[hackers] [wmii] [menu] Grab the keyboard rather than setting the keyboard focus. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Wed, 15 Oct 2008 20:09:01 +0000 (UTC)

changeset: 2368:efd09c52fc58
user: Kris Maglione <jg_AT_suckless.org>
date: Tue Oct 14 19:08:13 2008 -0400
files: cmd/menu/menu.c cmd/wmii/x11.c include/x11.h
description:
[menu] Grab the keyboard rather than setting the keyboard focus.

diff -r 81fd16a57752 -r efd09c52fc58 cmd/menu/menu.c
--- a/cmd/menu/menu.c Tue Oct 14 19:00:58 2008 -0400
+++ b/cmd/menu/menu.c Tue Oct 14 19:08:13 2008 -0400
@@ -223,7 +223,7 @@
         mapwin(barwin);
         raisewin(barwin);
         menu_draw();
- setfocus(barwin, RevertToPointerRoot);
+ grabkeyboard(barwin);
 }
 
 static void
diff -r 81fd16a57752 -r efd09c52fc58 cmd/wmii/x11.c
--- a/cmd/wmii/x11.c Tue Oct 14 19:00:58 2008 -0400
+++ b/cmd/wmii/x11.c Tue Oct 14 19:08:13 2008 -0400
@@ -970,6 +970,19 @@
         XUngrabPointer(display, CurrentTime);
 }
 
+int
+grabkeyboard(Window *w) {
+
+ return XGrabKeyboard(display, w->w, false /* owner events */,
+ GrabModeAsync, GrabModeAsync, CurrentTime
+ ) == GrabSuccess;
+}
+
+void
+ungrabkeyboard(void) {
+ XUngrabKeyboard(display, CurrentTime);
+}
+
 /* Insanity */
 void
 sethints(Window *w) {
diff -r 81fd16a57752 -r efd09c52fc58 include/x11.h
--- a/include/x11.h Tue Oct 14 19:00:58 2008 -0400
+++ b/include/x11.h Tue Oct 14 19:08:13 2008 -0400
@@ -212,6 +212,7 @@
 int getprop_textlist(Window *w, char *name, char **ret[]);
 ulong getprop_ulong(Window*, char*, char*, ulong, ulong**, ulong);
 ulong getproperty(Window*, char *prop, char *type, Atom *actual, ulong offset, uchar **ret, ulong length);
+int grabkeyboard(Window*);
 int grabpointer(Window*, Window *confine, Cursor, int mask);
 void initdisplay(void);
 KeyCode keycode(char*);
@@ -242,6 +243,7 @@
 uint textwidth_l(Font*, char*, uint len);
 int traperrors(bool);
 Point translate(Window*, Window*, Point);
+void ungrabkeyboard(void);
 void ungrabpointer(void);
 int unmapwin(Window*);
 void warppointer(Point);
Received on Wed Oct 15 2008 - 20:09:01 UTC

This archive was generated by hypermail 2.2.0 : Wed Oct 15 2008 - 20:12:05 UTC