aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--calmwm.h3
-rw-r--r--conf.c139
-rw-r--r--cwm.113
3 files changed, 91 insertions, 64 deletions
diff --git a/calmwm.h b/calmwm.h
index 269c213..741feb5 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -4,7 +4,7 @@
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
* All rights reserved.
*
- * $Id: calmwm.h,v 1.11 2007/11/13 23:26:04 todd Exp $
+ * $Id: calmwm.h,v 1.12 2007/11/19 22:18:16 oga Exp $
*/
#ifndef _CALMWM_H_
@@ -406,6 +406,7 @@ void conf_client(struct client_ctx *);
void conf_bindkey(struct conf *, void (*)(struct client_ctx *, void *),
int, int, int, void *);
void conf_bindname(struct conf *, char *, char *);
+void conf_unbind(struct conf *, struct keybinding *);
void conf_parsekeys(struct conf *, char *);
void conf_parsesettings(struct conf *, char *);
void conf_parseignores(struct conf *, char *);
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)
{
diff --git a/cwm.1 b/cwm.1
index 35846fe..57ac99a 100644
--- a/cwm.1
+++ b/cwm.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: cwm.1,v 1.15 2007/11/16 23:04:56 jmc Exp $
+.\" $OpenBSD: cwm.1,v 1.16 2007/11/19 22:18:16 oga Exp $
.\"
.\" The following requests are required for all man pages.
.Dd June 29, 2007
@@ -286,8 +286,8 @@ will cause any instances of
to not have borders.
.It Pa ~/.calmwm/.keys
Symlinks in this directory cause the creation of keyboard shortcuts.
-If the directory does not exist, then the default shortcuts will be
-created; otherwise only the shortcuts defined will be created.
+The default shortcuts will always be created. In case of conflict,
+user-defined shortcuts take precidence.
The name of a link here is first the modifier keys, followed by a ``-''.
The following modifiers are recognised:
.Bl -tag -width Ds
@@ -312,6 +312,9 @@ The target of the link should be either the name of a task from the
structure in
.Pa /usr/src/xenocara/app/cwm/conf.c ,
or, alternatively it should be the commandline that is wished to be executed.
+A special case is the ``unmap'' keyword, which causes any bindings using the
+named shortcut to be removed. This can be used to remove a binding which conflicts
+with an application.
For example, to cause
.Ic C-M-r
to add a label to a window:
@@ -324,6 +327,10 @@ with C-S-Enter:
.Bd -literal -offset indent
$ ln -s "/usr/X11R6/bin/xterm -e top" ~/.calmwm/.keys/CS-Return
.Ed
+Remove a keybinding for Mod4-o
+.Bd -literal -offset indent
+$ ln -s "unmap" 4-o
+.Ed
.El
.Sh AUTHORS
.An -nosplit