mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Compare commits
33 Commits
OPENBSD_4_
...
OPENBSD_4_
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d816834954 | ||
![]() |
de36e6ec2f | ||
![]() |
7ef6f63557 | ||
![]() |
3f63e529bf | ||
![]() |
9cb4f8884e | ||
![]() |
09dbddac87 | ||
![]() |
a936ffc470 | ||
![]() |
de72f62924 | ||
![]() |
7fb2664f92 | ||
![]() |
1eed217b1c | ||
![]() |
e5cabb0f43 | ||
![]() |
3de5c68888 | ||
![]() |
160d6aa910 | ||
![]() |
847191cff3 | ||
![]() |
f82afee4e2 | ||
![]() |
381ba77e03 | ||
![]() |
01a3f493d6 | ||
![]() |
219f297493 | ||
![]() |
2e72df662d | ||
![]() |
8b3cd2243a | ||
![]() |
f14a3eeebf | ||
![]() |
19ae2f65de | ||
![]() |
3341229c74 | ||
![]() |
ebebed71bd | ||
![]() |
4b85adbe60 | ||
![]() |
576d299095 | ||
![]() |
dc39e11ff9 | ||
![]() |
6b00b86622 | ||
![]() |
e64e1709ba | ||
![]() |
699b048959 | ||
![]() |
af71fc930a | ||
![]() |
56994282f0 | ||
![]() |
0584867396 |
18
LICENSE
18
LICENSE
@@ -12,21 +12,3 @@
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
Parts derived from 9wm:
|
||||
|
||||
9wm is free software, and is Copyright (c) 1994 by David Hogan.
|
||||
Permission is granted to all sentient beings to use this software,
|
||||
to make copies of it, and to distribute those copies, provided
|
||||
that:
|
||||
|
||||
(1) the copyright and licence notices are left intact
|
||||
(2) the recipients are aware that it is free software
|
||||
(3) any unapproved changes in functionality are either
|
||||
(i) only distributed as patches
|
||||
or (ii) distributed as a new program which is not called 9wm
|
||||
and whose documentation gives credit where it is due
|
||||
(4) the author is not held responsible for any defects
|
||||
or shortcomings in the software, or damages caused by it.
|
||||
|
||||
There is no warranty for this software. Have a nice day.
|
||||
|
6
Makefile
6
Makefile
@@ -6,9 +6,9 @@ X11BASE?= /usr/X11R6
|
||||
|
||||
PROG= cwm
|
||||
|
||||
SRCS= calmwm.c draw.c screen.c xmalloc.c client.c grab.c search.c \
|
||||
util.c xutil.c conf.c input.c xevents.c group.c geographic.c \
|
||||
kbfunc.c cursor.c font.c
|
||||
SRCS= calmwm.c screen.c xmalloc.c client.c grab.c search.c \
|
||||
util.c xutil.c conf.c input.c xevents.c group.c \
|
||||
kbfunc.c font.c
|
||||
|
||||
CPPFLAGS+= -I${X11BASE}/include -I${X11BASE}/include/freetype2
|
||||
|
||||
|
5
README
5
README
@@ -52,8 +52,7 @@ DOCUMENTATION
|
||||
|
||||
LICENSE
|
||||
|
||||
cwm is distributed under a BSD like license. Feel free to use,
|
||||
modify and distribute in any form. See the LICENSE file for more
|
||||
information.
|
||||
cwm is distributed under a BSD like license. Please see the LICENSE
|
||||
file or the top of any source file for more information.
|
||||
|
||||
[1] http://evilwm.sourceforge.net/
|
||||
|
2
TODO
2
TODO
@@ -1,5 +1,3 @@
|
||||
- clean up menu code from 9wm
|
||||
|
||||
- window initial position
|
||||
|
||||
- don't map windows if it's within [some time increment] of active typing,
|
||||
|
78
calmwm.c
78
calmwm.c
@@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@@ -11,7 +22,6 @@
|
||||
#include "calmwm.h"
|
||||
|
||||
Display *X_Dpy;
|
||||
XFontStruct *X_Font;
|
||||
|
||||
Cursor Cursor_move;
|
||||
Cursor Cursor_resize;
|
||||
@@ -36,16 +46,6 @@ char *DefaultFontName;
|
||||
#define gray_height 2
|
||||
static char gray_bits[] = {0x02, 0x01};
|
||||
|
||||
/* List borrowed from 9wm/rio */
|
||||
char *tryfonts[] = {
|
||||
"9x15bold",
|
||||
"blit",
|
||||
"*-lucidatypewriter-bold-*-14-*-75-*",
|
||||
"*-lucidatypewriter-medium-*-12-*-75-*",
|
||||
"fixed",
|
||||
"*",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static void _sigchld_cb(int);
|
||||
|
||||
@@ -71,7 +71,7 @@ main(int argc, char **argv)
|
||||
DefaultFontName = xstrdup(optarg);
|
||||
break;
|
||||
default:
|
||||
errx(1, "Unknown option '%c'", ch);
|
||||
usage();
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
@@ -124,21 +124,13 @@ x_setup(char *display_name)
|
||||
TAILQ_INIT(&Screenq);
|
||||
|
||||
if ((X_Dpy = XOpenDisplay(display_name)) == NULL)
|
||||
errx(1, "%s:%d XOpenDisplay()", __FILE__, __LINE__);
|
||||
errx(1, "unable to open display \"%s\"",
|
||||
XDisplayName(display_name));
|
||||
|
||||
XSetErrorHandler(x_errorhandler);
|
||||
|
||||
Doshape = XShapeQueryExtension(X_Dpy, &Shape_ev, &i);
|
||||
|
||||
i = 0;
|
||||
while ((fontname = tryfonts[i++]) != NULL) {
|
||||
if ((X_Font = XLoadQueryFont(X_Dpy, fontname)) != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
if (fontname == NULL)
|
||||
errx(1, "Couldn't load any fonts.");
|
||||
|
||||
Nscreens = ScreenCount(X_Dpy);
|
||||
for (i = 0; i < (int)Nscreens; i++) {
|
||||
XMALLOC(sc, struct screen_ctx);
|
||||
@@ -148,15 +140,12 @@ x_setup(char *display_name)
|
||||
|
||||
Cursor_move = XCreateFontCursor(X_Dpy, XC_fleur);
|
||||
Cursor_resize = XCreateFontCursor(X_Dpy, XC_bottom_right_corner);
|
||||
/* (used to be) XCreateFontCursor(X_Dpy, XC_hand1); */
|
||||
Cursor_select = XCreateFontCursor(X_Dpy, XC_hand1);
|
||||
/* Cursor_select = cursor_bigarrow(Curscreen); */
|
||||
Cursor_default = XCreateFontCursor(X_Dpy, XC_X_cursor);
|
||||
/* Cursor_default = cursor_bigarrow(Curscreen); */
|
||||
Cursor_question = XCreateFontCursor(X_Dpy, XC_question_arrow);
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
x_setupscreen(struct screen_ctx *sc, u_int which)
|
||||
{
|
||||
XColor tmp;
|
||||
@@ -188,10 +177,6 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
||||
TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
|
||||
xu_key_grab(sc->rootwin, kb->modmask, kb->keysym);
|
||||
|
||||
/* Special -- for alt state. */
|
||||
/* xu_key_grab(sc->rootwin, 0, XK_Alt_L); */
|
||||
/* xu_key_grab(sc->rootwin, 0, XK_Alt_R); */
|
||||
|
||||
sc->blackpixl = BlackPixel(X_Dpy, sc->which);
|
||||
sc->whitepixl = WhitePixel(X_Dpy, sc->which);
|
||||
sc->bluepixl = sc->fccolor.pixel;
|
||||
@@ -215,32 +200,21 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
||||
gv.function = GXxor;
|
||||
gv.line_width = 1;
|
||||
gv.subwindow_mode = IncludeInferiors;
|
||||
gv.font = X_Font->fid;
|
||||
|
||||
sc->gc = XCreateGC(X_Dpy, sc->rootwin,
|
||||
GCForeground|GCBackground|GCFunction|
|
||||
GCLineWidth|GCSubwindowMode|GCFont, &gv);
|
||||
|
||||
#ifdef notyet
|
||||
gv2.foreground = sc->blackpixl^sc->cyanpixl;
|
||||
gv2.background = sc->cyanpixl;
|
||||
gv2.function = GXxor;
|
||||
gv2.line_width = 1;
|
||||
gv2.subwindow_mode = IncludeInferiors;
|
||||
gv2.font = X_Font->fid;
|
||||
#endif
|
||||
GCLineWidth|GCSubwindowMode, &gv);
|
||||
|
||||
sc->hlgc = XCreateGC(X_Dpy, sc->rootwin,
|
||||
GCForeground|GCBackground|GCFunction|
|
||||
GCLineWidth|GCSubwindowMode|GCFont, &gv);
|
||||
GCLineWidth|GCSubwindowMode, &gv);
|
||||
|
||||
gv1.function = GXinvert;
|
||||
gv1.subwindow_mode = IncludeInferiors;
|
||||
gv1.line_width = 1;
|
||||
gv1.font = X_Font->fid;
|
||||
|
||||
sc->invgc = XCreateGC(X_Dpy, sc->rootwin,
|
||||
GCFunction|GCSubwindowMode|GCLineWidth|GCFont, &gv1);
|
||||
GCFunction|GCSubwindowMode|GCLineWidth, &gv1);
|
||||
|
||||
font_init(sc);
|
||||
DefaultFont = font_getx(sc, DefaultFontName);
|
||||
@@ -277,15 +251,12 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
||||
rootattr.event_mask = ChildMask|PropertyChangeMask|EnterWindowMask|
|
||||
LeaveWindowMask|ColormapChangeMask|ButtonMask;
|
||||
|
||||
/* Set the root cursor to a nice obnoxious arrow :-) */
|
||||
/* rootattr.cursor = cursor_bigarrow(sc); */
|
||||
|
||||
XChangeWindowAttributes(X_Dpy, sc->rootwin,
|
||||
/* CWCursor| */CWEventMask, &rootattr);
|
||||
|
||||
XSync(X_Dpy, False);
|
||||
|
||||
return (0);
|
||||
return;
|
||||
}
|
||||
|
||||
char *
|
||||
@@ -350,3 +321,12 @@ _sigchld_cb(int which)
|
||||
(pid < 0 && errno == EINTR))
|
||||
;
|
||||
}
|
||||
|
||||
__dead void
|
||||
usage(void)
|
||||
{
|
||||
extern char *__progname;
|
||||
|
||||
fprintf(stderr, "usage: %s [-s] [-d display] [-f fontname] \n", __progname);
|
||||
exit(1);
|
||||
}
|
||||
|
46
calmwm.h
46
calmwm.h
@@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@@ -68,6 +79,10 @@ struct screen_ctx {
|
||||
|
||||
int altpersist;
|
||||
|
||||
int maxinitialised;
|
||||
int xmax;
|
||||
int ymax;
|
||||
|
||||
FILE *notifier;
|
||||
|
||||
struct cycle_entry_q mruq;
|
||||
@@ -209,6 +224,10 @@ enum directions {
|
||||
CWM_UP=0, CWM_DOWN, CWM_LEFT, CWM_RIGHT,
|
||||
};
|
||||
|
||||
/* for cwm_exec */
|
||||
#define CWM_EXEC_PROGRAM 0x1
|
||||
#define CWM_EXEC_WM 0x2
|
||||
|
||||
#define KBFLAG_NEEDCLIENT 0x01
|
||||
#define KBFLAG_FINDCLIENT 0x02
|
||||
|
||||
@@ -261,7 +280,6 @@ struct menu {
|
||||
char text[MENU_MAXENTRY + 1];
|
||||
char print[MENU_MAXENTRY + 1];
|
||||
void *ctx;
|
||||
short lasthit;
|
||||
short dummy;
|
||||
};
|
||||
|
||||
@@ -293,8 +311,8 @@ int input_keycodetrans(KeyCode, u_int, enum ctltype *, char *, int);
|
||||
int x_errorhandler(Display *, XErrorEvent *);
|
||||
void x_setup(char *display_name);
|
||||
char *x_screenname(int);
|
||||
void x_loop(void);
|
||||
int x_setupscreen(struct screen_ctx *, u_int);
|
||||
void x_setupscreen(struct screen_ctx *, u_int);
|
||||
__dead void usage(void);
|
||||
|
||||
struct client_ctx *client_find(Window);
|
||||
void client_setup(void);
|
||||
@@ -378,13 +396,13 @@ int dirent_exists(char *);
|
||||
int dirent_isdir(char *);
|
||||
int dirent_islink(char *);
|
||||
int u_spawn(char *);
|
||||
void exec_wm(char *);
|
||||
|
||||
int grab_sweep(struct client_ctx *);
|
||||
int grab_drag(struct client_ctx *);
|
||||
void grab_sweep(struct client_ctx *);
|
||||
void grab_drag(struct client_ctx *);
|
||||
void grab_menuinit(struct screen_ctx *);
|
||||
void *grab_menu(XButtonEvent *, struct menu_q *);
|
||||
void grab_label(struct client_ctx *);
|
||||
void grab_exec(void);
|
||||
|
||||
void xfree(void *);
|
||||
void *xmalloc(size_t);
|
||||
@@ -405,6 +423,8 @@ int conf_get_int(struct client_ctx *, enum conftype);
|
||||
void conf_client(struct client_ctx *);
|
||||
void conf_bindkey(struct conf *, void (*)(struct client_ctx *, void *),
|
||||
int, int, int, void *);
|
||||
void conf_bindname(struct conf *, char *, char *);
|
||||
void conf_unbind(struct conf *, struct keybinding *);
|
||||
void conf_parsekeys(struct conf *, char *);
|
||||
void conf_parsesettings(struct conf *, char *);
|
||||
void conf_parseignores(struct conf *, char *);
|
||||
@@ -432,14 +452,14 @@ void kbfunc_client_nogroup(struct client_ctx *, void *);
|
||||
void kbfunc_client_maximize(struct client_ctx *, void *);
|
||||
void kbfunc_client_vmaximize(struct client_ctx *, void *);
|
||||
void kbfunc_client_move(struct client_ctx *, void *);
|
||||
void kbfunc_client_resize(struct client_ctx *, void *);
|
||||
void kbfunc_menu_search(struct client_ctx *, void *);
|
||||
void kbfunc_exec(struct client_ctx *, void *);
|
||||
void kbfunc_ptrmove(struct client_ctx *, void *);
|
||||
void kbfunc_ssh(struct client_ctx *, void *);
|
||||
void kbfunc_term(struct client_ctx *cc, void *arg);
|
||||
void kbfunc_lock(struct client_ctx *cc, void *arg);
|
||||
|
||||
void draw_outline(struct client_ctx *);
|
||||
|
||||
void search_init(struct screen_ctx *);
|
||||
struct menu *search_start(struct menu_q *menuq,
|
||||
void (*match)(struct menu_q *, struct menu_q *, char *),
|
||||
@@ -453,8 +473,7 @@ void search_match_exec(struct menu_q *, struct menu_q *, char *);
|
||||
void search_rank_text(struct menu_q *, char *);
|
||||
|
||||
void group_init(void);
|
||||
int group_new(void);
|
||||
int group_select(int);
|
||||
void group_select(int);
|
||||
void group_enter(void);
|
||||
void group_exit(int);
|
||||
void group_click(struct client_ctx *);
|
||||
@@ -476,10 +495,6 @@ void group_autogroup(struct client_ctx *);
|
||||
|
||||
void notification_init(struct screen_ctx *);
|
||||
|
||||
struct client_ctx *geographic_west(struct client_ctx *);
|
||||
|
||||
Cursor cursor_bigarrow();
|
||||
|
||||
void font_init(struct screen_ctx *sc);
|
||||
struct fontdesc *font_get(struct screen_ctx *sc, const char *name);
|
||||
int font_width(struct fontdesc *fdp, const char *text, int len);
|
||||
@@ -494,7 +509,6 @@ struct fontdesc *font_getx(struct screen_ctx *sc, const char *name);
|
||||
/* Externs */
|
||||
|
||||
extern Display *X_Dpy;
|
||||
extern XFontStruct *X_Font;
|
||||
|
||||
extern Cursor Cursor_move;
|
||||
extern Cursor Cursor_resize;
|
||||
|
68
client.c
68
client.c
@@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@@ -91,7 +102,6 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
||||
cc->geom.y = wattr.y;
|
||||
cc->geom.width = wattr.width;
|
||||
cc->geom.height = wattr.height;
|
||||
cc->geom.height = wattr.height;
|
||||
cc->cmap = wattr.colormap;
|
||||
|
||||
if (wattr.map_state != IsViewable) {
|
||||
@@ -256,15 +266,6 @@ client_leave(struct client_ctx *cc)
|
||||
xu_btn_ungrab(sc->rootwin, AnyModifier, Button1);
|
||||
}
|
||||
|
||||
void
|
||||
client_nocurrent(void)
|
||||
{
|
||||
if (_curcc != NULL)
|
||||
client_setactive(_curcc, 0);
|
||||
|
||||
_curcc = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
client_setactive(struct client_ctx *cc, int fg)
|
||||
{
|
||||
@@ -351,19 +352,6 @@ client_maximize(struct client_ctx *cc)
|
||||
client_resize(cc);
|
||||
}
|
||||
|
||||
void
|
||||
client_push_geometry(struct client_ctx *cc)
|
||||
{
|
||||
cc->savegeom = cc->geom;
|
||||
}
|
||||
|
||||
void
|
||||
client_restore_geometry(struct client_ctx *cc)
|
||||
{
|
||||
cc->geom = cc->savegeom;
|
||||
client_resize(cc);
|
||||
}
|
||||
|
||||
void
|
||||
client_resize(struct client_ctx *cc)
|
||||
{
|
||||
@@ -397,13 +385,6 @@ client_raise(struct client_ctx *cc)
|
||||
client_draw_border(cc);
|
||||
}
|
||||
|
||||
void
|
||||
client_warp(struct client_ctx *cc)
|
||||
{
|
||||
client_raise(cc);
|
||||
xu_ptr_setpos(cc->pwin, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
client_ptrwarp(struct client_ctx *cc)
|
||||
{
|
||||
@@ -705,6 +686,10 @@ client_cycleinfo(struct client_ctx *cc)
|
||||
if ((diff = cc->geom.height - (y + h)) < 0)
|
||||
y += diff;
|
||||
|
||||
/* Don't hide the beginning of the window names */
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
|
||||
XReparentWindow(X_Dpy, sc->infowin, cc->win, 0, 0);
|
||||
XMoveResizeWindow(X_Dpy, sc->infowin, x, y, w, h);
|
||||
XMapRaised(X_Dpy, sc->infowin);
|
||||
@@ -802,12 +787,18 @@ client_placecalc(struct client_ctx *cc)
|
||||
mousey = MAX(mousey, (int)cc->bwidth);
|
||||
|
||||
if (cc->size->flags & USPosition) {
|
||||
x = cc->size->x;
|
||||
if (x <= 0 || x >= xmax)
|
||||
if (cc->size->x > 0)
|
||||
x = cc->size->x;
|
||||
if (x < cc->bwidth)
|
||||
x = cc->bwidth;
|
||||
y = cc->size->y;
|
||||
if (y <= 0 || y >= ymax)
|
||||
else if (x > xslack)
|
||||
x = xslack;
|
||||
if (cc->size->y > 0)
|
||||
y = cc->size->y;
|
||||
if (y < cc->bwidth)
|
||||
y = cc->bwidth;
|
||||
else if (y > yslack)
|
||||
y = yslack;
|
||||
} else {
|
||||
if (yslack < 0) {
|
||||
y = cc->bwidth;
|
||||
@@ -859,13 +850,6 @@ client_vertmaximize(struct client_ctx *cc)
|
||||
client_resize(cc);
|
||||
}
|
||||
|
||||
void
|
||||
client_map(struct client_ctx *cc)
|
||||
{
|
||||
/* mtf? */
|
||||
client_ptrwarp(cc);
|
||||
}
|
||||
|
||||
void
|
||||
client_mtf(struct client_ctx *cc)
|
||||
{
|
||||
|
390
conf.c
390
conf.c
@@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@@ -181,84 +192,67 @@ conf_setup(struct conf *c)
|
||||
conf_cmd_init(c);
|
||||
|
||||
TAILQ_INIT(&c->keybindingq);
|
||||
|
||||
conf_bindname(c, "CM-Return", "terminal");
|
||||
conf_bindname(c, "CM-Delete", "lock");
|
||||
conf_bindname(c, "M-question", "exec");
|
||||
conf_bindname(c, "CM-q", "exec_wm");
|
||||
conf_bindname(c, "M-period", "ssh");
|
||||
conf_bindname(c, "M-Return", "hide");
|
||||
conf_bindname(c, "M-Down", "lower");
|
||||
conf_bindname(c, "M-Up", "raise");
|
||||
conf_bindname(c, "M-slash", "search");
|
||||
conf_bindname(c, "C-slash", "menusearch");
|
||||
conf_bindname(c, "M-Tab", "cycle");
|
||||
conf_bindname(c, "MS-Tab", "rcycle");
|
||||
conf_bindname(c, "CM-n", "label");
|
||||
conf_bindname(c, "CM-x", "delete");
|
||||
conf_bindname(c, "CM-Escape", "groupselect");
|
||||
conf_bindname(c, "CM-0", "nogroup");
|
||||
conf_bindname(c, "CM-1", "group1");
|
||||
conf_bindname(c, "CM-2", "group2");
|
||||
conf_bindname(c, "CM-3", "group3");
|
||||
conf_bindname(c, "CM-4", "group4");
|
||||
conf_bindname(c, "CM-5", "group5");
|
||||
conf_bindname(c, "CM-6", "group6");
|
||||
conf_bindname(c, "CM-7", "group7");
|
||||
conf_bindname(c, "CM-8", "group8");
|
||||
conf_bindname(c, "CM-9", "group9");
|
||||
conf_bindname(c, "M-Right", "nextgroup");
|
||||
conf_bindname(c, "M-Left", "prevgroup");
|
||||
conf_bindname(c, "CM-f", "maximize");
|
||||
conf_bindname(c, "CM-equal", "vmaximize");
|
||||
|
||||
conf_bindname(c, "M-h", "moveleft");
|
||||
conf_bindname(c, "M-j", "movedown");
|
||||
conf_bindname(c, "M-k", "moveup");
|
||||
conf_bindname(c, "M-l", "moveright");
|
||||
conf_bindname(c, "M-H", "bigmoveleft");
|
||||
conf_bindname(c, "M-J", "bigmovedown");
|
||||
conf_bindname(c, "M-K", "bigmoveup");
|
||||
conf_bindname(c, "M-L", "bigmoveright");
|
||||
|
||||
conf_bindname(c, "CM-h", "resizeleft");
|
||||
conf_bindname(c, "CM-j", "resizedown");
|
||||
conf_bindname(c, "CM-k", "resizeup");
|
||||
conf_bindname(c, "CM-l", "resizeright");
|
||||
conf_bindname(c, "CM-H", "bigresizeleft");
|
||||
conf_bindname(c, "CM-J", "bigresizedown");
|
||||
conf_bindname(c, "CM-K", "bigresizeup");
|
||||
conf_bindname(c, "CM-L", "bigresizeright");
|
||||
|
||||
conf_bindname(c, "C-Left", "ptrmoveleft");
|
||||
conf_bindname(c, "C-Down", "ptrmovedown");
|
||||
conf_bindname(c, "C-Up", "ptrmoveup");
|
||||
conf_bindname(c, "C-Right", "ptrmoveright");
|
||||
conf_bindname(c, "CS-Left", "bigptrmoveleft");
|
||||
conf_bindname(c, "CS-Down", "bigptrmovedown");
|
||||
conf_bindname(c, "CS-Up", "bigptrmoveup");
|
||||
conf_bindname(c, "CS-Right", "bigptrmoveright");
|
||||
|
||||
snprintf(dir_keydefs, sizeof(dir_keydefs), "%s/.calmwm/.keys", home);
|
||||
if (dirent_isdir(dir_keydefs)) {
|
||||
if (dirent_isdir(dir_keydefs))
|
||||
conf_parsekeys(c, dir_keydefs);
|
||||
} else {
|
||||
conf_bindkey(c, kbfunc_term,
|
||||
XK_Return, ControlMask|Mod1Mask, 0, NULL);
|
||||
conf_bindkey(c, kbfunc_lock,
|
||||
XK_Delete, ControlMask|Mod1Mask, 0, NULL);
|
||||
conf_bindkey(c, kbfunc_exec, XK_question, Mod1Mask, 0, NULL);
|
||||
conf_bindkey(c, kbfunc_ssh, XK_period, Mod1Mask, 0, NULL);
|
||||
conf_bindkey(c, kbfunc_client_hide,
|
||||
XK_Return, Mod1Mask, KBFLAG_NEEDCLIENT, 0);
|
||||
conf_bindkey(c, kbfunc_client_lower,
|
||||
XK_Down, Mod1Mask, KBFLAG_NEEDCLIENT, 0);
|
||||
conf_bindkey(c, kbfunc_client_raise,
|
||||
XK_Up, Mod1Mask, KBFLAG_NEEDCLIENT, 0);
|
||||
conf_bindkey(c, kbfunc_client_search, XK_slash, Mod1Mask, 0, 0);
|
||||
conf_bindkey(c, kbfunc_menu_search,
|
||||
XK_slash, ControlMask, 0, 0);
|
||||
conf_bindkey(c, kbfunc_client_cycle,
|
||||
XK_Tab, Mod1Mask, 0, 0);
|
||||
conf_bindkey(c, kbfunc_client_rcycle,
|
||||
XK_Tab, Mod1Mask|ShiftMask, 0, 0);
|
||||
conf_bindkey(c, kbfunc_client_label, XK_l,
|
||||
ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0);
|
||||
conf_bindkey(c, kbfunc_client_delete, XK_x,
|
||||
ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0);
|
||||
conf_bindkey(c, kbfunc_client_groupselect,
|
||||
XK_Escape, ControlMask|Mod1Mask, 0, 0);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_1, ControlMask|Mod1Mask, 0, (void *) 1);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_2, ControlMask|Mod1Mask, 0, (void *) 2);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_3, ControlMask|Mod1Mask, 0, (void *) 3);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_4, ControlMask|Mod1Mask, 0, (void *) 4);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_5, ControlMask|Mod1Mask, 0, (void *) 5);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_6, ControlMask|Mod1Mask, 0, (void *) 6);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_7, ControlMask|Mod1Mask, 0, (void *) 7);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_8, ControlMask|Mod1Mask, 0, (void *) 8);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_9, ControlMask|Mod1Mask, 0, (void *) 9);
|
||||
conf_bindkey(c, kbfunc_client_nogroup,
|
||||
XK_0, ControlMask|Mod1Mask, 0, 0);
|
||||
conf_bindkey(c, kbfunc_client_nextgroup,
|
||||
XK_Right, Mod1Mask, 0, 0);
|
||||
conf_bindkey(c, kbfunc_client_prevgroup,
|
||||
XK_Left, Mod1Mask, 0, 0);
|
||||
conf_bindkey(c, kbfunc_client_maximize,
|
||||
XK_f, ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0);
|
||||
conf_bindkey(c, kbfunc_client_vmaximize,
|
||||
XK_equal, ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0);
|
||||
conf_bindkey(c, kbfunc_client_move,
|
||||
XK_k, Mod1Mask, KBFLAG_NEEDCLIENT, (void *)CWM_UP);
|
||||
conf_bindkey(c, kbfunc_client_move,
|
||||
XK_j, Mod1Mask, KBFLAG_NEEDCLIENT, (void *)CWM_DOWN);
|
||||
conf_bindkey(c, kbfunc_client_move,
|
||||
XK_l, Mod1Mask, KBFLAG_NEEDCLIENT, (void *)CWM_RIGHT);
|
||||
conf_bindkey(c, kbfunc_client_move,
|
||||
XK_h, Mod1Mask, KBFLAG_NEEDCLIENT, (void *)CWM_LEFT);
|
||||
conf_bindkey(c, kbfunc_client_move,
|
||||
XK_K, Mod1Mask, KBFLAG_NEEDCLIENT,
|
||||
(void *)(CWM_UP|CWM_BIGMOVE));
|
||||
conf_bindkey(c, kbfunc_client_move,
|
||||
XK_J, Mod1Mask, KBFLAG_NEEDCLIENT,
|
||||
(void *)(CWM_DOWN|CWM_BIGMOVE));
|
||||
conf_bindkey(c, kbfunc_client_move,
|
||||
XK_L, Mod1Mask, KBFLAG_NEEDCLIENT,
|
||||
(void *)(CWM_RIGHT|CWM_BIGMOVE));
|
||||
conf_bindkey(c, kbfunc_client_move,
|
||||
XK_H, Mod1Mask, KBFLAG_NEEDCLIENT,
|
||||
(void *)(CWM_LEFT|CWM_BIGMOVE));
|
||||
}
|
||||
|
||||
snprintf(dir_settings, sizeof(dir_settings),
|
||||
"%s/.calmwm/.settings", home);
|
||||
@@ -333,19 +327,6 @@ conf_get_int(struct client_ctx *cc, enum conftype ctype)
|
||||
return (val);
|
||||
}
|
||||
|
||||
char *
|
||||
conf_get_str(struct client_ctx *cc, enum conftype ctype)
|
||||
{
|
||||
switch (ctype) {
|
||||
case CONF_NOTIFIER:
|
||||
return xstrdup("./notifier.py"); /* XXX */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
conf_client(struct client_ctx *cc)
|
||||
{
|
||||
@@ -361,60 +342,70 @@ struct {
|
||||
} name_to_kbfunc[] = {
|
||||
{ "lower", kbfunc_client_lower, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "raise", kbfunc_client_raise, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "search", kbfunc_client_search, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "search", kbfunc_client_search, 0, 0 },
|
||||
{ "menusearch", kbfunc_menu_search, 0, 0 },
|
||||
{ "hide", kbfunc_client_hide, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "cycle", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "rcycle", kbfunc_client_rcycle, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "label", kbfunc_client_label, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "delete", kbfunc_client_delete, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "ptrmoveup", kbfunc_ptrmove, 0, (void *)CWM_UP },
|
||||
{ "ptrmovedown", kbfunc_ptrmove, 0, (void *)CWM_DOWN },
|
||||
{ "ptrmoveleft", kbfunc_ptrmove, 0, (void *)CWM_LEFT },
|
||||
{ "ptrmoveright", kbfunc_ptrmove, 0, (void *)CWM_RIGHT },
|
||||
{ "bigptrmoveup", kbfunc_ptrmove, 0, (void *)(CWM_UP|CWM_BIGMOVE) },
|
||||
{ "bigptrmovedown", kbfunc_ptrmove, 0, (void *)(CWM_DOWN|CWM_BIGMOVE) },
|
||||
{ "bigptrmoveleft", kbfunc_ptrmove, 0, (void *)(CWM_LEFT|CWM_BIGMOVE) },
|
||||
{ "bigptrmoveright", kbfunc_ptrmove, 0, (void *)(CWM_RIGHT|CWM_BIGMOVE) },
|
||||
{ "groupselect", kbfunc_client_groupselect, 0, 0 },
|
||||
{ "group1", kbfunc_client_group, 0, (void *) 1 },
|
||||
{ "group2", kbfunc_client_group, 0, (void *) 2 },
|
||||
{ "group3", kbfunc_client_group, 0, (void *) 3 },
|
||||
{ "group4", kbfunc_client_group, 0, (void *) 4 },
|
||||
{ "group5", kbfunc_client_group, 0, (void *) 5 },
|
||||
{ "group6", kbfunc_client_group, 0, (void *) 6 },
|
||||
{ "group7", kbfunc_client_group, 0, (void *) 7 },
|
||||
{ "group8", kbfunc_client_group, 0, (void *) 8 },
|
||||
{ "group9", kbfunc_client_group, 0, (void *) 9 },
|
||||
{ "nogroup", kbfunc_client_nogroup, 0, 0},
|
||||
{ "nextgroup", kbfunc_client_nextgroup, 0, 0},
|
||||
{ "prevgroup", kbfunc_client_prevgroup, 0, 0},
|
||||
{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, 0},
|
||||
{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, 0},
|
||||
{ "group1", kbfunc_client_group, 0, (void *)1 },
|
||||
{ "group2", kbfunc_client_group, 0, (void *)2 },
|
||||
{ "group3", kbfunc_client_group, 0, (void *)3 },
|
||||
{ "group4", kbfunc_client_group, 0, (void *)4 },
|
||||
{ "group5", kbfunc_client_group, 0, (void *)5 },
|
||||
{ "group6", kbfunc_client_group, 0, (void *)6 },
|
||||
{ "group7", kbfunc_client_group, 0, (void *)7 },
|
||||
{ "group8", kbfunc_client_group, 0, (void *)8 },
|
||||
{ "group9", kbfunc_client_group, 0, (void *)9 },
|
||||
{ "nogroup", kbfunc_client_nogroup, 0, 0 },
|
||||
{ "nextgroup", kbfunc_client_nextgroup, 0, 0 },
|
||||
{ "prevgroup", kbfunc_client_prevgroup, 0, 0 },
|
||||
{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "exec", kbfunc_exec, 0, (void *)CWM_EXEC_PROGRAM },
|
||||
{ "exec_wm", kbfunc_exec, 0, (void *)CWM_EXEC_WM },
|
||||
{ "ssh", kbfunc_ssh, 0, 0 },
|
||||
{ "terminal", kbfunc_term, 0, 0 },
|
||||
{ "lock", kbfunc_lock, 0, 0 },
|
||||
{ "moveup", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)CWM_UP },
|
||||
{ "movedown", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)CWM_DOWN },
|
||||
{ "moveright", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)CWM_RIGHT },
|
||||
{ "moveleft", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)CWM_LEFT },
|
||||
{ "bigmoveup", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)(CWM_UP|CWM_BIGMOVE) },
|
||||
{ "bigmovedown", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)(CWM_DOWN|CWM_BIGMOVE) },
|
||||
{ "bigmoveright", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)(CWM_RIGHT|CWM_BIGMOVE) },
|
||||
{ "bigmoveleft", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)(CWM_LEFT|CWM_BIGMOVE) },
|
||||
{ "resizeup", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)(CWM_UP) },
|
||||
{ "resizedown", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)CWM_DOWN },
|
||||
{ "resizeright", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)CWM_RIGHT },
|
||||
{ "resizeleft", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)CWM_LEFT },
|
||||
{ "bigresizeup", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)(CWM_UP|CWM_BIGMOVE) },
|
||||
{ "bigresizedown", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)(CWM_DOWN|CWM_BIGMOVE) },
|
||||
{ "bigresizeright", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)(CWM_RIGHT|CWM_BIGMOVE) },
|
||||
{ "bigresizeleft", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)(CWM_LEFT|CWM_BIGMOVE) },
|
||||
{ NULL, NULL, 0, 0},
|
||||
};
|
||||
|
||||
void
|
||||
conf_bindkey(struct conf *c, void (*arg_callback)(struct client_ctx *, void *),
|
||||
int arg_keysym, int arg_modmask, int arg_flags, void * arg_arg)
|
||||
{
|
||||
struct keybinding *kb;
|
||||
|
||||
XMALLOC(kb, struct keybinding);
|
||||
|
||||
kb->modmask = arg_modmask;
|
||||
kb->keysym = arg_keysym;
|
||||
kb->keycode = 0;
|
||||
kb->flags = arg_flags;
|
||||
kb->callback = arg_callback;
|
||||
kb->argument = arg_arg;
|
||||
TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry);
|
||||
}
|
||||
|
||||
void
|
||||
conf_parsekeys(struct conf *c, char *filename)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
struct keybinding *current_binding;
|
||||
int iter;
|
||||
char buffer[MAXPATHLEN];
|
||||
char current_file[MAXPATHLEN];
|
||||
|
||||
dir = opendir(filename);
|
||||
while ((ent = readdir(dir)) != NULL) {
|
||||
char *substring;
|
||||
if (ent->d_name[0] == '.')
|
||||
continue;
|
||||
|
||||
@@ -425,66 +416,113 @@ conf_parsekeys(struct conf *c, char *filename)
|
||||
if (!dirent_islink(current_file))
|
||||
continue;
|
||||
|
||||
XCALLOC(current_binding, struct keybinding);
|
||||
|
||||
if (strchr(ent->d_name, 'C') != NULL &&
|
||||
strchr(ent->d_name, 'C') < strchr(ent->d_name, '-'))
|
||||
current_binding->modmask |= ControlMask;
|
||||
|
||||
if (strchr(ent->d_name, 'M') != NULL &&
|
||||
strchr(ent->d_name, 'M') < strchr(ent->d_name, '-'))
|
||||
current_binding->modmask |= Mod1Mask;
|
||||
|
||||
substring = strchr(ent->d_name, '-') + 1;
|
||||
|
||||
/* If there is no '-' in name, continue as is */
|
||||
if (strchr(ent->d_name, '-') == NULL)
|
||||
substring = ent->d_name;
|
||||
|
||||
if (substring[0] == '[' &&
|
||||
substring[strlen(substring)-1] == ']') {
|
||||
sscanf(substring, "[%d]", ¤t_binding->keycode);
|
||||
current_binding->keysym = NoSymbol;
|
||||
} else {
|
||||
current_binding->keycode = 0;
|
||||
current_binding->keysym = XStringToKeysym(substring);
|
||||
}
|
||||
|
||||
if (current_binding->keysym == NoSymbol &&
|
||||
current_binding->keycode == 0 ) {
|
||||
xfree(current_binding);
|
||||
continue;
|
||||
}
|
||||
|
||||
memset(buffer, 0, MAXPATHLEN);
|
||||
if (readlink(current_file, buffer, MAXPATHLEN) < 0) {
|
||||
free(current_binding);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (iter = 0; name_to_kbfunc[iter].tag != NULL; iter++) {
|
||||
if (strcmp(name_to_kbfunc[iter].tag, buffer) != 0)
|
||||
continue;
|
||||
|
||||
current_binding->callback = name_to_kbfunc[iter].handler;
|
||||
current_binding->flags = name_to_kbfunc[iter].flags;
|
||||
current_binding->argument = name_to_kbfunc[iter].argument;
|
||||
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
||||
break;
|
||||
}
|
||||
|
||||
if (name_to_kbfunc[iter].tag != NULL)
|
||||
if (readlink(current_file, buffer, MAXPATHLEN) < 0)
|
||||
continue;
|
||||
|
||||
current_binding->callback = kbfunc_cmdexec;
|
||||
current_binding->argument = strdup(buffer);
|
||||
current_binding->flags = 0;
|
||||
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
||||
conf_bindname(c, ent->d_name, buffer);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
void
|
||||
conf_bindname(struct conf *c, char *name, char *binding)
|
||||
{
|
||||
int iter;
|
||||
struct keybinding *current_binding;
|
||||
char *substring;
|
||||
|
||||
XCALLOC(current_binding, struct keybinding);
|
||||
|
||||
if (strchr(name, 'C') != NULL &&
|
||||
strchr(name, 'C') < strchr(name, '-'))
|
||||
current_binding->modmask |= ControlMask;
|
||||
|
||||
if (strchr(name, 'M') != NULL &&
|
||||
strchr(name, 'M') < strchr(name, '-'))
|
||||
current_binding->modmask |= Mod1Mask;
|
||||
|
||||
if (strchr(name, '2') != NULL &&
|
||||
strchr(name, '2') < strchr(name, '-'))
|
||||
current_binding->modmask |= Mod2Mask;
|
||||
|
||||
if (strchr(name, '3') != NULL &&
|
||||
strchr(name, '3') < strchr(name, '-'))
|
||||
current_binding->modmask |= Mod3Mask;
|
||||
|
||||
if (strchr(name, '4') != NULL &&
|
||||
strchr(name, '4') < strchr(name, '-'))
|
||||
current_binding->modmask |= Mod4Mask;
|
||||
|
||||
if (strchr(name, 'S') != NULL &&
|
||||
strchr(name, 'S') < strchr(name, '-'))
|
||||
current_binding->modmask |= ShiftMask;
|
||||
|
||||
substring = strchr(name, '-') + 1;
|
||||
|
||||
/* If there is no '-' in name, continue as is */
|
||||
if (strchr(name, '-') == NULL)
|
||||
substring = name;
|
||||
|
||||
if (substring[0] == '[' &&
|
||||
substring[strlen(substring)-1] == ']') {
|
||||
sscanf(substring, "[%d]", ¤t_binding->keycode);
|
||||
current_binding->keysym = NoSymbol;
|
||||
} else {
|
||||
current_binding->keycode = 0;
|
||||
current_binding->keysym = XStringToKeysym(substring);
|
||||
}
|
||||
|
||||
if (current_binding->keysym == NoSymbol &&
|
||||
current_binding->keycode == 0 ) {
|
||||
xfree(current_binding);
|
||||
return;
|
||||
}
|
||||
|
||||
/* We now have the correct binding, remove duplicates. */
|
||||
conf_unbind(c, current_binding);
|
||||
|
||||
if (strcmp("unmap",binding) == 0)
|
||||
return;
|
||||
|
||||
for (iter = 0; name_to_kbfunc[iter].tag != NULL; iter++) {
|
||||
if (strcmp(name_to_kbfunc[iter].tag, binding) != 0)
|
||||
continue;
|
||||
|
||||
current_binding->callback = name_to_kbfunc[iter].handler;
|
||||
current_binding->flags = name_to_kbfunc[iter].flags;
|
||||
current_binding->argument = name_to_kbfunc[iter].argument;
|
||||
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
||||
break;
|
||||
}
|
||||
|
||||
if (name_to_kbfunc[iter].tag != NULL)
|
||||
return;
|
||||
|
||||
current_binding->callback = kbfunc_cmdexec;
|
||||
current_binding->argument = strdup(binding);
|
||||
current_binding->flags = 0;
|
||||
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
||||
return;
|
||||
}
|
||||
|
||||
void conf_unbind(struct conf *c, struct keybinding *unbind)
|
||||
{
|
||||
struct keybinding *key = NULL;
|
||||
|
||||
TAILQ_FOREACH(key, &c->keybindingq, entry) {
|
||||
if (key->modmask != unbind->modmask)
|
||||
continue;
|
||||
|
||||
if ((key->keycode != 0 && key->keysym == NoSymbol &&
|
||||
key->keycode == unbind->keycode) ||
|
||||
key->keysym == unbind->keysym)
|
||||
TAILQ_REMOVE(&c->keybindingq, key, entry);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
conf_parsesettings(struct conf *c, char *filename)
|
||||
{
|
||||
|
65
cursor.c
65
cursor.c
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* cursor.c
|
||||
*
|
||||
* Copyright (c) 2005 Marius Eriksen <marius@monkey.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
|
||||
/* Pretty much straight out of 9wm... */
|
||||
|
||||
struct cursor_data {
|
||||
int width;
|
||||
int hot[2];
|
||||
u_char mask[64];
|
||||
u_char fore[64];
|
||||
};
|
||||
|
||||
static struct cursor_data Bigarrow = {
|
||||
16,
|
||||
{0, 0},
|
||||
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0x3F,
|
||||
0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x1F, 0xFF, 0x3F,
|
||||
0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0x3F,
|
||||
0xCF, 0x1F, 0x8F, 0x0F, 0x07, 0x07, 0x03, 0x02,
|
||||
},
|
||||
{ 0x00, 0x00, 0xFE, 0x7F, 0xFE, 0x3F, 0xFE, 0x0F,
|
||||
0xFE, 0x07, 0xFE, 0x07, 0xFE, 0x0F, 0xFE, 0x1F,
|
||||
0xFE, 0x3F, 0xFE, 0x7F, 0xFE, 0x3F, 0xCE, 0x1F,
|
||||
0x86, 0x0F, 0x06, 0x07, 0x02, 0x02, 0x00, 0x00,
|
||||
},
|
||||
};
|
||||
|
||||
static Cursor
|
||||
_mkcursor(struct cursor_data *c, struct screen_ctx *sc)
|
||||
{
|
||||
Pixmap f, m;
|
||||
|
||||
f = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin, (char *)c->fore,
|
||||
c->width, c->width, 1, 0, 1);
|
||||
m = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin, (char *)c->mask,
|
||||
c->width, c->width, 1, 0, 1);
|
||||
|
||||
return (XCreatePixmapCursor(X_Dpy, f, m,
|
||||
&sc->blackcolor, &sc->whitecolor, c->hot[0], c->hot[1]));
|
||||
}
|
||||
|
||||
Cursor
|
||||
cursor_bigarrow(struct screen_ctx *sc)
|
||||
{
|
||||
return _mkcursor(&Bigarrow, sc);
|
||||
}
|
||||
|
131
cwm.1
131
cwm.1
@@ -1,5 +1,19 @@
|
||||
.\" $OpenBSD$
|
||||
.\"
|
||||
.\" Copyright (c) 2004,2005 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and distribute this software for any
|
||||
.\" purpose with or without fee is hereby granted, provided that the above
|
||||
.\" copyright notice and this permission notice appear in all copies.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
.\"
|
||||
.\" The following requests are required for all man pages.
|
||||
.Dd June 29, 2007
|
||||
.Dt CWM 1
|
||||
@@ -15,15 +29,10 @@
|
||||
.Op Fl f Ar fontname
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
is a window manager for X11.
|
||||
It was originally inspired by evilwm, but was rewritten from scratch
|
||||
due to limitations in the evilwm codebase.
|
||||
The from-scratch rewrite borrowed some code from 9wm.
|
||||
is a window manager for X11 which contains many features that
|
||||
concentrate on the efficiency and transparency of window management.
|
||||
.Nm
|
||||
contains many new features which all concentrate on the efficiency and
|
||||
transparency of window management.
|
||||
.Nm
|
||||
also aims to maintain the most simplest and pleasant aesthetic.
|
||||
also aims to maintain the simplest and most pleasant aesthetic.
|
||||
.Pp
|
||||
The following notation is used throughout this page:
|
||||
.Pp
|
||||
@@ -63,7 +72,7 @@ Raise current window.
|
||||
Search for windows.
|
||||
.It Ic C-/
|
||||
Search for applications.
|
||||
.It Ic C-M-l
|
||||
.It Ic C-M-n
|
||||
Label current window.
|
||||
.It Ic M-Tab
|
||||
Cycle through currently visible windows.
|
||||
@@ -98,6 +107,12 @@ This parses
|
||||
to provide host auto-completion.
|
||||
.Xr ssh 1
|
||||
will be executed via the configured terminal emulator.
|
||||
.It Ic C-M-q
|
||||
Spawn
|
||||
.Dq Exec WindowManager
|
||||
dialog; allows you to switch from
|
||||
.Nm
|
||||
to another window manager without restarting the X server.
|
||||
.El
|
||||
.Pp
|
||||
The mouse bindings are also important, they are:
|
||||
@@ -133,13 +148,25 @@ The default behavior for new windows is to not assign any group.
|
||||
This changes the default behavior to assigning the currrently selected
|
||||
group to any newly created windows.
|
||||
.El
|
||||
.Sh WINDOW MOVEMENT
|
||||
.Sh POINTER MOVEMENT
|
||||
The pointer can be moved with the use of the keyboard through bindings.
|
||||
C-[UP|DOWN|LEFT|RIGHT] moves the pointer a small amount, while
|
||||
C-shift-[UP|DOWN|LEFT|RIGHT] moves the pointer a larger amount.
|
||||
For example, to move the pointer to the left by a small amount,
|
||||
press C-LEFT.
|
||||
To move the pointer down by a larger amount, press C-shift-DOWN.
|
||||
.Sh WINDOW MOVEMENT AND RESIZING
|
||||
.Nm
|
||||
windows can be moved with the use of the keyboard through Vi-like bindings.
|
||||
M-[hjkl] moves the current window a small amount, while M-shift-[hjkl] moves
|
||||
the current window a larger amount.
|
||||
For example, to move the current window to the left a small amount, press M-h.
|
||||
To move the current window down by a larger amount, press M-shift-j.
|
||||
.Pp
|
||||
Similarly, windows may be resized with the same keybindings with the addition
|
||||
of the Control key.
|
||||
C-M-[hjkl] resizes the window a small amount and C-M-shift-[hjkl]
|
||||
resizes by a larger increment.
|
||||
.Sh SEARCH
|
||||
.Nm
|
||||
features the ability to search for windows by their current title,
|
||||
@@ -254,16 +281,77 @@ class go to the third group:
|
||||
.Bd -literal -offset indent
|
||||
$ ln -s three ~/.calmwm/.autogroup/XTerm
|
||||
.Ed
|
||||
.It Pa ~/.calmwm/.settings
|
||||
Files in this directory cause various configuration options to be
|
||||
set or unset.
|
||||
Currently the only setting availiable is whether or not sticky groups
|
||||
are activated.
|
||||
To activate sticky groups create a file in this directory with the name
|
||||
``sticky''.
|
||||
.It Pa ~/.calmwm/.ignore
|
||||
Any files in this directory cause
|
||||
.Nm
|
||||
to ignore programs by that name by not drawing borders around them.
|
||||
For example the command
|
||||
.Bd -literal -offset indent
|
||||
$ ln -s three ~/.calmwm/.ignore/xclock
|
||||
.Ed
|
||||
will cause any instances of
|
||||
.Xr xclock 1
|
||||
to not have borders.
|
||||
.It Pa ~/.calmwm/.keys
|
||||
Symlinks in this directory cause the creation of keyboard shortcuts.
|
||||
The default shortcuts will always be created. In case of conflict,
|
||||
user-defined shortcuts take precidence.
|
||||
The name of a link here is first the modifier keys, followed by a ``-''.
|
||||
The following modifiers are recognised:
|
||||
.Bl -tag -width Ds
|
||||
.It Pa C
|
||||
The Control key.
|
||||
.It Pa M
|
||||
The Meta key.
|
||||
.It Pa S
|
||||
The Shift key.
|
||||
.It Pa 2
|
||||
The Mod2 key.
|
||||
.It Pa 3
|
||||
The Mod3 key.
|
||||
.It Pa 4
|
||||
The Mod4 key (normally the windows key).
|
||||
.El
|
||||
The ``-'' should be followed by either a keysym name, taken from
|
||||
.Pa /usr/X11R6/include/X11/keysymdef.h ,
|
||||
or a numerical keycode value enclosed in ``[]''.
|
||||
The target of the link should be either the name of a task from the
|
||||
``name_to_kbfunc''
|
||||
structure in
|
||||
.Pa conf.c ,
|
||||
or, alternatively it should be the commandline that is wished to be executed.
|
||||
A special case is the ``unmap'' keyword, which causes any bindings using the
|
||||
named shortcut to be removed. This can be used to remove a binding which conflicts
|
||||
with an application.
|
||||
For example, to cause
|
||||
.Ic C-M-r
|
||||
to add a label to a window:
|
||||
.Bd -literal -offset indent
|
||||
$ ln -s "label" ~/.calmwm/.keys/CM-r
|
||||
.Ed
|
||||
Launch an xterm running
|
||||
.Xr top 1
|
||||
with C-S-Enter:
|
||||
.Bd -literal -offset indent
|
||||
$ ln -s "/usr/X11R6/bin/xterm -e top" ~/.calmwm/.keys/CS-Return
|
||||
.Ed
|
||||
Remove a keybinding for Mod4-o
|
||||
.Bd -literal -offset indent
|
||||
$ ln -s "unmap" 4-o
|
||||
.Ed
|
||||
.El
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
.Pp
|
||||
.Nm
|
||||
contains some code from 9wm.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
software has been developed by
|
||||
was developed by
|
||||
.An Marius Aamodt Eriksen Aq marius@monkey.org
|
||||
with contributions from
|
||||
.An Andy Adamson Aq dros@monkey.org ,
|
||||
@@ -271,6 +359,13 @@ with contributions from
|
||||
and
|
||||
.An Antti Nyk<EFBFBD>nen Aq aon@iki.fi .
|
||||
Ideas, discussion with many others.
|
||||
.\" .Sh HISTORY
|
||||
.\".Aq marius@monkey.org .
|
||||
.\" .Sh CAVEATS
|
||||
.Sh HISTORY
|
||||
.Nm
|
||||
was originally inspired by evilwm, but was rewritten from scratch
|
||||
due to limitations in the evilwm codebase.
|
||||
The from-scratch rewrite borrowed some code from 9wm, however that code
|
||||
has since been removed or rewritten.
|
||||
.Pp
|
||||
.Nm
|
||||
first appeared in
|
||||
.Ox 4.2 .
|
||||
|
21
draw.c
21
draw.c
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
|
||||
void
|
||||
draw_outline(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = CCTOSC(cc);
|
||||
|
||||
XDrawRectangle(X_Dpy, sc->rootwin, sc->invgc,
|
||||
cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth,
|
||||
cc->geom.width + cc->bwidth, cc->geom.height + cc->bwidth);
|
||||
}
|
53
geographic.c
53
geographic.c
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
|
||||
struct client_ctx *
|
||||
geographic_west(struct client_ctx *from_cc)
|
||||
{
|
||||
/* Window *wins, w0, w1; */
|
||||
/* struct screen_ctx *sc = screen_current(); */
|
||||
/* u_int nwins, i; */
|
||||
/* struct client_ctx *cc; */
|
||||
|
||||
screen_updatestackingorder();
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int
|
||||
_visible(struct client_ctx *this_cc)
|
||||
{
|
||||
int stacking = cc->stackingorder;
|
||||
struct client_ctx *cc;
|
||||
|
||||
if (cc->flags & CLIENT_HIDDEN)
|
||||
return (0);
|
||||
|
||||
TAILQ_FOREACH(cc, &Clientq, entry) {
|
||||
if (cc->flags & CLIENT_HIDDEN)
|
||||
continue;
|
||||
|
||||
if (cc->stackingorder > stacking &&
|
||||
cc->geom.x <= this_cc->geom.x &&
|
||||
cc->geom.y <= this_cc->geom.y &&
|
||||
cc->geom.width > (this_cc->geom.width +
|
||||
(this_cc->geom.x - cc->geom.x) &&
|
||||
|
||||
|
||||
cc->geom.height > (this_cc->geom.height - cc->geom.height))
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
#endif
|
361
grab.c
361
grab.c
@@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@@ -10,8 +21,8 @@
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
|
||||
int _sweepcalc(struct client_ctx *, int, int, int, int);
|
||||
int _nobuttons(XButtonEvent *);
|
||||
static int _sweepcalc(struct client_ctx *, int, int, int, int);
|
||||
static int menu_calc_entry(int, int, int, int, int);
|
||||
|
||||
#define ADJUST_HEIGHT(cc, dy) ((cc->geom.height - cc->geom.min_dy)/ dy)
|
||||
#define ADJUST_WIDTH(cc, dx) ((cc->geom.width - cc->geom.min_dx)/ dx)
|
||||
@@ -42,7 +53,7 @@ grab_sweep_draw(struct client_ctx *cc, int dx, int dy)
|
||||
wide/2 - wide_size/2, height + font_ascent(font) + 1);
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
grab_sweep(struct client_ctx *cc)
|
||||
{
|
||||
XEvent ev;
|
||||
@@ -57,7 +68,7 @@ grab_sweep(struct client_ctx *cc)
|
||||
client_ptrsave(cc);
|
||||
|
||||
if (xu_ptr_grab(sc->rootwin, MouseMask, Cursor_resize) < 0)
|
||||
return (-1);
|
||||
return;
|
||||
|
||||
xu_ptr_setpos(cc->win, cc->geom.width, cc->geom.height);
|
||||
grab_sweep_draw(cc, dx, dy);
|
||||
@@ -90,13 +101,13 @@ grab_sweep(struct client_ctx *cc)
|
||||
XReparentWindow(X_Dpy, sc->menuwin, sc->rootwin, 0, 0);
|
||||
xu_ptr_ungrab();
|
||||
client_ptrwarp(cc);
|
||||
return (0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
grab_drag(struct client_ctx *cc)
|
||||
{
|
||||
int x0 = cc->geom.x, y0 = cc->geom.y, xm, ym;
|
||||
@@ -106,7 +117,7 @@ grab_drag(struct client_ctx *cc)
|
||||
client_raise(cc);
|
||||
|
||||
if (xu_ptr_grab(sc->rootwin, MouseMask, Cursor_move) < 0)
|
||||
return (-1);
|
||||
return;
|
||||
|
||||
xu_ptr_getpos(sc->rootwin, &xm, &ym);
|
||||
|
||||
@@ -127,211 +138,117 @@ grab_drag(struct client_ctx *cc)
|
||||
break;
|
||||
case ButtonRelease:
|
||||
xu_ptr_ungrab();
|
||||
return (0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/*
|
||||
* Adapted from 9wm.
|
||||
*/
|
||||
|
||||
/* XXX - this REALLY needs to be cleaned up. */
|
||||
|
||||
#define MenuMask (ButtonMask|ButtonMotionMask|ExposureMask)
|
||||
#define MenuGrabMask (ButtonMask|ButtonMotionMask|StructureNotifyMask)
|
||||
#define AllButtonMask (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
|
||||
|
||||
#ifdef notyet
|
||||
struct client_ctx *
|
||||
grab_menu_getcc(struct menu_q *menuq, int off)
|
||||
{
|
||||
int where = 0;
|
||||
struct menu *mi;
|
||||
|
||||
TAILQ_FOREACH(mi, menuq, entry)
|
||||
if (off == where++)
|
||||
return mi->ctx;
|
||||
return (NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
void *
|
||||
grab_menu(XButtonEvent *e, struct menu_q *menuq)
|
||||
{
|
||||
struct screen_ctx *sc;
|
||||
struct menu *mi;
|
||||
XEvent ev;
|
||||
int i, n, cur = 0, old, wide, high, status, drawn, warp;
|
||||
int x, y, dx, dy, xmax, ymax;
|
||||
int tx, ty;
|
||||
XEvent event;
|
||||
struct fontdesc *font = DefaultFont;
|
||||
int x, y, width, height, tothigh, i, no, entry, prev;
|
||||
int fx, fy;
|
||||
|
||||
no = i = width = 0;
|
||||
|
||||
if ((sc = screen_fromroot(e->root)) == NULL || e->window == sc->menuwin)
|
||||
return (NULL);
|
||||
|
||||
dx = 0;
|
||||
i = 0;
|
||||
TAILQ_FOREACH(mi, menuq, entry) {
|
||||
wide = font_width(font, mi->text, strlen(mi->text)) + 4;
|
||||
if (wide > dx)
|
||||
dx = wide;
|
||||
if (mi->lasthit)
|
||||
cur = i;
|
||||
i++;
|
||||
i = font_width(font, mi->text, strlen(mi->text)) + 4;
|
||||
if (i > width)
|
||||
width = i;
|
||||
no++;
|
||||
}
|
||||
|
||||
n = i;
|
||||
if (!sc->maxinitialised) {
|
||||
sc->xmax = DisplayWidth(X_Dpy, sc->which);
|
||||
sc->ymax = DisplayHeight(X_Dpy, sc->which);
|
||||
}
|
||||
|
||||
wide = dx;
|
||||
high = font_ascent(font) + font_descent(font) + 1;
|
||||
dy = n*high;
|
||||
x = e->x - wide/2;
|
||||
y = e->y - cur*high - high/2;
|
||||
warp = 0;
|
||||
/* XXX - cache these in sc. */
|
||||
xmax = DisplayWidth(X_Dpy, sc->which);
|
||||
ymax = DisplayHeight(X_Dpy, sc->which);
|
||||
if (x < 0) {
|
||||
e->x -= x;
|
||||
height = font_ascent(font) + font_descent(font) + 1;
|
||||
tothigh = height * no;
|
||||
|
||||
x = e->x - width/2;
|
||||
y = e->y - height/2;
|
||||
|
||||
/* does it fit on the screen? */
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
warp++;
|
||||
}
|
||||
if (x+wide >= xmax) {
|
||||
e->x -= x+wide-xmax;
|
||||
x = xmax-wide;
|
||||
warp++;
|
||||
}
|
||||
if (y < 0) {
|
||||
e->y -= y;
|
||||
y = 0;
|
||||
warp++;
|
||||
}
|
||||
if (y+dy >= ymax) {
|
||||
e->y -= y+dy-ymax;
|
||||
y = ymax-dy;
|
||||
warp++;
|
||||
}
|
||||
if (warp)
|
||||
xu_ptr_setpos(e->root, e->x, e->y);
|
||||
else if (x+width >= sc->xmax)
|
||||
x = sc->xmax - width;
|
||||
|
||||
XMoveResizeWindow(X_Dpy, sc->menuwin, x, y, dx, dy);
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
else if (y+tothigh >= sc->ymax)
|
||||
y = sc->ymax - tothigh;
|
||||
|
||||
xu_ptr_setpos(e->root, x + width/2, y + height/2);
|
||||
|
||||
XMoveResizeWindow(X_Dpy, sc->menuwin, x, y, width, tothigh);
|
||||
XSelectInput(X_Dpy, sc->menuwin, MenuMask);
|
||||
XMapRaised(X_Dpy, sc->menuwin);
|
||||
status = xu_ptr_grab(sc->menuwin, MenuGrabMask, Cursor_select);
|
||||
if (status < 0) {
|
||||
|
||||
if (xu_ptr_grab(sc->menuwin, MenuGrabMask, Cursor_select) < 0) {
|
||||
XUnmapWindow(X_Dpy, sc->menuwin);
|
||||
return (NULL);
|
||||
}
|
||||
drawn = 0;
|
||||
|
||||
#ifdef notyet
|
||||
if (e->button == Button1) {
|
||||
struct client_ctx *cc;
|
||||
cc = grab_menu_getcc(menuq, cur);
|
||||
if (cc != NULL) {
|
||||
client_unhide(cc);
|
||||
XRaiseWindow(X_Dpy, sc->menuwin);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
entry = prev = -1;
|
||||
|
||||
for (;;) {
|
||||
XMaskEvent(X_Dpy, MenuMask, &ev);
|
||||
switch (ev.type) {
|
||||
default:
|
||||
warnx("menuhit: unknown ev.type %d\n", ev.type);
|
||||
break;
|
||||
case ButtonPress:
|
||||
break;
|
||||
case ButtonRelease:
|
||||
if (ev.xbutton.button != e->button)
|
||||
break;
|
||||
x = ev.xbutton.x;
|
||||
y = ev.xbutton.y;
|
||||
i = y/high;
|
||||
if (cur >= 0 && y >= cur*high-3 && y < (cur+1)*high+3)
|
||||
i = cur;
|
||||
if (x < 0 || x > wide || y < -3)
|
||||
i = -1;
|
||||
else if (i < 0 || i >= n)
|
||||
i = -1;
|
||||
/* else */
|
||||
/* m->lasthit = i; */
|
||||
if (!_nobuttons(&ev.xbutton))
|
||||
i = -1;
|
||||
|
||||
/* XXX */
|
||||
/* ungrab(&ev.xbutton); */
|
||||
xu_ptr_ungrab();
|
||||
XUnmapWindow(X_Dpy, sc->menuwin);
|
||||
n = 0;
|
||||
TAILQ_FOREACH(mi, menuq, entry)
|
||||
if (i == n++)
|
||||
break;
|
||||
|
||||
return (mi);
|
||||
case MotionNotify:
|
||||
if (!drawn)
|
||||
break;
|
||||
x = ev.xbutton.x;
|
||||
y = ev.xbutton.y;
|
||||
old = cur;
|
||||
cur = y/high;
|
||||
if (old >= 0 && y >= old*high-3 && y < (old+1)*high+3)
|
||||
cur = old;
|
||||
if (x < 0 || x > wide || y < -3)
|
||||
cur = -1;
|
||||
else if (cur < 0 || cur >= n)
|
||||
cur = -1;
|
||||
if (cur == old)
|
||||
break;
|
||||
if (old >= 0 && old < n) {
|
||||
#ifdef notyet
|
||||
if (e->button == Button1) {
|
||||
struct client_ctx *cc;
|
||||
cc = grab_menu_getcc(menuq, old);
|
||||
if (cc != NULL)
|
||||
client_hide(cc);
|
||||
}
|
||||
#endif
|
||||
XFillRectangle(X_Dpy, sc->menuwin,
|
||||
sc->hlgc, 0, old*high, wide, high);
|
||||
}
|
||||
if (cur >= 0 && cur < n) {
|
||||
#ifdef notyet
|
||||
if (e->button == Button1) {
|
||||
struct client_ctx *cc;
|
||||
cc = grab_menu_getcc(menuq, cur);
|
||||
if (cc != NULL) {
|
||||
client_unhide(cc);
|
||||
XRaiseWindow(X_Dpy,
|
||||
sc->menuwin);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
xu_ptr_regrab(MenuGrabMask, Cursor_select);
|
||||
XFillRectangle(X_Dpy, sc->menuwin,
|
||||
sc->hlgc, 0, cur*high, wide, high);
|
||||
} else
|
||||
xu_ptr_regrab(MenuGrabMask, Cursor_default);
|
||||
break;
|
||||
XMaskEvent(X_Dpy, MenuMask, &event);
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
XClearWindow(X_Dpy, sc->menuwin);
|
||||
i = 0;
|
||||
TAILQ_FOREACH(mi, menuq, entry) {
|
||||
tx = (wide - font_width(font, mi->text,
|
||||
strlen(mi->text)))/2;
|
||||
ty = i*high + font_ascent(font) + 1;
|
||||
fx = (width - font_width(font, mi->text,
|
||||
strlen(mi->text)))/2;
|
||||
fy = height*i + font_ascent(font) + 1;
|
||||
font_draw(font, mi->text, strlen(mi->text),
|
||||
sc->menuwin, tx, ty);
|
||||
sc->menuwin, fx, fy);
|
||||
i++;
|
||||
}
|
||||
if (cur >= 0 && cur < n)
|
||||
XFillRectangle(X_Dpy, sc->menuwin,
|
||||
sc->hlgc, 0, cur*high, wide, high);
|
||||
drawn = 1;
|
||||
/* FALLTHROUGH */
|
||||
case MotionNotify:
|
||||
prev = entry;
|
||||
entry = menu_calc_entry(event.xbutton.x,
|
||||
event.xbutton.y, width, height, no);
|
||||
if (prev != -1)
|
||||
XFillRectangle(X_Dpy, sc->menuwin, sc->hlgc,
|
||||
0, height*prev, width, height);
|
||||
if (entry != -1) {
|
||||
xu_ptr_regrab(MenuGrabMask, Cursor_select);
|
||||
XFillRectangle(X_Dpy, sc->menuwin, sc->hlgc,
|
||||
0, height*entry, width, height);
|
||||
} else
|
||||
xu_ptr_regrab(MenuGrabMask, Cursor_default);
|
||||
break;
|
||||
case ButtonRelease:
|
||||
if (event.xbutton.button != e->button)
|
||||
break;
|
||||
entry = menu_calc_entry(event.xbutton.x,
|
||||
event.xbutton.y, width, height, no);
|
||||
xu_ptr_ungrab();
|
||||
XUnmapWindow(X_Dpy, sc->menuwin);
|
||||
|
||||
i = 0;
|
||||
TAILQ_FOREACH(mi, menuq, entry)
|
||||
if (entry == i++)
|
||||
break;
|
||||
return (mi);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -401,7 +318,7 @@ grab_label(struct client_ctx *cc)
|
||||
xfree(cc->label);
|
||||
|
||||
cc->label = xstrdup(labelstr);
|
||||
|
||||
/* FALLTHROUGH */
|
||||
case CTL_ABORT:
|
||||
goto out;
|
||||
default:
|
||||
@@ -436,86 +353,7 @@ grab_label(struct client_ctx *cc)
|
||||
XUnmapWindow(X_Dpy, sc->searchwin);
|
||||
}
|
||||
|
||||
#define ExecMask (KeyPressMask|ExposureMask)
|
||||
|
||||
void
|
||||
grab_exec(void)
|
||||
{
|
||||
int x, y, dx, dy, fontheight, focusrevert, len;
|
||||
char cmdstr[MAXPATHLEN];
|
||||
char dispstr[MAXPATHLEN + sizeof("exec>") - 1];
|
||||
char chr, str[2];
|
||||
enum ctltype ctl;
|
||||
struct fontdesc *font = DefaultFont;
|
||||
struct screen_ctx *sc = screen_current();
|
||||
XEvent e;
|
||||
Window focuswin;
|
||||
|
||||
cmdstr[0] = '\0';
|
||||
|
||||
xu_ptr_getpos(sc->rootwin, &x, &y);
|
||||
|
||||
dy = fontheight = font_ascent(font) + font_descent(font) + 1;
|
||||
dx = font_width(font, "exec>", 5);
|
||||
|
||||
XMoveResizeWindow(X_Dpy, sc->searchwin, x, y, dx, dy);
|
||||
XSelectInput(X_Dpy, sc->searchwin, ExecMask);
|
||||
XMapRaised(X_Dpy, sc->searchwin);
|
||||
|
||||
XGetInputFocus(X_Dpy, &focuswin, &focusrevert);
|
||||
XSetInputFocus(X_Dpy, sc->searchwin,
|
||||
RevertToPointerRoot, CurrentTime);
|
||||
|
||||
for (;;) {
|
||||
XMaskEvent(X_Dpy, ExecMask, &e);
|
||||
|
||||
switch (e.type) {
|
||||
case KeyPress:
|
||||
if (input_keycodetrans(e.xkey.keycode, e.xkey.state,
|
||||
&ctl, &chr, 0) < 0)
|
||||
continue;
|
||||
|
||||
switch (ctl) {
|
||||
case CTL_ERASEONE:
|
||||
if ((len = strlen(cmdstr)) > 0)
|
||||
cmdstr[len - 1] = '\0';
|
||||
break;
|
||||
case CTL_RETURN:
|
||||
if (strlen(cmdstr) > 0)
|
||||
u_spawn(cmdstr);
|
||||
goto out;
|
||||
break;
|
||||
case CTL_ABORT:
|
||||
goto out;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (chr != '\0') {
|
||||
str[0] = chr;
|
||||
str[1] = '\0';
|
||||
strlcat(cmdstr, str, sizeof(cmdstr));
|
||||
}
|
||||
case Expose:
|
||||
snprintf(dispstr, sizeof(dispstr), "exec>%s", cmdstr);
|
||||
|
||||
dx = font_width(font, dispstr, strlen(dispstr));
|
||||
dy = fontheight;
|
||||
|
||||
XClearWindow(X_Dpy, sc->searchwin);
|
||||
XResizeWindow(X_Dpy, sc->searchwin, dx, dy);
|
||||
|
||||
font_draw(font, dispstr, strlen(dispstr),
|
||||
sc->searchwin, 0, font_ascent(font) + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
out:
|
||||
XSetInputFocus(X_Dpy, focuswin, focusrevert, CurrentTime);
|
||||
XUnmapWindow(X_Dpy, sc->searchwin);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
_sweepcalc(struct client_ctx *cc, int x0, int y0, int motionx, int motiony)
|
||||
{
|
||||
int width, height;
|
||||
@@ -549,12 +387,15 @@ _sweepcalc(struct client_ctx *cc, int x0, int y0, int motionx, int motiony)
|
||||
return (width != cc->geom.width || height != cc->geom.height);
|
||||
}
|
||||
|
||||
/* XXX */
|
||||
int
|
||||
_nobuttons(XButtonEvent *e) /* Einstuerzende */
|
||||
static int
|
||||
menu_calc_entry(int x, int y, int width, int height, int noentries)
|
||||
{
|
||||
int state;
|
||||
int entry = y/height;
|
||||
|
||||
state = (e->state & AllButtonMask);
|
||||
return (e->type == ButtonRelease) && (state & (state - 1)) == 0;
|
||||
/* in bounds? */
|
||||
if (x < 0 || x > width || y < 0 || y > height*noentries ||
|
||||
entry < 0 || entry >= noentries)
|
||||
entry = -1;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
46
group.c
46
group.c
@@ -3,7 +3,18 @@
|
||||
*
|
||||
* Copyright (c) 2004 Andy Adamson <dros@monkey.org>
|
||||
* Copyright (c) 2004,2005 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@@ -81,7 +92,7 @@ _group_purge(struct group_ctx *gc)
|
||||
struct client_ctx *cc;
|
||||
|
||||
if (gc == NULL)
|
||||
errx(1, "_group_commit: ctx is null");
|
||||
errx(1, "_group_purge: ctx is null");
|
||||
|
||||
TAILQ_FOREACH(cc, &gc->clients, group_entry)
|
||||
if (cc->groupcommit == 0)
|
||||
@@ -186,36 +197,15 @@ group_init(void)
|
||||
* manipulate the 'current group'
|
||||
*/
|
||||
|
||||
#if 0
|
||||
/* set current group to the first empty group
|
||||
* returns 0 on success, -1 if there are no empty groups
|
||||
*/
|
||||
int
|
||||
group_new(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i < CALMWM_NGROUPS; i++) {
|
||||
if (TAILQ_EMPTY(&Groups[i].clients)) {
|
||||
Group_current = &Groups[i];
|
||||
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* change the current group */
|
||||
int
|
||||
void
|
||||
group_select(int idx)
|
||||
{
|
||||
struct group_ctx *gc = Group_current;
|
||||
struct client_ctx *cc;
|
||||
|
||||
if (idx < 0 || idx >= CALMWM_NGROUPS)
|
||||
return (-1);
|
||||
return;
|
||||
|
||||
TAILQ_FOREACH(cc, &gc->clients, group_entry) {
|
||||
cc->highlight = 0;
|
||||
@@ -226,7 +216,7 @@ group_select(int idx)
|
||||
Group_current = &Groups[idx];
|
||||
|
||||
group_display_draw(screen_current());
|
||||
return (0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* enter group mode */
|
||||
@@ -342,7 +332,7 @@ void
|
||||
group_display_draw(struct screen_ctx *sc)
|
||||
{
|
||||
struct group_ctx *gc = Group_current;
|
||||
int x, y, dx, dy, fontheight, titlelen;
|
||||
int x, y, dx, dy, fontheight;
|
||||
struct client_ctx *cc;
|
||||
char titlebuf[1024];
|
||||
struct fontdesc *font = DefaultFont;
|
||||
@@ -352,7 +342,7 @@ group_display_draw(struct screen_ctx *sc)
|
||||
x = y = 0;
|
||||
|
||||
fontheight = font_ascent(font) + font_descent(font) + 1;
|
||||
dx = titlelen = font_width(font, titlebuf, strlen(titlebuf));
|
||||
dx = font_width(font, titlebuf, strlen(titlebuf));
|
||||
dy = fontheight;
|
||||
|
||||
TAILQ_FOREACH(cc, &gc->clients, group_entry) {
|
||||
|
13
headers.h
13
headers.h
@@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
13
input.c
13
input.c
@@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
135
kbfunc.c
135
kbfunc.c
@@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Martin Murray <mmurray@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@@ -14,7 +25,7 @@
|
||||
|
||||
#define KNOWN_HOSTS ".ssh/known_hosts"
|
||||
#define HASH_MARKER "|1|"
|
||||
#define MOVE_AMOUNT 10
|
||||
#define MOVE_AMOUNT 1
|
||||
|
||||
void
|
||||
kbfunc_client_lower(struct client_ctx *cc, void *arg)
|
||||
@@ -67,6 +78,89 @@ kbfunc_client_move(struct client_ctx *cc, void *arg)
|
||||
cc->ptr.x = x + mx;
|
||||
client_ptrwarp(cc);
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_client_resize(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
int flags,mx,my;
|
||||
u_int amt;
|
||||
|
||||
mx = my = 0;
|
||||
|
||||
flags = (int)arg;
|
||||
amt = MOVE_AMOUNT;
|
||||
|
||||
if (flags & CWM_BIGMOVE) {
|
||||
flags -= CWM_BIGMOVE;
|
||||
amt = amt*10;
|
||||
}
|
||||
|
||||
switch(flags) {
|
||||
case CWM_UP:
|
||||
my -= amt;
|
||||
break;
|
||||
case CWM_DOWN:
|
||||
my += amt;
|
||||
break;
|
||||
case CWM_RIGHT:
|
||||
mx += amt;
|
||||
break;
|
||||
case CWM_LEFT:
|
||||
mx -= amt;
|
||||
break;
|
||||
}
|
||||
|
||||
cc->geom.height += my;
|
||||
cc->geom.width += mx;
|
||||
client_resize(cc);
|
||||
|
||||
/*
|
||||
* Moving the cursor while resizing is problematic. Just place
|
||||
* it in the middle of the window.
|
||||
*/
|
||||
cc->ptr.x = -1;
|
||||
cc->ptr.y = -1;
|
||||
client_ptrwarp(cc);
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_ptrmove(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
int px,py,mx,my,flags,amt;
|
||||
struct screen_ctx *sc = screen_current();
|
||||
my = mx = 0;
|
||||
|
||||
flags = (int)arg;
|
||||
amt = MOVE_AMOUNT;
|
||||
|
||||
if (flags & CWM_BIGMOVE) {
|
||||
flags -= CWM_BIGMOVE;
|
||||
amt = amt * 10;
|
||||
}
|
||||
switch(flags) {
|
||||
case CWM_UP:
|
||||
my -= amt;
|
||||
break;
|
||||
case CWM_DOWN:
|
||||
my += amt;
|
||||
break;
|
||||
case CWM_RIGHT:
|
||||
mx += amt;
|
||||
break;
|
||||
case CWM_LEFT:
|
||||
mx -= amt;
|
||||
break;
|
||||
}
|
||||
|
||||
if (cc) {
|
||||
xu_ptr_getpos(cc->pwin, &px, &py);
|
||||
xu_ptr_setpos(cc->pwin, px + mx, py + my);
|
||||
} else {
|
||||
xu_ptr_getpos(sc->rootwin, &px, &py);
|
||||
xu_ptr_setpos(sc->rootwin, px + mx, py + my);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_client_search(struct client_ctx *scratch, void *arg)
|
||||
{
|
||||
@@ -77,7 +171,6 @@ kbfunc_client_search(struct client_ctx *scratch, void *arg)
|
||||
TAILQ_INIT(&menuq);
|
||||
|
||||
TAILQ_FOREACH(cc, &Clientq, entry) {
|
||||
struct menu *mi;
|
||||
XCALLOC(mi, struct menu);
|
||||
strlcpy(mi->text, cc->name, sizeof(mi->text));
|
||||
mi->ctx = cc;
|
||||
@@ -170,7 +263,8 @@ kbfunc_lock(struct client_ctx *cc, void *arg)
|
||||
void
|
||||
kbfunc_exec(struct client_ctx *scratch, void *arg)
|
||||
{
|
||||
char **ap, *paths[256], *path, tpath[MAXPATHLEN];
|
||||
#define NPATHS 256
|
||||
char **ap, *paths[NPATHS], *path, tpath[MAXPATHLEN];
|
||||
int l, i, j, ngroups;
|
||||
gid_t mygroups[NGROUPS_MAX];
|
||||
uid_t ruid, euid, suid;
|
||||
@@ -179,6 +273,20 @@ kbfunc_exec(struct client_ctx *scratch, void *arg)
|
||||
struct stat sb;
|
||||
struct menu_q menuq;
|
||||
struct menu *mi;
|
||||
char *label;
|
||||
|
||||
int cmd = (int)arg;
|
||||
switch(cmd) {
|
||||
case CWM_EXEC_PROGRAM:
|
||||
label = "exec";
|
||||
break;
|
||||
case CWM_EXEC_WM:
|
||||
label = "wm";
|
||||
break;
|
||||
default:
|
||||
err(1, "kbfunc_exec: invalid cmd %d", cmd);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
if (getgroups(0, mygroups) == -1)
|
||||
err(1, "getgroups failure");
|
||||
@@ -188,13 +296,13 @@ kbfunc_exec(struct client_ctx *scratch, void *arg)
|
||||
TAILQ_INIT(&menuq);
|
||||
/* just use default path until we have config to set this */
|
||||
path = xstrdup(_PATH_DEFPATH);
|
||||
for (ap = paths; ap < &paths[sizeof(paths) - 1] &&
|
||||
for (ap = paths; ap < &paths[NPATHS - 1] &&
|
||||
(*ap = strsep(&path, ":")) != NULL;) {
|
||||
if (**ap != '\0')
|
||||
ap++;
|
||||
}
|
||||
*ap = NULL;
|
||||
for (i = 0; i < sizeof(paths) && paths[i] != NULL; i++) {
|
||||
for (i = 0; i < NPATHS && paths[i] != NULL; i++) {
|
||||
if ((dirp = opendir(paths[i])) == NULL)
|
||||
continue;
|
||||
|
||||
@@ -236,8 +344,19 @@ kbfunc_exec(struct client_ctx *scratch, void *arg)
|
||||
}
|
||||
|
||||
if ((mi = search_start(&menuq,
|
||||
search_match_exec, NULL, NULL, "exec", 1)) != NULL)
|
||||
u_spawn(mi->text);
|
||||
search_match_exec, NULL, NULL, label, 1)) != NULL) {
|
||||
switch (cmd) {
|
||||
case CWM_EXEC_PROGRAM:
|
||||
u_spawn(mi->text);
|
||||
break;
|
||||
case CWM_EXEC_WM:
|
||||
exec_wm(mi->text);
|
||||
break;
|
||||
default:
|
||||
err(1, "kb_func: egad, cmd changed value!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mi != NULL && mi->dummy)
|
||||
xfree(mi);
|
||||
|
13
screen.c
13
screen.c
@@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
23
search.c
23
search.c
@@ -2,7 +2,17 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@@ -239,6 +249,11 @@ search_start(struct menu_q *menuq,
|
||||
}
|
||||
if (y + dy >= ymax) {
|
||||
y = ymax - dy;
|
||||
/* If the menu is too high, never hide the
|
||||
* top of the menu.
|
||||
*/
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
warp = 1;
|
||||
}
|
||||
|
||||
@@ -442,12 +457,6 @@ search_match_exec(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
||||
TAILQ_INSERT_TAIL(resultq, mi, resultentry);
|
||||
}
|
||||
|
||||
void
|
||||
search_rank_text(struct menu_q *resultq, char *search)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
_strsubmatch(char *sub, char *str, int zeroidx)
|
||||
{
|
||||
|
28
util.c
28
util.c
@@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@@ -39,10 +50,19 @@ u_spawn(char *argstr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int dirent_exists(char *filename) {
|
||||
struct stat buffer;
|
||||
void
|
||||
exec_wm(char *argstr)
|
||||
{
|
||||
char *args[MAXARGLEN], **ap = args;
|
||||
char **end = &args[MAXARGLEN - 1];
|
||||
|
||||
return stat(filename, &buffer);
|
||||
while (ap < end && (*ap = strsep(&argstr, " \t")) != NULL)
|
||||
ap++;
|
||||
|
||||
*ap = NULL;
|
||||
setsid();
|
||||
execvp(args[0], args);
|
||||
warn(args[0]);
|
||||
}
|
||||
|
||||
int dirent_isdir(char *filename) {
|
||||
|
17
xevents.c
17
xevents.c
@@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@@ -16,8 +27,6 @@
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
|
||||
void _sendxmsg(Window, Atom, long);
|
||||
|
||||
/*
|
||||
* NOTE: in reality, many of these should move to client.c now that
|
||||
* we've got this nice event layer.
|
||||
@@ -404,7 +413,7 @@ out:
|
||||
}
|
||||
|
||||
/*
|
||||
* This is only used for the alt supression detection.
|
||||
* This is only used for the alt suppression detection.
|
||||
*/
|
||||
void
|
||||
xev_handle_keyrelease(struct xevent *xev, XEvent *ee)
|
||||
|
13
xmalloc.c
13
xmalloc.c
@@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
34
xutil.c
34
xutil.c
@@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@@ -73,16 +84,6 @@ xu_key_grab(Window win, int mask, int keysym)
|
||||
|
||||
XGrabKey(X_Dpy, XKeysymToKeycode(X_Dpy, keysym), mask, win, True,
|
||||
GrabModeAsync, GrabModeAsync);
|
||||
#if 0
|
||||
XGrabKey(X_Dpy, XKeysymToKeycode(X_Dpy, keysym), LockMask|mask,
|
||||
win, True, GrabModeAsync, GrabModeAsync);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
xu_key_grab_keycode(Window win, int mask, int keycode)
|
||||
{
|
||||
XGrabKey(X_Dpy, keycode, mask, win, True, GrabModeAsync, GrabModeAsync);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -133,17 +134,6 @@ xu_getstate(struct client_ctx *cc, int *state)
|
||||
return (0);
|
||||
}
|
||||
|
||||
char *
|
||||
xu_getstrprop(struct client_ctx *cc, Atom atm)
|
||||
{
|
||||
u_char *cp;
|
||||
|
||||
if (xu_getprop(cc, atm, XA_STRING, 100L, &cp) <= 0)
|
||||
return (NULL);
|
||||
|
||||
return ((char *)cp);
|
||||
}
|
||||
|
||||
void
|
||||
xu_setstate(struct client_ctx *cc, int state)
|
||||
{
|
||||
|
Reference in New Issue
Block a user