merge KBFLAG_NEEDCLIENT and MOUSEBIND_CTX_*; brings kbfunc and mousefunc

bits even closer.
This commit is contained in:
okan 2014-01-20 23:03:51 +00:00
parent 34f43e3f2d
commit c7adadaf9d
3 changed files with 58 additions and 74 deletions

View File

@ -83,6 +83,8 @@
#define CWM_GAP 0x0001 #define CWM_GAP 0x0001
#define CWM_NOGAP 0x0002 #define CWM_NOGAP 0x0002
#define CWM_WIN 0x0001
union arg { union arg {
char *c; char *c;
int i; int i;
@ -247,7 +249,6 @@ struct keybinding {
union arg argument; union arg argument;
unsigned int modmask; unsigned int modmask;
KeySym keysym; KeySym keysym;
#define KBFLAG_NEEDCLIENT 0x0001
int flags; int flags;
int argtype; int argtype;
}; };
@ -259,8 +260,6 @@ struct mousebinding {
union arg argument; union arg argument;
unsigned int modmask; unsigned int modmask;
unsigned int button; unsigned int button;
#define MOUSEBIND_CTX_ROOT 0x0001
#define MOUSEBIND_CTX_WIN 0x0002
int flags; int flags;
}; };
TAILQ_HEAD(mousebinding_q, mousebinding); TAILQ_HEAD(mousebinding_q, mousebinding);

121
conf.c
View File

