metacity r4089 - in trunk: . src/core



Author: tthurman
Date: Tue Jan 27 03:53:07 2009
New Revision: 4089
URL: http://svn.gnome.org/viewvc/metacity?rev=4089&view=rev

Log:
        More of the window properties are checked using simple
        window property handlers.  The ones which remain don't
        actually look up the new value in the ordinary way, and
        so are a little trickier to merge.  Added an "initial"
        flag to be on the safe side that the behaviour is the
        same as before (so we don't do things when a window's
        first mapped that we only used to do when a property
        changed).  Partial fix for bug #549886.
	* src/core/window-props.c:
	* src/core/window-props.h:
	* src/core/window.c:



Modified:
   trunk/ChangeLog
   trunk/src/core/window-props.c
   trunk/src/core/window-props.h
   trunk/src/core/window.c

Modified: trunk/src/core/window-props.c
==============================================================================
--- trunk/src/core/window-props.c	(original)
+++ trunk/src/core/window-props.c	Tue Jan 27 03:53:07 2009
@@ -54,7 +54,8 @@
                                   Atom           property,
                                   MetaPropValue *value);
 typedef void (* ReloadValueFunc) (MetaWindow    *window,
-                                  MetaPropValue *value);
+                                  MetaPropValue *value,
+                                  gboolean       initial);
 
 struct _MetaWindowPropHooks
 {
@@ -67,42 +68,49 @@
                                         Atom           property,
                                         MetaPropValue *value);
 static void reload_prop_value          (MetaWindow    *window,
-                                        MetaPropValue *value);
+                                        MetaPropValue *value,
+                                        gboolean       initial);
 static MetaWindowPropHooks* find_hooks (MetaDisplay *display,
                                         Atom         property);
 
 
 void
 meta_window_reload_property (MetaWindow *window,
-                             Atom        property)
+                             Atom        property,
+                             gboolean    initial)
 {
-  meta_window_reload_properties (window, &property, 1);
+  meta_window_reload_properties (window, &property, 1, initial);
 }
 
 void
 meta_window_reload_properties (MetaWindow *window,
                                const Atom *properties,
-                               int         n_properties)
+                               int         n_properties,
+                               gboolean    initial)
 {
   meta_window_reload_properties_from_xwindow (window,
                                               window->xwindow,
                                               properties,
-                                              n_properties);
+                                              n_properties,
+                                              initial);
 }
 
 void
 meta_window_reload_property_from_xwindow (MetaWindow *window,
                                           Window      xwindow,
-                                          Atom        property)
+                                          Atom        property,
+                                          gboolean    initial)
 {
-  meta_window_reload_properties_from_xwindow (window, xwindow, &property, 1);
+  meta_window_reload_properties_from_xwindow (window, xwindow, &property, 1,
+                                              initial);
 }
 
 void
 meta_window_reload_properties_from_xwindow (MetaWindow *window,
                                             Window      xwindow,
                                             const Atom *properties,
-                                            int         n_properties)
+                                            int         n_properties,
+                                            gboolean    initial)
 {
   int i;
   MetaPropValue *values;
@@ -125,7 +133,7 @@
   i = 0;
   while (i < n_properties)
     {
-      reload_prop_value (window, &values[i]);
+      reload_prop_value (window, &values[i], initial);
       
       ++i;
     }
@@ -153,13 +161,14 @@
 
 static void
 reload_prop_value (MetaWindow    *window,
-                   MetaPropValue *value)
+                   MetaPropValue *value,
+                   gboolean       initial)
 {
   MetaWindowPropHooks *hooks;  
   
   hooks = find_hooks (window->display, value->atom);
   if (hooks && hooks->reload_func != NULL)
-    (* hooks->reload_func) (window, value);
+    (* hooks->reload_func) (window, value, initial);
 }
 
 static void
