changeset 2338:a9f52daf13ba

Grab keys on all screens, not only the default one. Should fix #119.
author Sascha Hlusiak <contact@saschahlusiak.de>
date Thu, 24 Jan 2008 18:57:40 +0100
parents 107c1fed3d92
children b2a2ca9fceda
files src/hotkey/grab.c
diffstat 1 files changed, 25 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotkey/grab.c	Thu Jan 24 12:05:59 2008 +0000
+++ b/src/hotkey/grab.c	Thu Jan 24 18:57:40 2008 +0100
@@ -191,11 +191,16 @@
 
 void grab_keys ( )
 {
-	Display* xdisplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
-	Window x_root_window = GDK_WINDOW_XID(gdk_get_default_root_window());
+	GdkDisplay* display;
+	Display* xdisplay;
+	GdkWindow *root_window;
+	int i;
 	PluginConfig* plugin_cfg = get_config();
 	HotkeyConfiguration *hotkey;
+
 	XErrorHandler old_handler = 0;
+	display = gdk_display_get_default();
+ 	xdisplay = GDK_DISPLAY_XDISPLAY(display);
 
 	if (grabbed) return;
 
@@ -207,7 +212,11 @@
 	hotkey = &(plugin_cfg->first);
 	while (hotkey)
 	{
-		grab_key(hotkey, xdisplay, x_root_window);
+		for (i=0;i<gdk_display_get_n_screens(display);i++)
+		{
+			root_window = gdk_screen_get_root_window(gdk_display_get_screen(display, i));
+			grab_key(hotkey, xdisplay, GDK_WINDOW_XID(root_window));
+		}
 		hotkey = hotkey->next;
 	}
 
@@ -286,12 +295,17 @@
 
 void ungrab_keys ( )
 {
-	XErrorHandler old_handler = 0;
-	Display* xdisplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
-	Window x_root_window = GDK_WINDOW_XID(gdk_get_default_root_window());
+	GdkDisplay* display;
+	Display* xdisplay;
+	GdkWindow *root_window;
+	int i;
 	PluginConfig* plugin_cfg = get_config();
 	HotkeyConfiguration *hotkey;
 
+	XErrorHandler old_handler = 0;
+	display = gdk_display_get_default();
+ 	xdisplay = GDK_DISPLAY_XDISPLAY(display);
+
 	if (!grabbed) return;
 	if (!xdisplay) return;
 
@@ -303,7 +317,11 @@
 	hotkey = &(plugin_cfg->first);
 	while (hotkey)
 	{
-		ungrab_key(hotkey, xdisplay, x_root_window);
+		for (i=0;i<gdk_display_get_n_screens(display);i++)
+		{
+			root_window = gdk_screen_get_root_window(gdk_display_get_screen(display, i));
+			ungrab_key(hotkey, xdisplay, GDK_WINDOW_XID(root_window));
+		}
 		hotkey = hotkey->next;
 	}