aboutsummaryrefslogtreecommitdiffstats
path: root/conf.c
diff options
context:
space:
mode:
authorokan2013-05-23 16:52:39 +0000
committerokan2013-05-23 16:52:39 +0000
commit0e1a282d21c537a3a9f065464a15044befb6f4d1 (patch)
tree800f1952cd32945dea37108928df92ad489a7ab1 /conf.c
parent5a8fdbc2af0bc6cb55cda04a3dc9ef09bbb40090 (diff)
downloadcwm-0e1a282d21c537a3a9f065464a15044befb6f4d1.tar.gz
alter conf_grab(_kbd) to first ungrab AnyKey/AnyModifier, then proceed
to grab keys in keybindingq. we don't need to ungrab/grab on every addition to the queue, just once with a complete keybindingq; simplify grabbing keys per screen (during init) and during a MappingNotify. while here, change conf_grab_{kbd,mouse} to require only a Window.
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c56
1 files changed, 16 insertions, 40 deletions
diff --git a/conf.c b/conf.c
index 8892a50..c0e6314 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.132 2013/05/22 20:23:21 okan Exp $
+ * $OpenBSD: conf.c,v 1.133 2013/05/23 16:52:39 okan Exp $
*/
#include <sys/param.h>
@@ -98,7 +98,6 @@ static char *color_binds[CWM_COLOR_MAX] = {
void
conf_screen(struct screen_ctx *sc)
{
- struct keybinding *kb;
int i;
XftColor xc;
@@ -141,8 +140,7 @@ conf_screen(struct screen_ctx *sc)
if (sc->xftdraw == NULL)
errx(1, "XftDrawCreate");
- TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
- xu_key_grab(sc->rootwin, kb->modmask, kb->keysym);
+ conf_grab_kbd(sc->rootwin);
}
static struct {
@@ -436,37 +434,6 @@ static struct {
{.i = CWM_TILE_VERT } },
};
-/*
- * The following two functions are used when grabbing and ungrabbing keys for
- * bindings
- */
-
-/*
- * Grab key combination on all screens and add to the global queue
- */
-void
-conf_grab(struct conf *c, struct keybinding *kb)
-{
- extern struct screen_ctx_q Screenq;
- struct screen_ctx *sc;
-
- TAILQ_FOREACH(sc, &Screenq, entry)
- xu_key_grab(sc->rootwin, kb->modmask, kb->keysym);
-}
-
-/*
- * Ungrab key combination from all screens and remove from global queue
- */
-void
-conf_ungrab(struct conf *c, struct keybinding *kb)
-{
- extern struct screen_ctx_q Screenq;
- struct screen_ctx *sc;
-
- TAILQ_FOREACH(sc, &Screenq, entry)
- xu_key_ungrab(sc->rootwin, kb->modmask, kb->keysym);
-}
-
static struct {
char chr;
int mask;
@@ -656,17 +623,26 @@ conf_mouseunbind(struct conf *c, struct mousebinding *unbind)
}
}
-/*
- * Grab the mouse buttons that we need for bindings for this client
- */
void
-conf_grab_mouse(struct client_ctx *cc)
+conf_grab_mouse(Window win)
{
struct mousebinding *mb;
TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
if (mb->context != MOUSEBIND_CTX_WIN)
continue;
- xu_btn_grab(cc->win, mb->modmask, mb->button);
+ xu_btn_grab(win, mb->modmask, mb->button);
}
}
+
+void
+conf_grab_kbd(Window win)
+{
+ struct keybinding *kb;
+
+ XUngrabKey(X_Dpy, AnyKey, AnyModifier, win);
+
+ TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
+ xu_key_grab(win, kb->modmask, kb->keysym);
+}
+