@@ -173,7 +182,8 @@
 
 static void
 reload_wm_client_machine (MetaWindow    *window,
-                          MetaPropValue *value)
+                          MetaPropValue *value,
+                          gboolean       initial)
 {
   g_free (window->wm_client_machine);
   window->wm_client_machine = NULL;
@@ -196,7 +206,8 @@
 
 static void
 reload_net_wm_pid (MetaWindow    *window,
-                   MetaPropValue *value)
+                   MetaPropValue *value,
+                   gboolean       initial)
 {
   if (value->type != META_PROP_VALUE_INVALID)
     {
@@ -225,7 +236,8 @@
 
 static void
 reload_net_wm_user_time (MetaWindow    *window,
-                         MetaPropValue *value)
+                         MetaPropValue *value,
+                         gboolean       initial)
 {
   if (value->type != META_PROP_VALUE_INVALID)
     {
@@ -245,7 +257,8 @@
 
 static void
 reload_net_wm_user_time_window (MetaWindow    *window,
-                                MetaPropValue *value)
+                                MetaPropValue *value,
+                                gboolean       initial)
 {
   if (value->type != META_PROP_VALUE_INVALID)
     {
@@ -293,7 +306,8 @@
           meta_window_reload_property_from_xwindow (
             window,
             window->user_time_window,
-            window->display->atom__NET_WM_USER_TIME);
+            window->display->atom__NET_WM_USER_TIME,
+            initial);
         }
     }
 }
