xsettings: don't use the xsettings watch function functionality
authorOwen W. Taylor <otaylor@fishsoup.net>
Fri, 12 Nov 2010 23:53:51 +0000 (18:53 -0500)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Sun, 14 Nov 2010 14:50:25 +0000 (14:50 +0000)
The "watch" function functionality in xsettings-client.c is designed
for setups like GDK where filters are per-window. If we are going
to pass all events to _clutter_xsettings_client_process_event()
anyways, we can just pass in NULL for watch.

This avoids a nasty infinite loop where an event would get processed
triggering removing a filter and adding a new filter, which would
immediately run and remove a filter and add another and so on
ad-infinitum.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2415

clutter/x11/clutter-backend-x11.c

index 8a61741..3b7b579 100644 (file)
@@ -120,38 +120,6 @@ xsettings_filter (XEvent       *xevent,
   return CLUTTER_X11_FILTER_CONTINUE;
 }
 
-static Bool
-clutter_backend_x11_xsettings_watch (Window  window,
-                                     Bool    is_start,
-                                     long    mask,
-                                     void   *cb_data)
-{
-  ClutterBackendX11 *backend_x11 = cb_data;
-
-  if (is_start)
-    {
-      backend_x11->xsettings_xwin = window;
-      if (!backend_x11->xsettings_xwin)
-        return False;
-
-      clutter_x11_add_filter (xsettings_filter, backend_x11);
-
-      CLUTTER_NOTE (BACKEND, "Added filter on XSettings manager window 0x%x",
-                    (unsigned int) backend_x11->xsettings_xwin);
-    }
-  else
-    {
-      CLUTTER_NOTE (BACKEND, "Removed filter on XSettings manager window 0x%x",
-                    (unsigned int) backend_x11->xsettings_xwin);
-
-      clutter_x11_remove_filter (xsettings_filter, backend_x11);
-
-      backend_x11->xsettings_xwin = None;
-    }
-
-  return True;
-}
-
 static void
 clutter_backend_x11_xsettings_notify (const char       *name,
                                       XSettingsAction   action,
@@ -336,9 +304,11 @@ clutter_backend_x11_post_parse (ClutterBackend  *backend,
         _clutter_xsettings_client_new (backend_x11->xdpy,
                                        backend_x11->xscreen_num,
                                        clutter_backend_x11_xsettings_notify,
-                                       clutter_backend_x11_xsettings_watch,
+                                       NULL,
                                        backend_x11);
 
+      clutter_x11_add_filter (xsettings_filter, backend_x11);
+
       if (clutter_synchronise)
         XSynchronize (backend_x11->xdpy, True);
 
@@ -426,6 +396,7 @@ clutter_backend_x11_finalize (GObject *gobject)
 
   g_free (backend_x11->display_name);
 
+  clutter_x11_remove_filter (xsettings_filter, backend_x11);
   _clutter_xsettings_client_destroy (backend_x11->xsettings);
 
   XCloseDisplay (backend_x11->xdpy);