diff options
author | okan <okan> | 2013-07-10 14:15:58 +0000 |
---|---|---|
committer | okan <okan> | 2013-07-10 14:15:58 +0000 |
commit | 93bfc4a5c14db580a426571b8be6011998189ad2 (patch) | |
tree | a14fb69b67091ef2e2b753dc53f60854b0b58e74 | |
parent | ba9baaf671a4054524f62a5b90b21f603c369a5b (diff) | |
parent | bd7b8163bb0be2bd4904a179771a8f79163e8161 (diff) | |
download | cwm-93bfc4a5c14db580a426571b8be6011998189ad2.tar.gz cwm-93bfc4a5c14db580a426571b8be6011998189ad2.tar.xz cwm-93bfc4a5c14db580a426571b8be6011998189ad2.zip |
cvsimport
-rw-r--r-- | calmwm.c | 4 | ||||
-rw-r--r-- | calmwm.h | 29 | ||||
-rw-r--r-- | conf.c | 165 | ||||
-rw-r--r-- | cwmrc.5 | 6 | ||||
-rw-r--r-- | group.c | 9 | ||||
-rw-r--r-- | kbfunc.c | 2 | ||||
-rw-r--r-- | mousefunc.c | 26 | ||||
-rw-r--r-- | parse.y | 4 | ||||
-rw-r--r-- | xevents.c | 17 | ||||
-rw-r--r-- | xutil.c | 8 |
10 files changed, 143 insertions, 127 deletions
diff --git a/calmwm.c b/calmwm.c index 929fb12..c15766f 100644 --- a/calmwm.c +++ b/calmwm.c @@ -102,7 +102,6 @@ main(int argc, char **argv) conf_path = NULL; } - conf_init(&Conf); if (conf_path && (parse_config(conf_path, &Conf) == -1)) warnx("config file %s has errors, not loading", conf_path); @@ -121,8 +120,7 @@ x_init(const char *dpyname) int i; if ((X_Dpy = XOpenDisplay(dpyname)) == NULL) - errx(1, "unable to open display \"%s\"", - XDisplayName(dpyname)); + errx(1, "unable to open display \"%s\"", XDisplayName(dpyname)); XSetErrorHandler(x_wmerrorhandler); XSelectInput(X_Dpy, DefaultRootWindow(X_Dpy), SubstructureRedirectMask); diff --git a/calmwm.h b/calmwm.h index 3e40b88..0e6ee91 100644 --- a/calmwm.h +++ b/calmwm.h @@ -270,7 +270,7 @@ struct mousebinding { u_int button; #define MOUSEBIND_CTX_ROOT 0x0001 #define MOUSEBIND_CTX_WIN 0x0002 - int context; + int flags; }; TAILQ_HEAD(mousebinding_q, mousebinding); @@ -372,7 +372,7 @@ void group_autogroup(struct client_ctx *); void group_cycle(struct screen_ctx *, int); void group_hidetoggle(struct screen_ctx *, int); void group_init(struct screen_ctx *); -void group_menu(XButtonEvent *); +void group_menu(struct screen_ctx *); void group_movetogroup(struct client_ctx *, int); void group_only(struct screen_ctx *, int); void group_sticky(struct client_ctx *); @@ -415,6 +415,8 @@ void kbfunc_client_label(struct client_ctx *, union arg *); void kbfunc_client_lower(struct client_ctx *, union arg *); void kbfunc_client_maximize(struct client_ctx *, union arg *); +void kbfunc_client_moveresize(struct client_ctx *, + union arg *); void kbfunc_client_movetogroup(struct client_ctx *, union arg *); void kbfunc_client_nogroup(struct client_ctx *, @@ -428,23 +430,26 @@ void kbfunc_cmdexec(struct client_ctx *, union arg *); void kbfunc_exec(struct client_ctx *, union arg *); void kbfunc_lock(struct client_ctx *, union arg *); void kbfunc_menu_search(struct client_ctx *, union arg *); -void kbfunc_moveresize(struct client_ctx *, union arg *); void kbfunc_quit_wm(struct client_ctx *, union arg *); void kbfunc_restart(struct client_ctx *, union arg *); void kbfunc_ssh(struct client_ctx *, union arg *); void kbfunc_term(struct client_ctx *, union arg *); void kbfunc_tile(struct client_ctx *, union arg *); +void mousefunc_client_cyclegroup(struct client_ctx *, + void *); +void mousefunc_client_grouptoggle(struct client_ctx *, + void *); +void mousefunc_client_hide(struct client_ctx *, void *); +void mousefunc_client_lower(struct client_ctx *, void *); +void mousefunc_client_move(struct client_ctx *, void *); +void mousefunc_client_raise(struct client_ctx *, void *); +void mousefunc_client_rcyclegroup(struct client_ctx *, + void *); +void mousefunc_client_resize(struct client_ctx *, void *); void mousefunc_menu_cmd(struct client_ctx *, void *); void mousefunc_menu_group(struct client_ctx *, void *); void mousefunc_menu_unhide(struct client_ctx *, void *); -void mousefunc_window_grouptoggle(struct client_ctx *, - void *); -void mousefunc_window_hide(struct client_ctx *, void *); -void mousefunc_window_lower(struct client_ctx *, void *); -void mousefunc_window_move(struct client_ctx *, void *); -void mousefunc_window_raise(struct client_ctx *, void *); -void mousefunc_window_resize(struct client_ctx *, void *); struct menu *menu_filter(struct screen_ctx *, struct menu_q *, char *, char *, int, @@ -455,7 +460,8 @@ void menuq_clear(struct menu_q *); int parse_config(const char *, struct conf *); void conf_autogroup(struct conf *, int, char *); -void conf_bindname(struct conf *, char *, char *); +void conf_bind_kbd(struct conf *, char *, char *); +int conf_bind_mouse(struct conf *, char *, char *); void conf_clear(struct conf *); void conf_client(struct client_ctx *); void conf_cmd_add(struct conf *, char *, char *); @@ -464,7 +470,6 @@ void conf_grab_kbd(Window); void conf_grab_mouse(Window); void conf_init(struct conf *); void conf_ignore(struct conf *, char *); -int conf_mousebind(struct conf *, char *, char *); void conf_screen(struct screen_ctx *); void xev_loop(void); diff --git a/conf.c b/conf.c index a3eff6d..8331ad2 100644 --- a/conf.c +++ b/conf.c @@ -31,8 +31,9 @@ #include "calmwm.h" -static void conf_mouseunbind(struct conf *, struct mousebinding *); -static void conf_unbind(struct conf *, struct keybinding *); +static const char *conf_bind_getmask(const char *, u_int *); +static void conf_unbind_kbd(struct conf *, struct keybinding *); +static void conf_unbind_mouse(struct conf *, struct mousebinding *); /* Add an command menu entry to the end of the menu */ void @@ -98,8 +99,8 @@ static char *color_binds[] = { void conf_screen(struct screen_ctx *sc) { - int i; - XftColor xc; + u_int i; + XftColor xc; sc->gap = Conf.gap; @@ -144,7 +145,7 @@ conf_screen(struct screen_ctx *sc) static struct { char *key; char *func; -} kb_binds[] = { +} kbd_binds[] = { { "CM-Return", "terminal" }, { "CM-Delete", "lock" }, { "M-question", "exec" }, @@ -203,7 +204,7 @@ static struct { { "CS-Up", "bigptrmoveup" }, { "CS-Right", "bigptrmoveright" }, }, -m_binds[] = { +mouse_binds[] = { { "1", "menu_unhide" }, { "2", "menu_group" }, { "3", "menu_cmd" }, @@ -231,11 +232,11 @@ conf_init(struct conf *c) TAILQ_INIT(&c->autogroupq); TAILQ_INIT(&c->mousebindingq); - for (i = 0; i < nitems(kb_binds); i++) - conf_bindname(c, kb_binds[i].key, kb_binds[i].func); + for (i = 0; i < nitems(kbd_binds); i++) + conf_bind_kbd(c, kbd_binds[i].key, kbd_binds[i].func); - for (i = 0; i < nitems(m_binds); i++) - conf_mousebind(c, m_binds[i].key, m_binds[i].func); + for (i = 0; i < nitems(mouse_binds); i++) + conf_bind_mouse(c, mouse_binds[i].key, mouse_binds[i].func); for (i = 0; i < nitems(color_binds); i++) c->color[i] = xstrdup(color_binds[i]); @@ -381,50 +382,53 @@ static struct { { "ssh", kbfunc_ssh, 0, {0} }, { "terminal", kbfunc_term, 0, {0} }, { "lock", kbfunc_lock, 0, {0} }, - { "moveup", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "moveup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_UP|CWM_MOVE)} }, - { "movedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "movedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_DOWN|CWM_MOVE)} }, - { "moveright", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "moveright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_RIGHT|CWM_MOVE)} }, - { "moveleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "moveleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_LEFT|CWM_MOVE)} }, - { "bigmoveup", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "bigmoveup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_UP|CWM_MOVE|CWM_BIGMOVE)} }, - { "bigmovedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "bigmovedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_DOWN|CWM_MOVE|CWM_BIGMOVE)} }, - { "bigmoveright", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "bigmoveright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_RIGHT|CWM_MOVE|CWM_BIGMOVE)} }, - { "bigmoveleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "bigmoveleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_LEFT|CWM_MOVE|CWM_BIGMOVE)} }, - { "resizeup", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "resizeup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_UP|CWM_RESIZE)} }, - { "resizedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "resizedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_DOWN|CWM_RESIZE)} }, - { "resizeright", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "resizeright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_RIGHT|CWM_RESIZE)} }, - { "resizeleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "resizeleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_LEFT|CWM_RESIZE)} }, - { "bigresizeup", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "bigresizeup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_UP|CWM_RESIZE|CWM_BIGMOVE)} }, - { "bigresizedown", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "bigresizedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_DOWN|CWM_RESIZE|CWM_BIGMOVE)} }, - { "bigresizeright", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "bigresizeright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_RIGHT|CWM_RESIZE|CWM_BIGMOVE)} }, - { "bigresizeleft", kbfunc_moveresize, KBFLAG_NEEDCLIENT, + { "bigresizeleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, {.i = (CWM_LEFT|CWM_RESIZE|CWM_BIGMOVE)} }, - { "ptrmoveup", kbfunc_moveresize, 0, {.i = (CWM_UP|CWM_PTRMOVE)} }, - { "ptrmovedown", kbfunc_moveresize, 0, {.i = (CWM_DOWN|CWM_PTRMOVE)} }, - { "ptrmoveleft", kbfunc_moveresize, 0, {.i = (CWM_LEFT|CWM_PTRMOVE)} }, - { "ptrmoveright", kbfunc_moveresize, 0, + { "ptrmoveup", kbfunc_client_moveresize, 0, + {.i = (CWM_UP|CWM_PTRMOVE)} }, + { "ptrmovedown", kbfunc_client_moveresize, 0, + {.i = (CWM_DOWN|CWM_PTRMOVE)} }, + { "ptrmoveleft", kbfunc_client_moveresize, 0, + {.i = (CWM_LEFT|CWM_PTRMOVE)} }, + { "ptrmoveright", kbfunc_client_moveresize, 0, {.i = (CWM_RIGHT|CWM_PTRMOVE)} }, - { "bigptrmoveup", kbfunc_moveresize, 0, + { "bigptrmoveup", kbfunc_client_moveresize, 0, {.i = (CWM_UP|CWM_PTRMOVE|CWM_BIGMOVE)} }, - { "bigptrmovedown", kbfunc_moveresize, 0, + { "bigptrmovedown", kbfunc_client_moveresize, 0, {.i = (CWM_DOWN|CWM_PTRMOVE|CWM_BIGMOVE)} }, - { "bigptrmoveleft", kbfunc_moveresize, 0, + { "bigptrmoveleft", kbfunc_client_moveresize, 0, {.i = (CWM_LEFT|CWM_PTRMOVE|CWM_BIGMOVE)} }, - { "bigptrmoveright", kbfunc_moveresize, 0, + { "bigptrmoveright", kbfunc_client_moveresize, 0, {.i = (CWM_RIGHT|CWM_PTRMOVE|CWM_BIGMOVE)} }, { "htile", kbfunc_tile, KBFLAG_NEEDCLIENT, {.i = CWM_TILE_HORIZ } }, @@ -433,7 +437,7 @@ static struct { }; static struct { - char chr; + char ch; int mask; } bind_mods[] = { { 'C', ControlMask }, @@ -442,27 +446,35 @@ static struct { { 'S', ShiftMask }, }; +static const char * +conf_bind_getmask(const char *name, u_int *mask) +{ + char *dash; + const char *ch; + u_int i; + + *mask = 0; + if ((dash = strchr(name, '-')) == NULL) + return (name); + for (i = 0; i < nitems(bind_mods); i++) { + if ((ch = strchr(name, bind_mods[i].ch)) != NULL && ch < dash) + *mask |= bind_mods[i].mask; + } + + /* Skip past modifiers. */ + return (dash + 1); +} + void -conf_bindname(struct conf *c, char *name, char *binding) +conf_bind_kbd(struct conf *c, char *name, char *binding) { struct keybinding *current_binding; - char *substring, *tmp; - u_int i; + const char *substring; + u_int i, mask; current_binding = xcalloc(1, sizeof(*current_binding)); - - if ((substring = strchr(name, '-')) != NULL) { - for (i = 0; i < nitems(bind_mods); i++) { - if ((tmp = strchr(name, bind_mods[i].chr)) != - NULL && tmp < substring) { - current_binding->modmask |= bind_mods[i].mask; - } - } - - /* skip past the modifiers */ - substring++; - } else - substring = name; + substring = conf_bind_getmask(name, &mask); + current_binding->modmask |= mask; if (substring[0] == '[' && substring[strlen(substring)-1] == ']') { @@ -480,7 +492,7 @@ conf_bindname(struct conf *c, char *name, char *binding) } /* We now have the correct binding, remove duplicates. */ - conf_unbind(c, current_binding); + conf_unbind_kbd(c, current_binding); if (strcmp("unmap", binding) == 0) { free(current_binding); @@ -507,7 +519,7 @@ conf_bindname(struct conf *c, char *name, char *binding) } static void -conf_unbind(struct conf *c, struct keybinding *unbind) +conf_unbind_kbd(struct conf *c, struct keybinding *unbind) { struct keybinding *key = NULL, *keynxt; @@ -529,15 +541,17 @@ conf_unbind(struct conf *c, struct keybinding *unbind) static struct { char *tag; void (*handler)(struct client_ctx *, void *); - int context; + int flags; } name_to_mousefunc[] = { - { "window_move", mousefunc_window_move, MOUSEBIND_CTX_WIN }, - { "window_resize", mousefunc_window_resize, MOUSEBIND_CTX_WIN }, - { "window_grouptoggle", mousefunc_window_grouptoggle, + { "window_move", mousefunc_client_move, MOUSEBIND_CTX_WIN }, + { "window_resize", mousefunc_client_resize, MOUSEBIND_CTX_WIN }, + { "window_grouptoggle", mousefunc_client_grouptoggle, MOUSEBIND_CTX_WIN }, - { "window_lower", mousefunc_window_lower, MOUSEBIND_CTX_WIN }, - { "window_raise", mousefunc_window_raise, MOUSEBIND_CTX_WIN }, - { "window_hide", mousefunc_window_hide, MOUSEBIND_CTX_WIN }, + { "window_lower", mousefunc_client_lower, MOUSEBIND_CTX_WIN }, + { "window_raise", mousefunc_client_raise, MOUSEBIND_CTX_WIN }, + { "window_hide", mousefunc_client_hide, MOUSEBIND_CTX_WIN }, + { "cyclegroup", mousefunc_client_cyclegroup, MOUSEBIND_CTX_ROOT }, + { "rcyclegroup", mousefunc_client_rcyclegroup, MOUSEBIND_CTX_ROOT }, { "menu_group", mousefunc_menu_group, MOUSEBIND_CTX_ROOT }, { "menu_unhide", mousefunc_menu_unhide, MOUSEBIND_CTX_ROOT }, { "menu_cmd", mousefunc_menu_cmd, MOUSEBIND_CTX_ROOT }, @@ -548,28 +562,15 @@ static unsigned int mouse_btns[] = { }; int -conf_mousebind(struct conf *c, char *name, char *binding) +conf_bind_mouse(struct conf *c, char *name, char *binding) { struct mousebinding *current_binding; - char *substring, *tmp; - u_int button; - const char *errstr; - u_int i; + const char *errstr, *substring; + u_int button, i, mask; current_binding = xcalloc(1, sizeof(*current_binding)); - - if ((substring = strchr(name, '-')) != NULL) { - for (i = 0; i < nitems(bind_mods); i++) { - if ((tmp = strchr(name, bind_mods[i].chr)) != - NULL && tmp < substring) { - current_binding->modmask |= bind_mods[i].mask; - } - } - - /* skip past the modifiers */ - substring++; - } else - substring = name; + substring = conf_bind_getmask(name, &mask); + current_binding->modmask |= mask; button = strtonum(substring, 1, 5, &errstr); if (errstr) @@ -587,7 +588,7 @@ conf_mousebind(struct conf *c, char *name, char *binding) } /* We now have the correct binding, remove duplicates. */ - conf_mouseunbind(c, current_binding); + conf_unbind_mouse(c, current_binding); if (strcmp("unmap", binding) == 0) { free(current_binding); @@ -598,8 +599,8 @@ conf_mousebind(struct conf *c, char *name, char *binding) if (strcmp(name_to_mousefunc[i].tag, binding) != 0) continue; - current_binding->context = name_to_mousefunc[i].context; current_binding->callback = name_to_mousefunc[i].handler; + current_binding->flags = name_to_mousefunc[i].flags; TAILQ_INSERT_TAIL(&c->mousebindingq, current_binding, entry); return (1); } @@ -608,7 +609,7 @@ conf_mousebind(struct conf *c, char *name, char *binding) } static void -conf_mouseunbind(struct conf *c, struct mousebinding *unbind) +conf_unbind_mouse(struct conf *c, struct mousebinding *unbind) { struct mousebinding *mb = NULL, *mbnxt; @@ -646,7 +647,7 @@ conf_grab_mouse(Window win) struct mousebinding *mb; TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) { - if (mb->context != MOUSEBIND_CTX_WIN) + if (mb->flags != MOUSEBIND_CTX_WIN) continue; xu_btn_grab(win, mb->modmask, mb->button); } diff --git a/cwmrc.5 b/cwmrc.5 index 68803ad..9f75dbd 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 8 2013 $ +.Dd $Mdocdate: June 17 2013 $ .Dt CWMRC 5 .Os .Sh NAME @@ -463,6 +463,10 @@ Raise current window. Hide current window. .It window_grouptoggle Toggle group membership of current window. +.It cyclegroup +Forward cycle through groups. +.It rcyclegroup +Reverse cycle through groups. .It menu_group Launch group list. .It menu_unhide diff --git a/group.c b/group.c index 30bc5d5..4264813 100644 --- a/group.c +++ b/group.c @@ -309,16 +309,13 @@ group_cycle(struct screen_ctx *sc, int flags) } void -group_menu(XButtonEvent *e) +group_menu(struct screen_ctx *sc) { - struct screen_ctx *sc; struct group_ctx *gc; struct menu *mi; struct menu_q menuq; int i; - sc = screen_fromroot(e->root); - TAILQ_INIT(&menuq); for (i = 0; i < CALMWM_NGROUPS; i++) { @@ -430,8 +427,8 @@ group_update_names(struct screen_ctx *sc) } } - strings = xmalloc((nstrings < CALMWM_NGROUPS ? CALMWM_NGROUPS : - nstrings) * sizeof(*strings)); + strings = xcalloc((nstrings < CALMWM_NGROUPS ? CALMWM_NGROUPS : + nstrings), sizeof(*strings)); p = (char *)prop_ret; while (n < nstrings) { diff --git a/kbfunc.c b/kbfunc.c index 37b8af7..2059b0a 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -53,7 +53,7 @@ kbfunc_client_raise(struct client_ctx *cc, union arg *arg) #define TYPEMASK (CWM_MOVE | CWM_RESIZE | CWM_PTRMOVE) #define MOVEMASK (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT) void -kbfunc_moveresize(struct client_ctx *cc, union arg *arg) +kbfunc_client_moveresize(struct client_ctx *cc, union arg *arg) { struct screen_ctx *sc = cc->sc; int x, y, flags, amt; diff --git a/mousefunc.c b/mousefunc.c index 158a791..8053fe7 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -68,7 +68,7 @@ mousefunc_sweep_draw(struct client_ctx *cc) } void -mousefunc_window_resize(struct client_ctx *cc, void *arg) +mousefunc_client_resize(struct client_ctx *cc, void *arg) { XEvent ev; Time ltime = 0; @@ -125,7 +125,7 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg) } void -mousefunc_window_move(struct client_ctx *cc, void *arg) +mousefunc_client_move(struct client_ctx *cc, void *arg) { XEvent ev; Time ltime = 0; @@ -177,34 +177,46 @@ mousefunc_window_move(struct client_ctx *cc, void *arg) } void -mousefunc_window_grouptoggle(struct client_ctx *cc, void *arg) +mousefunc_client_grouptoggle(struct client_ctx *cc, void *arg) { group_sticky_toggle_enter(cc); } void -mousefunc_window_lower(struct client_ctx *cc, void *arg) +mousefunc_client_lower(struct client_ctx *cc, void *arg) { client_ptrsave(cc); client_lower(cc); } void -mousefunc_window_raise(struct client_ctx *cc, void *arg) +mousefunc_client_raise(struct client_ctx *cc, void *arg) { client_raise(cc); } void -mousefunc_window_hide(struct client_ctx *cc, void *arg) +mousefunc_client_hide(struct client_ctx *cc, void *arg) { client_hide(cc); } void +mousefunc_client_cyclegroup(struct client_ctx *cc, void *arg) +{ + group_cycle(cc->sc, CWM_CYCLE); +} + +void +mousefunc_client_rcyclegroup(struct client_ctx *cc, void *arg) +{ + group_cycle(cc->sc, CWM_RCYCLE); +} + +void mousefunc_menu_group(struct client_ctx *cc, void *arg) { - group_menu(arg); + group_menu(cc->sc); } void diff --git a/parse.y b/parse.y index 5b88c42..b4d61f1 100644 --- a/parse.y +++ b/parse.y @@ -157,7 +157,7 @@ main : FONTNAME STRING { free($2); } | BIND STRING string { - conf_bindname(conf, $2, $3); + conf_bind_kbd(conf, $2, $3); free($2); free($3); } @@ -173,7 +173,7 @@ main : FONTNAME STRING { conf->gap.right = $5; } | MOUSEBIND STRING string { - if (!conf_mousebind(conf, $2, $3)) { + if (!conf_bind_mouse(conf, $2, $3)) { yyerror("invalid mousebind: %s %s", $2, $3); free($2); free($3); diff --git a/xevents.c b/xevents.c index 8ad036b..8e17241 100644 --- a/xevents.c +++ b/xevents.c @@ -238,12 +238,8 @@ xev_handle_buttonpress(XEvent *ee) { XButtonEvent *e = &ee->xbutton; struct client_ctx *cc, fakecc; - struct screen_ctx *sc; struct mousebinding *mb; - sc = screen_fromroot(e->root); - cc = client_find(e->window); - e->state &= ~IGNOREMODMASK; TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) { @@ -253,13 +249,16 @@ xev_handle_buttonpress(XEvent *ee) if (mb == NULL) return; - if (mb->context == MOUSEBIND_CTX_ROOT) { - if (e->window != sc->rootwin) + if (mb->flags == MOUSEBIND_CTX_WIN) { + if (((cc = client_find(e->window)) == NULL) && + (cc = client_current()) == NULL) + return; + } else { /* (mb->flags == MOUSEBIND_CTX_ROOT) */ + if (e->window != e->root) return; cc = &fakecc; cc->sc = screen_fromroot(e->window); - } else if (cc == NULL) /* (mb->context == MOUSEBIND_CTX_WIN */ - return; + } (*mb->callback)(cc, e); } @@ -357,7 +356,7 @@ xev_handle_clientmessage(XEvent *ee) client_send_delete(cc); if (e->message_type == ewmh[_NET_ACTIVE_WINDOW].atom && - e->format == 32) { + e->format == 32) { old_cc = client_current(); if (old_cc) client_ptrsave(old_cc); diff --git a/xutil.c b/xutil.c index 7145683..c1e4611 100644 --- a/xutil.c +++ b/xutil.c @@ -291,7 +291,7 @@ xu_ewmh_net_client_list(struct screen_ctx *sc) if (i == 0) return; - winlist = xmalloc(i * sizeof(*winlist)); + winlist = xcalloc(i, sizeof(*winlist)); TAILQ_FOREACH(cc, &Clientq, entry) winlist[j++] = cc->win; XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_CLIENT_LIST].atom, @@ -382,7 +382,7 @@ xu_ewmh_get_net_wm_state(struct client_ctx *cc, int *n) (u_char **)&p)) <= 0) return (NULL); - state = xmalloc(*n * sizeof(Atom)); + state = xcalloc(*n, sizeof(Atom)); memcpy(state, p, *n * sizeof(Atom)); XFree((char *)p); @@ -393,7 +393,7 @@ void xu_ewmh_handle_net_wm_state_msg(struct client_ctx *cc, int action, Atom first, Atom second) { - int i; + u_int i; static struct handlers { int atom; int property; @@ -449,7 +449,7 @@ xu_ewmh_set_net_wm_state(struct client_ctx *cc) int n, i, j; oatoms = xu_ewmh_get_net_wm_state(cc, &n); - atoms = xmalloc((n + _NET_WM_STATES_NITEMS) * sizeof(Atom)); + atoms = xcalloc((n + _NET_WM_STATES_NITEMS), sizeof(Atom)); for (i = j = 0; i < n; i++) { if (oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_HORZ].atom && oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_VERT].atom) |