@@ -397,7 +411,8 @@
 
 static void
 reload_net_wm_name (MetaWindow    *window,
-                    MetaPropValue *value)
+                    MetaPropValue *value,
+                    gboolean       initial)
 {
   if (value->type != META_PROP_VALUE_INVALID)
     {
@@ -411,6 +426,8 @@
     {
       set_window_title (window, NULL);
       window->using_net_wm_name = FALSE;
+      if (!initial)
+        meta_window_reload_property (window, XA_WM_NAME, FALSE);
     }
 }
 
@@ -426,7 +443,8 @@
 
 static void
 reload_wm_name (MetaWindow    *window,
-                MetaPropValue *value)
+                MetaPropValue *value,
+                gboolean       initial)
 {
   if (window->using_net_wm_name)
     {
@@ -472,7 +490,8 @@
 
 static void
 reload_net_wm_icon_name (MetaWindow    *window,
-                    MetaPropValue *value)
+                         MetaPropValue *value,
+                         gboolean       initial)
 {
   if (value->type != META_PROP_VALUE_INVALID)
     {
@@ -486,6 +505,8 @@
     {
       set_icon_title (window, NULL);
       window->using_net_wm_icon_name = FALSE;
+      if (!initial)
+        meta_window_reload_property (window, XA_WM_ICON_NAME, FALSE);
     }
 }
 
@@ -501,7 +522,8 @@
 
 static void
 reload_wm_icon_name (MetaWindow    *window,
-                     MetaPropValue *value)
+                     MetaPropValue *value,
+                     gboolean       initial)
 {
   if (window->using_net_wm_icon_name)
     {
@@ -534,7 +556,8 @@
 
 static void
 reload_net_wm_state (MetaWindow    *window,
-                     MetaPropValue *value)
+                     MetaPropValue *value,
+                     gboolean       initial)
 {
   int i;
 
@@ -603,7 +626,8 @@
 
 static void
 reload_mwm_hints (MetaWindow    *window,
-                  MetaPropValue *value)
+                  MetaPropValue *value,
+                  gboolean       initial)
 {
   MotifWmHints *hints;
 
@@ -736,7 +760,8 @@
 
 static void
 reload_wm_class (MetaWindow    *window,
-                 MetaPropValue *value)
+                 MetaPropValue *value,
+                 gboolean       initial)
 {
   if (window->res_class)
     g_free (window->res_class);
@@ -772,7 +797,8 @@
 
 static void
 reload_net_wm_desktop (MetaWindow    *window,
-                       MetaPropValue *value)
+                       MetaPropValue *value,
+                       gboolean       initial)
 {
   if (value->type != META_PROP_VALUE_INVALID)
     {
@@ -795,7 +821,8 @@
 
 static void
 reload_net_startup_id (MetaWindow    *window,
-                       MetaPropValue *value)
+                       MetaPropValue *value,
+                       gboolean       initial)
 {
   guint32 timestamp = window->net_wm_user_time;
   MetaWorkspace *workspace = NULL;
@@ -841,7 +868,8 @@
 
 static void
 reload_update_counter (MetaWindow    *window,
-                       MetaPropValue *value)
+                       MetaPropValue *value,
+                       gboolean       initial)
 {
   if (value->type != META_PROP_VALUE_INVALID)
     {
@@ -1270,7 +1298,8 @@
 
 static void
 reload_normal_hints (MetaWindow    *window,
-                     MetaPropValue *value)
+                     MetaPropValue *value,
+                     gboolean       initial)
 {
   if (value->type != META_PROP_VALUE_INVALID)
     {
@@ -1285,6 +1314,9 @@
       spew_size_hints_differences (&old_hints, &window->size_hints);
       
       meta_window_recalc_features (window);
+
+      if (!initial)
+        meta_window_queue(window, META_QUEUE_MOVE_RESIZE);
     }
 }
 
@@ -1300,7 +1332,8 @@
 
 static void
 reload_wm_protocols (MetaWindow    *window,
-                     MetaPropValue *value)
+                     MetaPropValue *value,
+                     gboolean       initial)
 {
   int i;
   
@@ -1342,7 +1375,8 @@
 
 static void
 reload_wm_hints (MetaWindow    *window,
-                 MetaPropValue *value)
+                 MetaPropValue *value,
+                 gboolean       initial)
 {
   Window old_group_leader;
   
@@ -1407,7 +1441,8 @@
 
 static void
 reload_transient_for (MetaWindow    *window,
-                      MetaPropValue *value)
+                      MetaPropValue *value,
+                      gboolean       initial)
 {
   window->xtransient_for = None;
   

Modified: trunk/src/core/window-props.h
==============================================================================
--- trunk/src/core/window-props.h	(original)
+++ trunk/src/core/window-props.h	Tue Jan 27 03:53:07 2009
@@ -43,7 +43,8 @@
  * \param property   A single X atom.
  */
 void meta_window_reload_property   (MetaWindow *window,
-                                    Atom        property);
+                                    Atom        property,
+                                    gboolean    initial);
 
 
 /**
@@ -57,7 +58,8 @@
  */
 void meta_window_reload_properties (MetaWindow *window,
                                     const Atom *properties,
-                                    int         n_properties);
+                                    int         n_properties,
+                                    gboolean    initial);
 
 /**
  * Requests the current values of a single property for a given
@@ -72,7 +74,8 @@
 void meta_window_reload_property_from_xwindow
                                    (MetaWindow *window,
                                     Window      xwindow,
-                                    Atom        property);
+                                    Atom        property,
+                                    gboolean    initial);
 
 /**
  * Requests the current values of a set of properties for a given
@@ -89,7 +92,8 @@
                                    (MetaWindow *window,
                                     Window      xwindow,
                                     const Atom *properties,
-                                    int         n_properties);
+                                    int         n_properties,
+                                    gboolean    initial);
 
 /**
  * Initialises the hooks used for the reload_propert* functions

Modified: trunk/src/core/window.c
==============================================================================
--- trunk/src/core/window.c	(original)
+++ trunk/src/core/window.c	Tue Jan 27 03:53:07 2009
@@ -595,7 +595,7 @@
   initial_props[i++] = display->atom__NET_WM_FULLSCREEN_MONITORS;
   g_assert (N_INITIAL_PROPS == i);
   
-  meta_window_reload_properties (window, initial_props, N_INITIAL_PROPS);
+  meta_window_reload_properties (window, initial_props, N_INITIAL_PROPS, TRUE);
   
   update_sm_hints (window); /* must come after transient_for */
   update_role (window);
@@ -5431,17 +5431,7 @@
 process_property_notify (MetaWindow     *window,
                          XPropertyEvent *event)
 {
-  /* First, property notifies to ignore because we shouldn't honor
-   * new values
-   */
-  if (event->atom == window->display->atom__NET_WM_STATE)
-    {
-      meta_verbose ("Property notify on %s for _NET_WM_STATE, ignoring (we should be the one who set the property in the first place)\n",
-                    window->desc);
-      return TRUE;
-    }
-
-  /* Second, property notifies we want to use.
+  /* Property notifies we want to use.
    * FIXME once we move entirely to the window-props.h framework, we
    * can just call reload on the property in the event and get rid of
    * this if-else chain.
@@ -5457,64 +5447,7 @@
       XFree (property_name);
     }
  
-  if (event->atom == XA_WM_NAME)
-    {
-      /* don't bother reloading WM_NAME if using _NET_WM_NAME already */
-      if (!window->using_net_wm_name)
-        meta_window_reload_property (window, XA_WM_NAME);
-    }
-  else if (event->atom == window->display->atom__NET_WM_NAME)
-    {
-      meta_window_reload_property (window, window->display->atom__NET_WM_NAME);
-      
-      /* if _NET_WM_NAME was unset, reload WM_NAME */
-      if (!window->using_net_wm_name)
-        meta_window_reload_property (window, XA_WM_NAME);      
-    }
-  else if (event->atom == XA_WM_ICON_NAME)
-    {
-      /* don't bother reloading WM_ICON_NAME if using _NET_WM_ICON_NAME already */
-      if (!window->using_net_wm_icon_name)
-        meta_window_reload_property (window, XA_WM_ICON_NAME);
-    }
-  else if (event->atom == window->display->atom__NET_WM_ICON_NAME)
-    {
-      meta_window_reload_property (window, window->display->atom__NET_WM_ICON_NAME);
-      
-      /* if _NET_WM_ICON_NAME was unset, reload WM_ICON_NAME */
-      if (!window->using_net_wm_icon_name)
-        meta_window_reload_property (window, XA_WM_ICON_NAME);
-    }  
-  else if (event->atom == XA_WM_NORMAL_HINTS)
-    {
-      meta_window_reload_property (window, XA_WM_NORMAL_HINTS);
-      
-      /* See if we need to constrain current size */
-      meta_window_queue(window, META_QUEUE_MOVE_RESIZE);
-    }
-  else if (event->atom == window->display->atom_WM_PROTOCOLS)
-    {
-      meta_window_reload_property (window, window->display->atom_WM_PROTOCOLS);
-    }
-  else if (event->atom == XA_WM_HINTS)
-    {
-      meta_window_reload_property (window, XA_WM_HINTS);
-    }
-  else if (event->atom == window->display->atom__MOTIF_WM_HINTS)
-    {
-      meta_window_reload_property (window,
-                                   window->display->atom__MOTIF_WM_HINTS);
-    }
-  else if (event->atom == XA_WM_CLASS)
-    {
-      meta_window_reload_property (window, XA_WM_CLASS);
-    }
-  else if (event->atom == XA_WM_TRANSIENT_FOR)
-    {
-      meta_window_reload_property (window, XA_WM_TRANSIENT_FOR);
-    }
-  else if (event->atom ==
-           window->display->atom_WM_WINDOW_ROLE)
+  if (event->atom == window->display->atom_WM_WINDOW_ROLE)
     {
       update_role (window);
     }
@@ -5526,6 +5459,11 @@
       meta_warning ("Broken client! Window %s changed client leader window or SM client ID\n", window->desc);
     }
   else if (event->atom ==
+           window->display->atom__NET_WM_STATE)
+    {
+      meta_verbose ("Ignoring _NET_WM_STATE: we should be the one who set the property in the first place\n");
+    }
+  else if (event->atom ==
            window->display->atom__NET_WM_WINDOW_TYPE)
     {
       update_net_wm_type (window);
@@ -5549,16 +5487,6 @@
     {
       meta_window_update_struts (window);
     }
-  else if (event->atom == window->display->atom__NET_STARTUP_ID)
-    {
-      meta_window_reload_property (window,
-                                   window->display->atom__NET_STARTUP_ID);
-    }
-  else if (event->atom == window->display->atom__NET_WM_SYNC_REQUEST_COUNTER)
-    {
-      meta_window_reload_property (window,
-                                   window->display->atom__NET_WM_SYNC_REQUEST_COUNTER);
-    }
   else if (event->atom == window->display->atom__NET_WM_USER_TIME)
     {
       Window xid;
@@ -5571,8 +5499,10 @@
         xid = window->xwindow;
       meta_window_reload_property_from_xwindow (window,
                                                 xid,
-                                                atom__NET_WM_USER_TIME);
+                                                atom__NET_WM_USER_TIME, FALSE);
     }
+  else
+    meta_window_reload_property (window, event->atom, FALSE);
 
   return TRUE;
 }



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