aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorokan2016-11-14 21:25:59 +0000
committerokan2016-11-14 21:25:59 +0000
commitee3ec00421417024d273006f0a412ca5f6f302b7 (patch)
tree73bb46c0823434b683aa5794157c9c5b5d01ad55
parent277714c53ff6e57732583dd3b1f7eb3e7ac23935 (diff)
downloadcwm-ee3ec00421417024d273006f0a412ca5f6f302b7.tar.gz
Define callbacks, then default bindings.
-rw-r--r--calmwm.h4
-rw-r--r--conf.c160
-rw-r--r--parse.y4
3 files changed, 85 insertions, 83 deletions
diff --git a/calmwm.h b/calmwm.h
index 68e0066..7867dc2 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -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: calmwm.h,v 1.330 2016/10/24 17:16:23 okan Exp $
+ * $OpenBSD: calmwm.h,v 1.331 2016/11/14 21:25:59 okan Exp $
*/
#ifndef _CALMWM_H_
@@ -518,7 +518,7 @@ int parse_config(const char *, struct conf *);
void conf_atoms(void);
void conf_autogroup(struct conf *, int, const char *,
const char *);
-int conf_bind_kbd(struct conf *, const char *,
+int conf_bind_key(struct conf *, const char *,
const char *);
int conf_bind_mouse(struct conf *, const char *,
const char *);
diff --git a/conf.c b/conf.c
index c72ac9a..bcae78d 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.221 2016/11/14 19:56:05 okan Exp $
+ * $OpenBSD: conf.c,v 1.222 2016/11/14 21:25:59 okan Exp $
*/
#include <sys/types.h>
@@ -34,7 +34,7 @@
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 bind_ctx *);
+static void conf_unbind_key(struct conf *, struct bind_ctx *);
static void conf_unbind_mouse(struct conf *, struct bind_ctx *);
static int cursor_binds[] = {
@@ -55,73 +55,6 @@ static const char *color_binds[] = {
"", /* CWM_COLOR_MENU_FONT_SEL */
};
static const struct {
- const char *key;
- const char *func;
-} kbd_binds[] = {
- { "CM-Return", "terminal" },
- { "CM-Delete", "lock" },
- { "M-question", "exec" },
- { "CM-w", "exec_wm" },
- { "M-period", "ssh" },
- { "M-Return", "hide" },
- { "M-Down", "lower" },
- { "M-Up", "raise" },
- { "M-slash", "search" },
- { "C-slash", "menusearch" },
- { "M-Tab", "cycle" },
- { "MS-Tab", "rcycle" },
- { "CM-n", "label" },
- { "CM-x", "delete" },
- { "CM-a", "nogroup" },
- { "CM-0", "nogroup" },
- { "CM-1", "group1" },
- { "CM-2", "group2" },
- { "CM-3", "group3" },
- { "CM-4", "group4" },
- { "CM-5", "group5" },
- { "CM-6", "group6" },
- { "CM-7", "group7" },
- { "CM-8", "group8" },
- { "CM-9", "group9" },
- { "M-Right", "cyclegroup" },
- { "M-Left", "rcyclegroup" },
- { "CM-g", "grouptoggle" },
- { "CM-f", "fullscreen" },
- { "CM-m", "maximize" },
- { "CM-s", "stick" },
- { "CM-equal", "vmaximize" },
- { "CMS-equal", "hmaximize" },
- { "CMS-f", "freeze" },
- { "CMS-r", "restart" },
- { "CMS-q", "quit" },
- { "M-h", "moveleft" },
- { "M-j", "movedown" },
- { "M-k", "moveup" },
- { "M-l", "moveright" },
- { "MS-h", "bigmoveleft" },
- { "MS-j", "bigmovedown" },
- { "MS-k", "bigmoveup" },
- { "MS-l", "bigmoveright" },
- { "CM-h", "resizeleft" },
- { "CM-j", "resizedown" },
- { "CM-k", "resizeup" },
- { "CM-l", "resizeright" },
- { "CMS-h", "bigresizeleft" },
- { "CMS-j", "bigresizedown" },
- { "CMS-k", "bigresizeup" },
- { "CMS-l", "bigresizeright" },
-},
-mouse_binds[] = {
- { "1", "menu_unhide" },
- { "2", "menu_group" },
- { "3", "menu_cmd" },
- { "M-1", "window_move" },
- { "CM-1", "window_grouptoggle" },
- { "M-2", "window_resize" },
- { "M-3", "window_lower" },
- { "CMS-3", "window_hide" },
-};
-static const struct {
const char *tag;
void (*handler)(void *, union arg *, enum xev);
int context;
@@ -251,6 +184,9 @@ static const struct {
{ "menu_unhide", kbfunc_menu_client, CWM_CONTEXT_SC, {0} },
{ "menu_cmd", kbfunc_menu_cmd, CWM_CONTEXT_SC, {0} },
};
+static unsigned int ignore_mods[] = {
+ 0, LockMask, Mod2Mask, Mod2Mask | LockMask
+};
static const struct {
const char ch;
int mask;
@@ -260,7 +196,73 @@ static const struct {
{ '4', Mod4Mask },
{ 'S', ShiftMask },
};
-static unsigned int ign_mods[] = { 0, LockMask, Mod2Mask, Mod2Mask | LockMask };
+static const struct {
+ const char *key;
+ const char *func;
+} key_binds[] = {
+ { "CM-Return", "terminal" },
+ { "CM-Delete", "lock" },
+ { "M-question", "exec" },
+ { "CM-w", "exec_wm" },
+ { "M-period", "ssh" },
+ { "M-Return", "hide" },
+ { "M-Down", "lower" },
+ { "M-Up", "raise" },
+ { "M-slash", "search" },
+ { "C-slash", "menusearch" },
+ { "M-Tab", "cycle" },
+ { "MS-Tab", "rcycle" },
+ { "CM-n", "label" },
+ { "CM-x", "delete" },
+ { "CM-a", "nogroup" },
+ { "CM-0", "nogroup" },
+ { "CM-1", "group1" },
+ { "CM-2", "group2" },
+ { "CM-3", "group3" },
+ { "CM-4", "group4" },
+ { "CM-5", "group5" },
+ { "CM-6", "group6" },
+ { "CM-7", "group7" },
+ { "CM-8", "group8" },
+ { "CM-9", "group9" },
+ { "M-Right", "cyclegroup" },
+ { "M-Left", "rcyclegroup" },
+ { "CM-g", "grouptoggle" },
+ { "CM-f", "fullscreen" },
+ { "CM-m", "maximize" },
+ { "CM-s", "stick" },
+ { "CM-equal", "vmaximize" },
+ { "CMS-equal", "hmaximize" },
+ { "CMS-f", "freeze" },
+ { "CMS-r", "restart" },
+ { "CMS-q", "quit" },
+ { "M-h", "moveleft" },
+ { "M-j", "movedown" },
+ { "M-k", "moveup" },
+ { "M-l", "moveright" },
+ { "MS-h", "bigmoveleft" },
+ { "MS-j", "bigmovedown" },
+ { "MS-k", "bigmoveup" },
+ { "MS-l", "bigmoveright" },
+ { "CM-h", "resizeleft" },
+ { "CM-j", "resizedown" },
+ { "CM-k", "resizeup" },
+ { "CM-l", "resizeright" },
+ { "CMS-h", "bigresizeleft" },
+ { "CMS-j", "bigresizedown" },
+ { "CMS-k", "bigresizeup" },
+ { "CMS-l", "bigresizeright" },
+},
+mouse_binds[] = {
+ { "1", "menu_unhide" },
+ { "2", "menu_group" },
+ { "3", "menu_cmd" },
+ { "M-1", "window_move" },
+ { "CM-1", "window_grouptoggle" },
+ { "M-2", "window_resize" },
+ { "M-3", "window_lower" },
+ { "CMS-3", "window_hide" },
+};
void
conf_init(struct conf *c)
@@ -280,8 +282,8 @@ conf_init(struct conf *c)
TAILQ_INIT(&c->autogroupq);
TAILQ_INIT(&c->mousebindq);
- 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(key_binds); i++)
+ conf_bind_key(c, key_binds[i].key, key_binds[i].func);
for (i = 0; i < nitems(mouse_binds); i++)
conf_bind_mouse(c, mouse_binds[i].key, mouse_binds[i].func);
@@ -502,7 +504,7 @@ conf_bind_getmask(const char *name, unsigned int *mask)
}
int
-conf_bind_kbd(struct conf *c, const char *bind, const char *cmd)
+conf_bind_key(struct conf *c, const char *bind, const char *cmd)
{
struct bind_ctx *kb;
const char *key;
@@ -517,7 +519,7 @@ conf_bind_kbd(struct conf *c, const char *bind, const char *cmd)
return(0);
}
/* Remove duplicates. */
- conf_unbind_kbd(c, kb);
+ conf_unbind_key(c, kb);
if (strcmp("unmap", cmd) == 0) {
free(kb);
@@ -540,7 +542,7 @@ conf_bind_kbd(struct conf *c, const char *bind, const char *cmd)
}
static void
-conf_unbind_kbd(struct conf *c, struct bind_ctx *unbind)
+conf_unbind_key(struct conf *c, struct bind_ctx *unbind)
{
struct bind_ctx *key = NULL, *keynxt;
@@ -620,8 +622,8 @@ conf_grab_kbd(Window win)
(XkbKeycodeToKeysym(X_Dpy, kc, 0, 1) == kb->press.keysym))
kb->modmask |= ShiftMask;
- for (i = 0; i < nitems(ign_mods); i++)
- XGrabKey(X_Dpy, kc, (kb->modmask | ign_mods[i]), win,
+ for (i = 0; i < nitems(ignore_mods); i++)
+ XGrabKey(X_Dpy, kc, (kb->modmask | ignore_mods[i]), win,
True, GrabModeAsync, GrabModeAsync);
}
}
@@ -637,9 +639,9 @@ conf_grab_mouse(Window win)
TAILQ_FOREACH(mb, &Conf.mousebindq, entry) {
if (mb->context != CWM_CONTEXT_CC)
continue;
- for (i = 0; i < nitems(ign_mods); i++) {
+ for (i = 0; i < nitems(ignore_mods); i++) {
XGrabButton(X_Dpy, mb->press.button,
- (mb->modmask | ign_mods[i]), win, False,
+ (mb->modmask | ignore_mods[i]), win, False,
BUTTONMASK, GrabModeAsync, GrabModeSync,
None, None);
}
diff --git a/parse.y b/parse.y
index c615d0b..7ed8f93 100644
--- a/parse.y
+++ b/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.65 2016/10/03 14:42:34 okan Exp $ */
+/* $OpenBSD: parse.y,v 1.66 2016/11/14 21:25:59 okan Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -170,7 +170,7 @@ main : FONTNAME STRING {
free($2);
}
| BIND STRING string {
- if (!conf_bind_kbd(conf, $2, $3)) {
+ if (!conf_bind_key(conf, $2, $3)) {
yyerror("invalid bind: %s %s", $2, $3);
free($2);
free($3);