aboutsummaryrefslogtreecommitdiffstats
path: root/conf.c
diff options
context:
space:
mode:
authoroga2007-11-19 22:18:16 +0000
committeroga2007-11-19 22:18:16 +0000
commitf83d9ceb32e720b666f35606f4a8a53acae0e8c1 (patch)
treedee33862587d9ae70482f8e3f8ec4d523c77c1cd /conf.c
parentc59a5b8d0a2cad51f2d69c38f8d7bf7c16ae9605 (diff)
downloadcwm-f83d9ceb32e720b666f35606f4a8a53acae0e8c1.tar.gz
Make cwm default keybindings always exist. Additional keybindings now
overlap with the new ones, overriding them. Also a new "unmap" keyword in binding definitions now unmaps a binding without adding a new one. This seriously shrinks the ~/.calmwm/.keys directory of anyone who defines their own bindings whilst wanting some of the defaults. Looked over, liked and ok todd@
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c139
1 files changed, 79 insertions, 60 deletions
diff --git a/conf.c b/conf.c
index d313d4f..c371d13 100644
--- a/conf.c
+++ b/conf.c
@@ -4,7 +4,7 @@
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
* All rights reserved.
*
- * $Id: conf.c,v 1.12 2007/11/13 23:26:04 todd Exp $
+ * $Id: conf.c,v 1.13 2007/11/19 22:18:16 oga Exp $
*/
#include "headers.h"
@@ -181,67 +181,65 @@ 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, "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", "group0");
+ conf_bindname(c, "CM-1", "group1");
+ conf_bindname(c, "CM-2", "group2");
+ conf_bindname(c, "CM-3", "group3");
+ 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_bindname(c, "CM-Return", "terminal");
- conf_bindname(c, "CM-Delete", "lock");
- conf_bindname(c, "M-question", "exec");
- 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", "group0");
- 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_settings, sizeof(dir_settings),
"%s/.calmwm/.settings", home);
@@ -499,6 +497,12 @@ conf_bindname(struct conf *c, char *name, char *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;
@@ -520,6 +524,21 @@ conf_bindname(struct conf *c, char *name, char *binding)
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)
{