@ -324,15 +324,15 @@ static struct {
int flags; int flags;
union arg argument; union arg argument;
} name_to_kbfunc[] = { } name_to_kbfunc[] = {
{ "lower", kbfunc_client_lower, KBFLAG_NEEDCLIENT, {0} }, { "lower", kbfunc_client_lower, CWM_WIN, {0} },
{ "raise", kbfunc_client_raise, KBFLAG_NEEDCLIENT, {0} }, { "raise", kbfunc_client_raise, CWM_WIN, {0} },
{ "search", kbfunc_client_search, 0, {0} }, { "search", kbfunc_client_search, 0, {0} },
{ "menusearch", kbfunc_menu_search, 0, {0} }, { "menusearch", kbfunc_menu_search, 0, {0} },
{ "hide", kbfunc_client_hide, KBFLAG_NEEDCLIENT, {0} }, { "hide", kbfunc_client_hide, CWM_WIN, {0} },
{ "cycle", kbfunc_client_cycle, 0, {.i = CWM_CYCLE} }, { "cycle", kbfunc_client_cycle, 0, {.i = CWM_CYCLE} },
{ "rcycle", kbfunc_client_cycle, 0, {.i = CWM_RCYCLE} }, { "rcycle", kbfunc_client_cycle, 0, {.i = CWM_RCYCLE} },
{ "label", kbfunc_client_label, KBFLAG_NEEDCLIENT, {0} }, { "label", kbfunc_client_label, CWM_WIN, {0} },
{ "delete", kbfunc_client_delete, KBFLAG_NEEDCLIENT, {0} }, { "delete", kbfunc_client_delete, CWM_WIN, {0} },
{ "group1", kbfunc_client_group, 0, {.i = 1} }, { "group1", kbfunc_client_group, 0, {.i = 1} },
{ "group2", kbfunc_client_group, 0, {.i = 2} }, { "group2", kbfunc_client_group, 0, {.i = 2} },
{ "group3", kbfunc_client_group, 0, {.i = 3} }, { "group3", kbfunc_client_group, 0, {.i = 3} },
@ -351,37 +351,28 @@ static struct {
{ "grouponly7", kbfunc_client_grouponly, 0, {.i = 7} }, { "grouponly7", kbfunc_client_grouponly, 0, {.i = 7} },
{ "grouponly8", kbfunc_client_grouponly, 0, {.i = 8} }, { "grouponly8", kbfunc_client_grouponly, 0, {.i = 8} },
{ "grouponly9", kbfunc_client_grouponly, 0, {.i = 9} }, { "grouponly9", kbfunc_client_grouponly, 0, {.i = 9} },
{ "movetogroup1", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT, { "movetogroup1", kbfunc_client_movetogroup, CWM_WIN, {.i = 1} },
{.i = 1} }, { "movetogroup2", kbfunc_client_movetogroup, CWM_WIN, {.i = 2} },
{ "movetogroup2", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT, { "movetogroup3", kbfunc_client_movetogroup, CWM_WIN, {.i = 3} },
{.i = 2} }, { "movetogroup4", kbfunc_client_movetogroup, CWM_WIN, {.i = 4} },
{ "movetogroup3", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT, { "movetogroup5", kbfunc_client_movetogroup, CWM_WIN, {.i = 5} },
{.i = 3} }, { "movetogroup6", kbfunc_client_movetogroup, CWM_WIN, {.i = 6} },
{ "movetogroup4", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT, { "movetogroup7", kbfunc_client_movetogroup, CWM_WIN, {.i = 7} },
{.i = 4} }, { "movetogroup8", kbfunc_client_movetogroup, CWM_WIN, {.i = 8} },
{ "movetogroup5", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT, { "movetogroup9", kbfunc_client_movetogroup, CWM_WIN, {.i = 9} },
{.i = 5} },
{ "movetogroup6", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
{.i = 6} },
{ "movetogroup7", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
{.i = 7} },
{ "movetogroup8", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
{.i = 8} },
{ "movetogroup9", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
{.i = 9} },
{ "nogroup", kbfunc_client_nogroup, 0, {0} }, { "nogroup", kbfunc_client_nogroup, 0, {0} },
{ "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} }, { "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} },
{ "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} }, { "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} },
{ "cycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, { "cycleingroup", kbfunc_client_cycle, CWM_WIN,
{.i = CWM_CYCLE|CWM_INGROUP} }, {.i = CWM_CYCLE|CWM_INGROUP} },
{ "rcycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, { "rcycleingroup", kbfunc_client_cycle, CWM_WIN,
{.i = CWM_RCYCLE|CWM_INGROUP} }, {.i = CWM_RCYCLE|CWM_INGROUP} },
{ "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, {0}}, { "grouptoggle", kbfunc_client_grouptoggle, CWM_WIN, {0}},
{ "fullscreen", kbfunc_client_fullscreen, KBFLAG_NEEDCLIENT, {0} }, { "fullscreen", kbfunc_client_fullscreen, CWM_WIN, {0} },
{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} }, { "maximize", kbfunc_client_maximize, CWM_WIN, {0} },
{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} }, { "vmaximize", kbfunc_client_vmaximize, CWM_WIN, {0} },
{ "hmaximize", kbfunc_client_hmaximize, KBFLAG_NEEDCLIENT, {0} }, { "hmaximize", kbfunc_client_hmaximize, CWM_WIN, {0} },
{ "freeze", kbfunc_client_freeze, KBFLAG_NEEDCLIENT, {0} }, { "freeze", kbfunc_client_freeze, CWM_WIN, {0} },
{ "restart", kbfunc_restart, 0, {0} }, { "restart", kbfunc_restart, 0, {0} },
{ "quit", kbfunc_quit_wm, 0, {0} }, { "quit", kbfunc_quit_wm, 0, {0} },
{ "exec", kbfunc_exec, 0, {.i = CWM_EXEC_PROGRAM} }, { "exec", kbfunc_exec, 0, {.i = CWM_EXEC_PROGRAM} },
@ -389,37 +380,37 @@ static struct {
{ "ssh", kbfunc_ssh, 0, {0} }, { "ssh", kbfunc_ssh, 0, {0} },
{ "terminal", kbfunc_term, 0, {0} }, { "terminal", kbfunc_term, 0, {0} },
{ "lock", kbfunc_lock, 0, {0} }, { "lock", kbfunc_lock, 0, {0} },
{ "moveup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "moveup", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_UP|CWM_MOVE)} }, {.i = (CWM_UP|CWM_MOVE)} },
{ "movedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "movedown", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_DOWN|CWM_MOVE)} }, {.i = (CWM_DOWN|CWM_MOVE)} },
{ "moveright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "moveright", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_RIGHT|CWM_MOVE)} }, {.i = (CWM_RIGHT|CWM_MOVE)} },
{ "moveleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "moveleft", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_LEFT|CWM_MOVE)} }, {.i = (CWM_LEFT|CWM_MOVE)} },
{ "bigmoveup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "bigmoveup", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_UP|CWM_MOVE|CWM_BIGMOVE)} }, {.i = (CWM_UP|CWM_MOVE|CWM_BIGMOVE)} },
{ "bigmovedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "bigmovedown", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_DOWN|CWM_MOVE|CWM_BIGMOVE)} }, {.i = (CWM_DOWN|CWM_MOVE|CWM_BIGMOVE)} },
{ "bigmoveright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "bigmoveright", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_RIGHT|CWM_MOVE|CWM_BIGMOVE)} }, {.i = (CWM_RIGHT|CWM_MOVE|CWM_BIGMOVE)} },
{ "bigmoveleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "bigmoveleft", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_LEFT|CWM_MOVE|CWM_BIGMOVE)} }, {.i = (CWM_LEFT|CWM_MOVE|CWM_BIGMOVE)} },
{ "resizeup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "resizeup", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_UP|CWM_RESIZE)} }, {.i = (CWM_UP|CWM_RESIZE)} },
{ "resizedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "resizedown", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_DOWN|CWM_RESIZE)} }, {.i = (CWM_DOWN|CWM_RESIZE)} },
{ "resizeright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "resizeright", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_RIGHT|CWM_RESIZE)} }, {.i = (CWM_RIGHT|CWM_RESIZE)} },
{ "resizeleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "resizeleft", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_LEFT|CWM_RESIZE)} }, {.i = (CWM_LEFT|CWM_RESIZE)} },
{ "bigresizeup", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "bigresizeup", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_UP|CWM_RESIZE|CWM_BIGMOVE)} }, {.i = (CWM_UP|CWM_RESIZE|CWM_BIGMOVE)} },
{ "bigresizedown", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "bigresizedown", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_DOWN|CWM_RESIZE|CWM_BIGMOVE)} }, {.i = (CWM_DOWN|CWM_RESIZE|CWM_BIGMOVE)} },
{ "bigresizeright", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "bigresizeright", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_RIGHT|CWM_RESIZE|CWM_BIGMOVE)} }, {.i = (CWM_RIGHT|CWM_RESIZE|CWM_BIGMOVE)} },
{ "bigresizeleft", kbfunc_client_moveresize, KBFLAG_NEEDCLIENT, { "bigresizeleft", kbfunc_client_moveresize, CWM_WIN,
{.i = (CWM_LEFT|CWM_RESIZE|CWM_BIGMOVE)} }, {.i = (CWM_LEFT|CWM_RESIZE|CWM_BIGMOVE)} },
{ "ptrmoveup", kbfunc_client_moveresize, 0, { "ptrmoveup", kbfunc_client_moveresize, 0,
{.i = (CWM_UP|CWM_PTRMOVE)} }, {.i = (CWM_UP|CWM_PTRMOVE)} },
@ -437,10 +428,8 @@ static struct {
{.i = (CWM_LEFT|CWM_PTRMOVE|CWM_BIGMOVE)} }, {.i = (CWM_LEFT|CWM_PTRMOVE|CWM_BIGMOVE)} },
{ "bigptrmoveright", kbfunc_client_moveresize, 0, { "bigptrmoveright", kbfunc_client_moveresize, 0,
{.i = (CWM_RIGHT|CWM_PTRMOVE|CWM_BIGMOVE)} }, {.i = (CWM_RIGHT|CWM_PTRMOVE|CWM_BIGMOVE)} },
{ "htile", kbfunc_tile, KBFLAG_NEEDCLIENT, { "htile", kbfunc_tile, CWM_WIN, {.i = CWM_TILE_HORIZ} },
{.i = CWM_TILE_HORIZ } }, { "vtile", kbfunc_tile, CWM_WIN, {.i = CWM_TILE_VERT} },
{ "vtile", kbfunc_tile, KBFLAG_NEEDCLIENT,
{.i = CWM_TILE_VERT } },
}; };
static struct { static struct {
@ -542,20 +531,17 @@ static struct {
int flags; int flags;
union arg argument; union arg argument;
} name_to_mousefunc[] = { } name_to_mousefunc[] = {
{ "window_move", mousefunc_client_move, MOUSEBIND_CTX_WIN, {0} }, { "window_move", mousefunc_client_move, CWM_WIN, {0} },
{ "window_resize", mousefunc_client_resize, MOUSEBIND_CTX_WIN, {0} }, { "window_resize", mousefunc_client_resize, CWM_WIN, {0} },
{ "window_grouptoggle", mousefunc_client_grouptoggle, { "window_grouptoggle", mousefunc_client_grouptoggle, CWM_WIN, {0} },
MOUSEBIND_CTX_WIN, {0} }, { "window_lower", mousefunc_client_lower, CWM_WIN, {0} },
{ "window_lower", mousefunc_client_lower, MOUSEBIND_CTX_WIN, {0} }, { "window_raise", mousefunc_client_raise, CWM_WIN, {0} },
{ "window_raise", mousefunc_client_raise, MOUSEBIND_CTX_WIN, {0} }, { "window_hide", mousefunc_client_hide, CWM_WIN, {0} },
{ "window_hide", mousefunc_client_hide, MOUSEBIND_CTX_WIN, {0} }, { "cyclegroup", mousefunc_client_cyclegroup, 0, {.i = CWM_CYCLE} },
{ "cyclegroup", mousefunc_client_cyclegroup, { "rcyclegroup", mousefunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} },
MOUSEBIND_CTX_ROOT, {.i = CWM_CYCLE} }, { "menu_group", mousefunc_menu_group, 0, {0} },
{ "rcyclegroup", mousefunc_client_cyclegroup, { "menu_unhide", mousefunc_menu_unhide, 0, {0} },
MOUSEBIND_CTX_ROOT, {.i = CWM_RCYCLE} }, { "menu_cmd", mousefunc_menu_cmd, 0, {0} },
{ "menu_group", mousefunc_menu_group, MOUSEBIND_CTX_ROOT, {0} },
{ "menu_unhide", mousefunc_menu_unhide, MOUSEBIND_CTX_ROOT, {0} },
{ "menu_cmd", mousefunc_menu_cmd, MOUSEBIND_CTX_ROOT, {0} },
}; };
int int
@ -639,9 +625,8 @@ conf_grab_mouse(Window win)
xu_btn_ungrab(win); xu_btn_ungrab(win);
TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) { TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
if (mb->flags != MOUSEBIND_CTX_WIN) if (mb->flags & CWM_WIN)
continue; xu_btn_grab(win, mb->modmask, mb->button);
xu_btn_grab(win, mb->modmask, mb->button);
} }
} }

View File

@ -235,11 +235,11 @@ xev_handle_buttonpress(XEvent *ee)
if (mb == NULL) if (mb == NULL)
return; return;
if (mb->flags == MOUSEBIND_CTX_WIN) { if (mb->flags & CWM_WIN) {
if (((cc = client_find(e->window)) == NULL) && if (((cc = client_find(e->window)) == NULL) &&
(cc = client_current()) == NULL) (cc = client_current()) == NULL)
return; return;
} else { /* (mb->flags == MOUSEBIND_CTX_ROOT) */ } else {
if (e->window != e->root) if (e->window != e->root)
return; return;
cc = &fakecc; cc = &fakecc;
@ -287,7 +287,7 @@ xev_handle_keypress(XEvent *ee)
if (kb == NULL) if (kb == NULL)
return; return;
if (kb->flags & KBFLAG_NEEDCLIENT) { if (kb->flags & CWM_WIN) {
if (((cc = client_find(e->window)) == NULL) && if (((cc = client_find(e->window)) == NULL) &&
(cc = client_current()) == NULL) (cc = client_current()) == NULL)
return; return;