[gnome-settings-daemon] keyboard: Merge both events filters



commit df15992db6fc777bd081ef2772f346bd0a7de8de
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Apr 26 19:11:16 2012 +0100

    keyboard: Merge both events filters

 plugins/keyboard/gsd-keyboard-manager.c |   45 +++++++++++--------------------
 1 files changed, 16 insertions(+), 29 deletions(-)
---
diff --git a/plugins/keyboard/gsd-keyboard-manager.c b/plugins/keyboard/gsd-keyboard-manager.c
index b040407..84fba6b 100644
--- a/plugins/keyboard/gsd-keyboard-manager.c
+++ b/plugins/keyboard/gsd-keyboard-manager.c
@@ -434,14 +434,6 @@ gsd_keyboard_xkb_analyze_sysconfig (GsdKeyboardManager *manager)
 						  NULL);
 }
 
-static GdkFilterReturn
-gsd_keyboard_xkb_evt_filter (GdkXEvent * xev, GdkEvent * event, GsdKeyboardManager *manager)
-{
-	XEvent *xevent = (XEvent *) xev;
-	xkl_engine_filter_events (manager->priv->xkl_engine, xevent);
-	return GDK_FILTER_CONTINUE;
-}
-
 static void
 gsd_keyboard_xkb_init (GsdKeyboardManager *manager)
 {
@@ -465,9 +457,6 @@ gsd_keyboard_xkb_init (GsdKeyboardManager *manager)
 	g_signal_connect (manager->priv->settings_keyboard, "changed",
 			  (GCallback) xkb_settings_changed, manager);
 
-	gdk_window_add_filter (NULL, (GdkFilterFunc)
-			       gsd_keyboard_xkb_evt_filter, manager);
-
 	gnome_settings_profile_start ("xkl_engine_start_listen");
 	xkl_engine_start_listen (manager->priv->xkl_engine,
 				 XKLL_MANAGE_LAYOUTS |
@@ -494,9 +483,6 @@ gsd_keyboard_xkb_shutdown (GsdKeyboardManager *manager)
 				XKLL_MANAGE_LAYOUTS |
 				XKLL_MANAGE_WINDOW_STATES);
 
-	gdk_window_remove_filter (NULL, (GdkFilterFunc)
-				  gsd_keyboard_xkb_evt_filter, manager);
-
 	g_object_unref (manager->priv->settings_desktop);
 	manager->priv->settings_desktop = NULL;
 	g_object_unref (manager->priv->settings_keyboard);
@@ -572,14 +558,19 @@ numlock_set_xkb_state (GsdNumLockState new_state)
 }
 
 static GdkFilterReturn
-numlock_xkb_callback (GdkXEvent *xev_,
-                      GdkEvent  *gdkev_,
-                      gpointer   user_data)
+xkb_events_filter (GdkXEvent *xev_,
+		   GdkEvent  *gdkev_,
+		   gpointer   user_data)
 {
         XEvent *xev = (XEvent *) xev_;
 	XkbEvent *xkbev = (XkbEvent *) xev;
         GsdKeyboardManager *manager = (GsdKeyboardManager *) user_data;
 
+	/* libxklavier's events first */
+	if (manager->priv->xkl_engine != NULL)
+		xkl_engine_filter_events (manager->priv->xkl_engine, xev);
+
+	/* Then XKB specific events */
         if (xev->type != manager->priv->xkb_event_base)
 		return GDK_FILTER_CONTINUE;
 
@@ -605,24 +596,18 @@ numlock_xkb_callback (GdkXEvent *xev_,
 }
 
 static void
-numlock_install_xkb_callback (GsdKeyboardManager *manager)
+install_xkb_filter (GsdKeyboardManager *manager)
 {
-        if (!manager->priv->have_xkb)
-                return;
-
         gdk_window_add_filter (NULL,
-                               numlock_xkb_callback,
+                               xkb_events_filter,
                                manager);
 }
 
 static void
-numlock_remove_xkb_callback (GsdKeyboardManager *manager)
+remove_xkb_filter (GsdKeyboardManager *manager)
 {
-        if (!manager->priv->have_xkb)
-                return;
-
         gdk_window_remove_filter (NULL,
-                                  numlock_xkb_callback,
+                                  xkb_events_filter,
                                   manager);
 }
 
@@ -765,7 +750,8 @@ start_keyboard_idle_cb (GsdKeyboardManager *manager)
         g_signal_connect (G_OBJECT (manager->priv->settings), "changed",
                           G_CALLBACK (apply_settings), manager);
 
-        numlock_install_xkb_callback (manager);
+	if (manager->priv->have_xkb)
+		install_xkb_filter (manager);
 
         gnome_settings_profile_end (NULL);
 
@@ -805,7 +791,8 @@ gsd_keyboard_manager_stop (GsdKeyboardManager *manager)
                 p->device_manager = NULL;
         }
 
-        numlock_remove_xkb_callback (manager);
+	if (manager->priv->have_xkb)
+		remove_xkb_filter (manager);
         gsd_keyboard_xkb_shutdown (manager);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]