aboutsummaryrefslogtreecommitdiffstats
path: root/conf.c
diff options
context:
space:
mode:
authorokan2016-10-18 17:03:30 +0000
committerokan2016-10-18 17:03:30 +0000
commita10bee93be3f2ad370a6dfc360e1b05cb84e7f5c (patch)
tree40fc7c400bfe2a07cc92331d68f6cb4a9a2f4c69 /conf.c
parent7b0b231bfe9465d7b2f57f5257ea719325b36666 (diff)
downloadcwm-a10bee93be3f2ad370a6dfc360e1b05cb84e7f5c.tar.gz
Refactor callbacks to take a void * so as to not try and generalize into
client_ctx in keypress and buttonpress event handlers; pass appropriate *ctx's based on context. While here, limit some globals, replace defines with appropriate variables and fix some naming.
Diffstat (limited to '')
-rw-r--r--conf.c308
1 files changed, 147 insertions, 161 deletions
diff --git a/conf.c b/conf.c
index f725060..dae14e3 100644
--- a/conf.c
+++ b/conf.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: conf.c,v 1.216 2016/10/06 14:53:52 okan Exp $
+ * $OpenBSD: conf.c,v 1.217 2016/10/18 17:03:30 okan Exp $
*/
#include <sys/types.h>
@@ -34,13 +34,13 @@
static const char *conf_bind_getmask(const char *, unsigned int *);
static void conf_cmd_remove(struct conf *, const char *);
-static void conf_unbind_kbd(struct conf *, struct binding *);
-static void conf_unbind_mouse(struct conf *, struct binding *);
+static void conf_unbind_kbd(struct conf *, struct bind_ctx *);
+static void conf_unbind_mouse(struct conf *, struct bind_ctx *);
int
conf_cmd_add(struct conf *c, const char *name, const char *path)
{
- struct cmd *cmd;
+ struct cmd_ctx *cmd;
cmd = xmalloc(sizeof(*cmd));
@@ -61,7 +61,7 @@ conf_cmd_add(struct conf *c, const char *name, const char *path)
static void
conf_cmd_remove(struct conf *c, const char *name)
{
- struct cmd *cmd = NULL, *cmdnxt;
+ struct cmd_ctx *cmd = NULL, *cmdnxt;
TAILQ_FOREACH_SAFE(cmd, &c->cmdq, entry, cmdnxt) {
if (strcmp(cmd->name, name) == 0) {
@@ -74,31 +74,31 @@ conf_cmd_remove(struct conf *c, const char *name)
void
conf_autogroup(struct conf *c, int num, const char *name, const char *class)
{
- struct autogroupwin *aw;
+ struct autogroup *ag;
char *p;
- aw = xmalloc(sizeof(*aw));
+ ag = xmalloc(sizeof(*ag));
if ((p = strchr(class, ',')) == NULL) {
if (name == NULL)
- aw->name = NULL;
+ ag->name = NULL;
else
- aw->name = xstrdup(name);
+ ag->name = xstrdup(name);
- aw->class = xstrdup(class);
+ ag->class = xstrdup(class);
} else {
*(p++) = '\0';
if (name == NULL)
- aw->name = xstrdup(class);
+ ag->name = xstrdup(class);
else
- aw->name = xstrdup(name);
+ ag->name = xstrdup(name);
- aw->class = xstrdup(p);
+ ag->class = xstrdup(p);
}
- aw->num = num;
+ ag->num = num;
- TAILQ_INSERT_TAIL(&c->autogroupq, aw, entry);
+ TAILQ_INSERT_TAIL(&c->autogroupq, ag, entry);
}
void
@@ -264,9 +264,9 @@ conf_init(struct conf *c)
TAILQ_INIT(&c->ignoreq);
TAILQ_INIT(&c->cmdq);
- TAILQ_INIT(&c->keybindingq);
+ TAILQ_INIT(&c->keybindq);
TAILQ_INIT(&c->autogroupq);
- TAILQ_INIT(&c->mousebindingq);
+ TAILQ_INIT(&c->mousebindq);
for (i = 0; i < nitems(kbd_binds); i++)
conf_bind_kbd(c, kbd_binds[i].key, kbd_binds[i].func);
@@ -290,10 +290,10 @@ conf_init(struct conf *c)
void
conf_clear(struct conf *c)
{
- struct autogroupwin *aw;
- struct binding *kb, *mb;
+ struct autogroup *ag;
+ struct bind_ctx *kb, *mb;
struct winname *wn;
- struct cmd *cmd;
+ struct cmd_ctx *cmd;
int i;
while ((cmd = TAILQ_FIRST(&c->cmdq)) != NULL) {
@@ -302,16 +302,16 @@ conf_clear(struct conf *c)
free(cmd);
}
- while ((kb = TAILQ_FIRST(&c->keybindingq)) != NULL) {
- TAILQ_REMOVE(&c->keybindingq, kb, entry);
+ while ((kb = TAILQ_FIRST(&c->keybindq)) != NULL) {
+ TAILQ_REMOVE(&c->keybindq, kb, entry);
free(kb);
}
- while ((aw = TAILQ_FIRST(&c->autogroupq)) != NULL) {
- TAILQ_REMOVE(&c->autogroupq, aw, entry);
- free(aw->class);
- free(aw->name);
- free(aw);
+ while ((ag = TAILQ_FIRST(&c->autogroupq)) != NULL) {
+ TAILQ_REMOVE(&c->autogroupq, ag, entry);
+ free(ag->class);
+ free(ag->name);
+ free(ag);
}
while ((wn = TAILQ_FIRST(&c->ignoreq)) != NULL) {
@@ -320,8 +320,8 @@ conf_clear(struct conf *c)
free(wn);
}
- while ((mb = TAILQ_FIRST(&c->mousebindingq)) != NULL) {
- TAILQ_REMOVE(&c->mousebindingq, mb, entry);
+ while ((mb = TAILQ_FIRST(&c->mousebindq)) != NULL) {
+ TAILQ_REMOVE(&c->mousebindq, mb, entry);
free(mb);
}
@@ -351,147 +351,133 @@ conf_client(struct client_ctx *cc)
static const struct {
const char *tag;
- void (*handler)(struct client_ctx *, union arg *, int);
+ void (*handler)(void *, union arg *, enum xev);
int context;
union arg argument;
} name_to_func[] = {
- { "lower", kbfunc_client_lower, CWM_CONTEXT_CLIENT, {0} },
- { "raise", kbfunc_client_raise, CWM_CONTEXT_CLIENT, {0} },
- { "search", kbfunc_menu_client, CWM_CONTEXT_SCREEN, {0} },
- { "menusearch", kbfunc_menu_cmd, CWM_CONTEXT_SCREEN, {0} },
- { "groupsearch", kbfunc_menu_group, CWM_CONTEXT_SCREEN, {0} },
- { "hide", kbfunc_client_hide, CWM_CONTEXT_CLIENT, {0} },
- { "cycle", kbfunc_client_cycle, CWM_CONTEXT_SCREEN,
- {.i = CWM_CLIENT_CYCLE} },
- { "rcycle", kbfunc_client_cycle, CWM_CONTEXT_SCREEN,
- {.i = CWM_CLIENT_RCYCLE} },
- { "label", kbfunc_menu_client_label, CWM_CONTEXT_CLIENT, {0} },
- { "delete", kbfunc_client_delete, CWM_CONTEXT_CLIENT, {0} },
- { "group1", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 1} },
- { "group2", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 2} },
- { "group3", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 3} },
- { "group4", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 4} },
- { "group5", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 5} },
- { "group6", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 6} },
- { "group7", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 7} },
- { "group8", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 8} },
- { "group9", kbfunc_group_toggle, CWM_CONTEXT_SCREEN, {.i = 9} },
- { "grouponly1", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 1} },
- { "grouponly2", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 2} },
- { "grouponly3", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 3} },
- { "grouponly4", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 4} },
- { "grouponly5", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 5} },
- { "grouponly6", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 6} },
- { "grouponly7", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 7} },
- { "grouponly8", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 8} },
- { "grouponly9", kbfunc_group_only, CWM_CONTEXT_SCREEN, {.i = 9} },
- { "movetogroup1", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
- {.i = 1} },
- { "movetogroup2", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
- {.i = 2} },
- { "movetogroup3", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
- {.i = 3} },
- { "movetogroup4", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
- {.i = 4} },
- { "movetogroup5", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
- {.i = 5} },
- { "movetogroup6", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
- {.i = 6} },
- { "movetogroup7", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
- {.i = 7} },
- { "movetogroup8", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
- {.i = 8} },
- { "movetogroup9", kbfunc_client_movetogroup, CWM_CONTEXT_CLIENT,
- {.i = 9} },
- { "nogroup", kbfunc_group_alltoggle, CWM_CONTEXT_SCREEN, {0} },
- { "cyclegroup", kbfunc_group_cycle, CWM_CONTEXT_SCREEN,
- {.i = CWM_CLIENT_CYCLE} },
- { "rcyclegroup", kbfunc_group_cycle, CWM_CONTEXT_SCREEN,
- {.i = CWM_CLIENT_RCYCLE} },
- { "cycleingroup", kbfunc_client_cycle, CWM_CONTEXT_CLIENT,
- {.i = (CWM_CLIENT_CYCLE | CWM_CLIENT_CYCLE_INGRP)} },
- { "rcycleingroup", kbfunc_client_cycle, CWM_CONTEXT_CLIENT,
- {.i = (CWM_CLIENT_RCYCLE | CWM_CLIENT_CYCLE_INGRP)} },
- { "grouptoggle", kbfunc_client_toggle_group, CWM_CONTEXT_CLIENT, {0} },
- { "stick", kbfunc_client_toggle_sticky, CWM_CONTEXT_CLIENT, {0} },
- { "fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CLIENT,
- {0} },
- { "maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CLIENT, {0} },
- { "vmaximize", kbfunc_client_toggle_vmaximize, CWM_CONTEXT_CLIENT,
- {0} },
- { "hmaximize", kbfunc_client_toggle_hmaximize, CWM_CONTEXT_CLIENT,
- {0} },
- { "freeze", kbfunc_client_toggle_freeze, CWM_CONTEXT_CLIENT, {0} },
- { "restart", kbfunc_cwm_status, CWM_CONTEXT_SCREEN,
- {.i = CWM_EXEC_WM} },
- { "quit", kbfunc_cwm_status, CWM_CONTEXT_SCREEN, {.i = CWM_QUIT} },
- { "exec", kbfunc_menu_exec, CWM_CONTEXT_SCREEN, {.i = CWM_MENU_EXEC} },
- { "exec_wm", kbfunc_menu_exec, CWM_CONTEXT_SCREEN,
+ { "lower", kbfunc_client_lower, CWM_CONTEXT_CC, {0} },
+ { "raise", kbfunc_client_raise, CWM_CONTEXT_CC, {0} },
+ { "search", kbfunc_menu_client, CWM_CONTEXT_SC, {0} },
+ { "menusearch", kbfunc_menu_cmd, CWM_CONTEXT_SC, {0} },
+ { "groupsearch", kbfunc_menu_group, CWM_CONTEXT_SC, {0} },
+ { "hide", kbfunc_client_hide, CWM_CONTEXT_CC, {0} },
+ { "cycle", kbfunc_client_cycle, CWM_CONTEXT_SC,
+ {.i = CWM_CYCLE_FORWARD} },
+ { "rcycle", kbfunc_client_cycle, CWM_CONTEXT_SC,
+ {.i = CWM_CYCLE_REVERSE} },
+ { "label", kbfunc_menu_client_label, CWM_CONTEXT_CC, {0} },
+ { "delete", kbfunc_client_delete, CWM_CONTEXT_CC, {0} },
+ { "group1", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 1} },
+ { "group2", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 2} },
+ { "group3", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 3} },
+ { "group4", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 4} },
+ { "group5", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 5} },
+ { "group6", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 6} },
+ { "group7", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 7} },
+ { "group8", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 8} },
+ { "group9", kbfunc_group_toggle, CWM_CONTEXT_SC, {.i = 9} },
+ { "grouponly1", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 1} },
+ { "grouponly2", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 2} },
+ { "grouponly3", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 3} },
+ { "grouponly4", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 4} },
+ { "grouponly5", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 5} },
+ { "grouponly6", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 6} },
+ { "grouponly7", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 7} },
+ { "grouponly8", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 8} },
+ { "grouponly9", kbfunc_group_only, CWM_CONTEXT_SC, {.i = 9} },
+ { "movetogroup1", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 1} },
+ { "movetogroup2", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 2} },
+ { "movetogroup3", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 3} },
+ { "movetogroup4", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 4} },
+ { "movetogroup5", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 5} },
+ { "movetogroup6", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 6} },
+ { "movetogroup7", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 7} },
+ { "movetogroup8", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 8} },
+ { "movetogroup9", kbfunc_client_movetogroup, CWM_CONTEXT_CC, {.i = 9} },
+ { "nogroup", kbfunc_group_alltoggle, CWM_CONTEXT_SC, {0} },
+ { "cyclegroup", kbfunc_group_cycle, CWM_CONTEXT_SC,
+ {.i = CWM_CYCLE_FORWARD} },
+ { "rcyclegroup", kbfunc_group_cycle, CWM_CONTEXT_SC,
+ {.i = CWM_CYCLE_REVERSE} },
+ { "cycleingroup", kbfunc_client_cycle, CWM_CONTEXT_SC,
+ {.i = (CWM_CYCLE_FORWARD | CWM_CYCLE_INGROUP)} },
+ { "rcycleingroup", kbfunc_client_cycle, CWM_CONTEXT_SC,
+ {.i = (CWM_CYCLE_REVERSE | CWM_CYCLE_INGROUP)} },
+ { "grouptoggle", kbfunc_client_toggle_group, CWM_CONTEXT_CC, {0} },
+ { "stick", kbfunc_client_toggle_sticky, CWM_CONTEXT_CC, {0} },
+ { "fullscreen", kbfunc_client_toggle_fullscreen, CWM_CONTEXT_CC, {0} },
+ { "maximize", kbfunc_client_toggle_maximize, CWM_CONTEXT_CC, {0} },
+ { "vmaximize", kbfunc_client_toggle_vmaximize, CWM_CONTEXT_CC, {0} },
+ { "hmaximize", kbfunc_client_toggle_hmaximize, CWM_CONTEXT_CC, {0} },
+ { "freeze", kbfunc_client_toggle_freeze, CWM_CONTEXT_CC, {0} },
+ { "restart", kbfunc_cwm_status, CWM_CONTEXT_SC, {.i = CWM_EXEC_WM} },
+ { "quit", kbfunc_cwm_status, CWM_CONTEXT_SC, {.i = CWM_QUIT} },
+ { "exec", kbfunc_menu_exec, CWM_CONTEXT_SC,
+ {.i = CWM_MENU_EXEC_EXEC} },
+ { "exec_wm", kbfunc_menu_exec, CWM_CONTEXT_SC,
{.i = CWM_MENU_EXEC_WM} },
- { "ssh", kbfunc_menu_ssh, CWM_CONTEXT_SCREEN, {0} },
- { "terminal", kbfunc_exec_term, CWM_CONTEXT_SCREEN, {0} },
- { "lock", kbfunc_exec_lock, CWM_CONTEXT_SCREEN, {0} },
- { "moveup", kbfunc_client_move, CWM_CONTEXT_CLIENT,
+ { "ssh", kbfunc_menu_ssh, CWM_CONTEXT_SC, {0} },
+ { "terminal", kbfunc_exec_term, CWM_CONTEXT_SC, {0} },
+ { "lock", kbfunc_exec_lock, CWM_CONTEXT_SC, {0} },
+ { "moveup", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_UP)} },
- { "movedown", kbfunc_client_move, CWM_CONTEXT_CLIENT,
+ { "movedown", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_DOWN)} },
- { "moveright", kbfunc_client_move, CWM_CONTEXT_CLIENT,
+ { "moveright", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_RIGHT)} },
- { "moveleft", kbfunc_client_move, CWM_CONTEXT_CLIENT,
+ { "moveleft", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_LEFT)} },
- { "bigmoveup", kbfunc_client_move, CWM_CONTEXT_CLIENT,
+ { "bigmoveup", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_UP | CWM_BIGAMOUNT)} },
- { "bigmovedown", kbfunc_client_move, CWM_CONTEXT_CLIENT,
+ { "bigmovedown", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
- { "bigmoveright", kbfunc_client_move, CWM_CONTEXT_CLIENT,
+ { "bigmoveright", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
- { "bigmoveleft", kbfunc_client_move, CWM_CONTEXT_CLIENT,
+ { "bigmoveleft", kbfunc_client_move, CWM_CONTEXT_CC,
{.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
- { "resizeup", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
+ { "resizeup", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_UP)} },
- { "resizedown", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
+ { "resizedown", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_DOWN)} },
- { "resizeright", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
+ { "resizeright", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_RIGHT)} },
- { "resizeleft", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
+ { "resizeleft", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_LEFT)} },
- { "bigresizeup", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
+ { "bigresizeup", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_UP | CWM_BIGAMOUNT)} },
- { "bigresizedown", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
+ { "bigresizedown", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
- { "bigresizeright", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
+ { "bigresizeright", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
- { "bigresizeleft", kbfunc_client_resize, CWM_CONTEXT_CLIENT,
+ { "bigresizeleft", kbfunc_client_resize, CWM_CONTEXT_CC,
{.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
- { "ptrmoveup", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
+ { "ptrmoveup", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_UP)} },
- { "ptrmovedown", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
+ { "ptrmovedown", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_DOWN)} },
- { "ptrmoveleft", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
+ { "ptrmoveleft", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_LEFT)} },
- { "ptrmoveright", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
+ { "ptrmoveright", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_RIGHT)} },
- { "bigptrmoveup", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
+ { "bigptrmoveup", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_UP | CWM_BIGAMOUNT)} },
- { "bigptrmovedown", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
+ { "bigptrmovedown", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_DOWN | CWM_BIGAMOUNT)} },
- { "bigptrmoveleft", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
+ { "bigptrmoveleft", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_LEFT | CWM_BIGAMOUNT)} },
- { "bigptrmoveright", kbfunc_ptrmove, CWM_CONTEXT_SCREEN,
+ { "bigptrmoveright", kbfunc_ptrmove, CWM_CONTEXT_SC,
{.i = (CWM_RIGHT | CWM_BIGAMOUNT)} },
- { "htile", kbfunc_client_tile, CWM_CONTEXT_CLIENT,
- {.i = CWM_CLIENT_TILE_HORIZ} },
- { "vtile", kbfunc_client_tile, CWM_CONTEXT_CLIENT,
- {.i = CWM_CLIENT_TILE_VERT} },
- { "window_lower", kbfunc_client_lower, CWM_CONTEXT_CLIENT, {0} },
- { "window_raise", kbfunc_client_raise, CWM_CONTEXT_CLIENT, {0} },
- { "window_hide", kbfunc_client_hide, CWM_CONTEXT_CLIENT, {0} },
- { "window_move", mousefunc_client_move, CWM_CONTEXT_CLIENT, {0} },
- { "window_resize", mousefunc_client_resize, CWM_CONTEXT_CLIENT, {0} },
- { "window_grouptoggle", kbfunc_client_toggle_group, CWM_CONTEXT_CLIENT, {0} },
- { "menu_group", kbfunc_menu_group, CWM_CONTEXT_SCREEN, {0} },
- { "menu_unhide", kbfunc_menu_client, CWM_CONTEXT_SCREEN, {0} },
- { "menu_cmd", kbfunc_menu_cmd, CWM_CONTEXT_SCREEN, {0} },
+ { "htile", kbfunc_client_htile, CWM_CONTEXT_CC, {0} },
+ { "vtile", kbfunc_client_vtile, CWM_CONTEXT_CC, {0} },
+ { "window_lower", kbfunc_client_lower, CWM_CONTEXT_CC, {0} },
+ { "window_raise", kbfunc_client_raise, CWM_CONTEXT_CC, {0} },
+ { "window_hide", kbfunc_client_hide, CWM_CONTEXT_CC, {0} },
+ { "window_move", mousefunc_client_move, CWM_CONTEXT_CC, {0} },
+ { "window_resize", mousefunc_client_resize, CWM_CONTEXT_CC, {0} },
+ { "window_grouptoggle", kbfunc_client_toggle_group, CWM_CONTEXT_CC, {0} },
+ { "menu_group", kbfunc_menu_group, CWM_CONTEXT_SC, {0} },
+ { "menu_unhide", kbfunc_menu_client, CWM_CONTEXT_SC, {0} },
+ { "menu_cmd", kbfunc_menu_cmd, CWM_CONTEXT_SC, {0} },
};
static const struct {
@@ -526,7 +512,7 @@ conf_bind_getmask(const char *name, unsigned int *mask)
int
conf_bind_kbd(struct conf *c, const char *bind, const char *cmd)
{
- struct binding *kb;
+ struct bind_ctx *kb;
const char *key;
unsigned int i;
@@ -555,28 +541,28 @@ conf_bind_kbd(struct conf *c, const char *bind, const char *cmd)
kb->callback = name_to_func[i].handler;
kb->context = name_to_func[i].context;
kb->argument = name_to_func[i].argument;
- TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry);
+ TAILQ_INSERT_TAIL(&c->keybindq, kb, entry);
return(1);
}
- kb->callback = kbfunc_exec;
+ kb->callback = kbfunc_exec_cmd;
kb->context = CWM_CONTEXT_NONE;
kb->argument.c = xstrdup(cmd);
- TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry);
+ TAILQ_INSERT_TAIL(&c->keybindq, kb, entry);
return(1);
}
static void
-conf_unbind_kbd(struct conf *c, struct binding *unbind)
+conf_unbind_kbd(struct conf *c, struct bind_ctx *unbind)
{
- struct binding *key = NULL, *keynxt;
+ struct bind_ctx *key = NULL, *keynxt;
- TAILQ_FOREACH_SAFE(key, &c->keybindingq, entry, keynxt) {
+ TAILQ_FOREACH_SAFE(key, &c->keybindq, entry, keynxt) {
if (key->modmask != unbind->modmask)
continue;
if (key->press.keysym == unbind->press.keysym) {
- TAILQ_REMOVE(&c->keybindingq, key, entry);
+ TAILQ_REMOVE(&c->keybindq, key, entry);
if (key->context == CWM_CONTEXT_NONE)
free(key->argument.c);
free(key);
@@ -587,7 +573,7 @@ conf_unbind_kbd(struct conf *c, struct binding *unbind)
int
conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
{
- struct binding *mb;
+ struct bind_ctx *mb;
const char *button, *errstr;
unsigned int i;
@@ -616,7 +602,7 @@ conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
mb->callback = name_to_func[i].handler;
mb->context = name_to_func[i].context;
mb->argument = name_to_func[i].argument;
- TAILQ_INSERT_TAIL(&c->mousebindingq, mb, entry);
+ TAILQ_INSERT_TAIL(&c->mousebindq, mb, entry);
return(1);
}
@@ -624,16 +610,16 @@ conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
}
static void
-conf_unbind_mouse(struct conf *c, struct binding *unbind)
+conf_unbind_mouse(struct conf *c, struct bind_ctx *unbind)
{
- struct binding *mb = NULL, *mbnxt;
+ struct bind_ctx *mb = NULL, *mbnxt;
- TAILQ_FOREACH_SAFE(mb, &c->mousebindingq, entry, mbnxt) {
+ TAILQ_FOREACH_SAFE(mb, &c->mousebindq, entry, mbnxt) {
if (mb->modmask != unbind->modmask)
continue;
if (mb->press.button == unbind->press.button) {
- TAILQ_REMOVE(&c->mousebindingq, mb, entry);
+ TAILQ_REMOVE(&c->mousebindq, mb, entry);
free(mb);
}
}
@@ -660,13 +646,13 @@ static unsigned int ign_mods[] = { 0, LockMask, Mod2Mask, Mod2Mask | LockMask };
void
conf_grab_mouse(Window win)
{
- struct binding *mb;
+ struct bind_ctx *mb;
unsigned int i;
XUngrabButton(X_Dpy, AnyButton, AnyModifier, win);
- TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
- if (mb->context != CWM_CONTEXT_CLIENT)
+ TAILQ_FOREACH(mb, &Conf.mousebindq, entry) {
+ if (mb->context != CWM_CONTEXT_CC)
continue;
for (i = 0; i < nitems(ign_mods); i++) {
XGrabButton(X_Dpy, mb->press.button,
@@ -681,13 +667,13 @@ conf_grab_mouse(Window win)
void
conf_grab_kbd(Window win)
{
- struct binding *kb;
+ struct bind_ctx *kb;
KeyCode kc;
unsigned int i;
XUngrabKey(X_Dpy, AnyKey, AnyModifier, win);
- TAILQ_FOREACH(kb, &Conf.keybindingq, entry) {
+ TAILQ_FOREACH(kb, &Conf.keybindq, entry) {
kc = XKeysymToKeycode(X_Dpy, kb->press.keysym);
if ((XkbKeycodeToKeysym(X_Dpy, kc, 0, 0) != kb->press.keysym) &&
(XkbKeycodeToKeysym(X_Dpy, kc, 0, 1) == kb->press.keysym))