[gnome-settings-daemon] common: Add code to grab a mouse button on a device
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] common: Add code to grab a mouse button on a device
- Date: Mon, 13 Feb 2012 18:22:12 +0000 (UTC)
commit 5693e1bedd4624a60acf4b811041340602e5a5a6
Author: Bastien Nocera <hadess hadess net>
Date: Mon Feb 13 18:14:27 2012 +0000
common: Add code to grab a mouse button on a device
So we can capture all the mouse button events from the pad device.
plugins/common/gsd-keygrab.c | 56 ++++++++++++++++++++++++++++++++++++++++++
plugins/common/gsd-keygrab.h | 4 +++
2 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/plugins/common/gsd-keygrab.c b/plugins/common/gsd-keygrab.c
index ace44cd..755cc24 100644
--- a/plugins/common/gsd-keygrab.c
+++ b/plugins/common/gsd-keygrab.c
@@ -366,3 +366,59 @@ free_key (Key *key)
g_free (key->keycodes);
g_free (key);
}
+
+static void
+grab_button_real (int deviceid,
+ gboolean grab,
+ GdkWindow *root)
+{
+ XIGrabModifiers mods;
+
+ mods.modifiers = XIAnyModifier;
+
+ if (grab) {
+ XIEventMask evmask;
+ unsigned char mask[(XI_LASTEVENT + 7)/8];
+
+ memset (mask, 0, sizeof (mask));
+ XISetMask (mask, XI_ButtonRelease);
+
+ evmask.deviceid = deviceid;
+ evmask.mask_len = sizeof (mask);
+ evmask.mask = mask;
+
+ XIGrabButton (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ deviceid,
+ XIAnyButton,
+ GDK_WINDOW_XID (root),
+ None,
+ GrabModeAsync,
+ GrabModeAsync,
+ False,
+ &evmask,
+ 1,
+ &mods);
+ } else {
+ XIUngrabButton (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ deviceid,
+ XIAnyButton,
+ GDK_WINDOW_XID (root),
+ 1, &mods);
+ }
+}
+
+void
+grab_button (int deviceid,
+ gboolean grab,
+ GSList *screens)
+{
+ GSList *l;
+
+ for (l = screens; l; l = l->next) {
+ GdkScreen *screen = l->data;
+
+ grab_button_real (deviceid,
+ grab,
+ gdk_screen_get_root_window (screen));
+ }
+}
diff --git a/plugins/common/gsd-keygrab.h b/plugins/common/gsd-keygrab.h
index 8e92dd2..e450072 100644
--- a/plugins/common/gsd-keygrab.h
+++ b/plugins/common/gsd-keygrab.h
@@ -46,6 +46,10 @@ gboolean key_uses_keycode (const Key *key,
Key * parse_key (const char *str);
void free_key (Key *key);
+void grab_button (int deviceid,
+ gboolean grab,
+ GSList *screens);
+
G_END_DECLS
#endif /* __GSD_COMMON_KEYGRAB_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]