? wm-tester/test-size-hints
Index: display.c
===================================================================
RCS file: /cvs/gnome/metacity/src/display.c,v
retrieving revision 1.206
diff -p -u -r1.206 display.c
--- display.c	30 Nov 2003 03:30:27 -0000	1.206
+++ display.c	13 Dec 2003 18:16:25 -0000
@@ -274,7 +274,8 @@ meta_display_open (const char *name)
     "_METACITY_SENTINEL",
     "_NET_WM_STRUT_PARTIAL",
     "_NET_WM_ACTION_FULLSCREEN",
-    "_NET_WM_ACTION_MINIMIZE"
+    "_NET_WM_ACTION_MINIMIZE",
+    "_NET_WM_USER_TIME"
   };
   Atom atoms[G_N_ELEMENTS(atom_names)];
   
@@ -419,6 +420,7 @@ meta_display_open (const char *name)
   display->atom_net_wm_strut_partial = atoms[80];
   display->atom_net_wm_action_fullscreen = atoms[81];
   display->atom_net_wm_action_minimize = atoms[82];
+  display->atom_net_wm_user_time = atoms[83];
   
   display->prop_hooks = NULL;
   meta_display_init_window_prop_hooks (display);
@@ -1168,7 +1170,8 @@ event_callback (XEvent   *event,
   Window modified;
   gboolean frame_was_receiver;
   gboolean filter_out_event;
-  
+  Time event_time;
+ 
   display = data;
   
   if (dump_events)
@@ -1321,7 +1324,15 @@ event_callback (XEvent   *event,
   meta_compositor_process_event (display->compositor,
                                  event,
                                  window);
-  
+
+  if (window && 
+      (event->type == KeyPress || 
+       event->type == ButtonPress) &&
+      (CurrentTime != 
+       (event_time = event_get_time (display, event)))) {
+    window->net_wm_user_time = event_time;
+  }
+
   switch (event->type)
     {
     case KeyPress:
@@ -1867,9 +1878,10 @@ event_callback (XEvent   *event,
       {
         MetaGroup *group;
         MetaScreen *screen;
-        
-        if (window && !frame_was_receiver)
+
+        if (window && !frame_was_receiver) {
           meta_window_property_notify (window, event);
+	}
 
         group = meta_display_lookup_group (display,
                                            event->xproperty.window);
Index: display.h
===================================================================
RCS file: /cvs/gnome/metacity/src/display.h,v
retrieving revision 1.112
diff -p -u -r1.112 display.h
--- display.h	24 Nov 2003 18:09:47 -0000	1.112
+++ display.h	13 Dec 2003 18:16:26 -0000
@@ -172,6 +172,7 @@ struct _MetaDisplay
   Atom atom_gnome_panel_action_run_dialog;
   Atom atom_metacity_sentinel;
   Atom atom_net_wm_strut_partial;
+  Atom atom_net_wm_user_time;
   
   /* This is the actual window from focus events,
    * not the one we last set
Index: screen.c
===================================================================
RCS file: /cvs/gnome/metacity/src/screen.c,v
retrieving revision 1.117
diff -p -u -r1.117 screen.c
--- screen.c	30 Nov 2003 03:30:27 -0000	1.117
+++ screen.c	13 Dec 2003 18:16:30 -0000
@@ -82,7 +82,7 @@ set_wm_check_hint (MetaScreen *screen)
 static int
 set_supported_hint (MetaScreen *screen)
 {
-#define N_SUPPORTED 68
+#define N_SUPPORTED 69
   Atom atoms[N_SUPPORTED];
   
   atoms[0] = screen->display->atom_net_wm_name;
@@ -153,6 +153,7 @@ set_supported_hint (MetaScreen *screen)
   atoms[65] = screen->display->atom_net_wm_strut_partial;
   atoms[66] = screen->display->atom_net_wm_action_fullscreen;
   atoms[67] = screen->display->atom_net_wm_action_minimize;
+  atoms[68] = screen->display->atom_net_wm_user_time;
   
   XChangeProperty (screen->display->xdisplay, screen->xroot,
                    screen->display->atom_net_supported,
Index: window-props.c
===================================================================
RCS file: /cvs/gnome/metacity/src/window-props.c,v
retrieving revision 1.13
diff -p -u -r1.13 window-props.c
--- window-props.c	26 Jun 2003 03:09:37 -0000	1.13
+++ window-props.c	13 Dec 2003 18:16:32 -0000
@@ -171,6 +171,33 @@ reload_net_wm_pid (MetaWindow    *window
 }
 
 static void
+init_net_wm_user_time (MetaDisplay   *display,
+                       Atom           property,
+                       MetaPropValue *value)
+{
+  value->type = META_PROP_VALUE_CARDINAL;
+  value->atom = display->atom_net_wm_user_time;
+}
+
+static void
+reload_net_wm_user_time (MetaWindow    *window,
+                         MetaPropValue *value)
+{
+  if (value->type != META_PROP_VALUE_INVALID)
+    {
+      gulong cardinal = (int) value->v.cardinal;
+      
+      if (cardinal <= 0)
+        meta_warning (_("Application set a bogus _NET_WM_USER_TIME %ld\n"),
+                      cardinal);
+      else
+        {
+          window->net_wm_user_time = cardinal;
+        }
+    }
+}
+
+static void
 set_window_title (MetaWindow *window,
                   const char *title)
 {
@@ -814,7 +841,7 @@ reload_wm_hints (MetaWindow    *window,
 
 
 
-#define N_HOOKS 23
+#define N_HOOKS 24
 
 void
 meta_display_init_window_prop_hooks (MetaDisplay *display)
@@ -844,6 +871,16 @@ meta_display_init_window_prop_hooks (Met
   hooks[i].reload_func = reload_net_wm_pid;
   ++i;
 
+  hooks[i].property = display->atom_net_wm_user_time;
+  hooks[i].init_func = init_net_wm_user_time;
+  hooks[i].reload_func = reload_net_wm_user_time;
+  ++i;
+
+  hooks[i].property = display->atom_net_wm_user_time;
+  hooks[i].init_func = init_net_wm_user_time;
+  hooks[i].reload_func = reload_net_wm_user_time;
+  ++i;
+
   hooks[i].property = display->atom_net_wm_name;
   hooks[i].init_func = init_net_wm_name;
   hooks[i].reload_func = reload_net_wm_name;
Index: window.c
===================================================================
RCS file: /cvs/gnome/metacity/src/window.c,v
retrieving revision 1.315
diff -p -u -r1.315 window.c
--- window.c	13 Dec 2003 03:58:55 -0000	1.315
+++ window.c	13 Dec 2003 18:16:44 -0000
@@ -582,6 +582,17 @@ meta_window_new_with_attrs (MetaDisplay 
   meta_display_grab_window_buttons (window->display, window->xwindow);
   meta_display_grab_focus_window_button (window->display, window);
   
+  if (window->type == META_WINDOW_DESKTOP ||
+      window->type == META_WINDOW_DOCK)
+    {
+      /* Change the default, but don't enforce this if the user
+       * focuses the dock/desktop and unsticks it using key shortcuts.
+       * Need to set this before adding to the workspaces so the MRU
+       * lists will be updated.
+       */
+      window->on_all_workspaces = TRUE;
+    }
+
   /* For the workspace, first honor hints,
    * if that fails put transients with parents,
    * otherwise put window on active space
@@ -595,8 +606,11 @@ meta_window_new_with_attrs (MetaDisplay 
                       "Window %s is initially on all spaces\n",
                       window->desc);
           
-          meta_workspace_add_window (window->screen->active_workspace, window);
+	  /* need to set on_all_workspaces first so that it will be
+	   * added to all the MRU lists
+	   */
           window->on_all_workspaces = TRUE;
+          meta_workspace_add_window (window->screen->active_workspace, window);
         }
       else
         {
@@ -636,6 +650,8 @@ meta_window_new_with_attrs (MetaDisplay 
           tmp_list = parent->workspaces;
           while (tmp_list != NULL)
             {
+	      /* this will implicitly add to the appropriate MRU lists
+	       */
               meta_workspace_add_window (tmp_list->data, window);
               
               tmp_list = tmp_list->next;
@@ -654,16 +670,6 @@ meta_window_new_with_attrs (MetaDisplay 
       meta_workspace_add_window (space, window);
     }
   
-  if (window->type == META_WINDOW_DESKTOP ||
-      window->type == META_WINDOW_DOCK)
-    {
-      /* Change the default, but don't enforce this if
-       * the user focuses the dock/desktop and unsticks it
-       * using key shortcuts
-       */
-      window->on_all_workspaces = TRUE;
-    }
-
   /* for the various on_all_workspaces = TRUE possible above */
   meta_window_set_current_workspace_hint (window);
   
@@ -4317,6 +4323,20 @@ process_property_notify (MetaWindow     
       meta_window_reload_property (window,
                                    window->display->atom_metacity_update_counter);
     }
+  else if (event->atom == window->display->atom_net_wm_user_time)
+    {
+      meta_verbose ("Property notify on %s for _NET_WM_USER_TIME\n", window->desc);
+      
+      meta_window_reload_property (window,
+                                   window->display->atom_net_wm_user_time);
+    }
+  else if (event->atom == window->display->atom_net_wm_user_time)
+    {      
+      meta_verbose ("Property notify on %s for _NET_WM_USER_TIME\n", window->desc);
+      
+      meta_window_reload_property (window,
+                                   window->display->atom_net_wm_user_time);
+    }
   
   return TRUE;
 }
Index: window.h
===================================================================
RCS file: /cvs/gnome/metacity/src/window.h,v
retrieving revision 1.97
diff -p -u -r1.97 window.h
--- window.h	21 Nov 2003 02:32:05 -0000	1.97
+++ window.h	13 Dec 2003 18:16:45 -0000
@@ -242,6 +242,11 @@ struct _MetaWindow
 
   /* if TRUE we have a grab on the focus click buttons */
   guint have_focus_click_grab : 1;
+
+  /* set to the most recent user-interaction event timestamp that we
+   * know about for this window
+   */
+  Time net_wm_user_time;
   
 #ifdef HAVE_XSYNC
   /* XSync update counter */
Index: workspace.c
===================================================================
RCS file: /cvs/gnome/metacity/src/workspace.c,v
retrieving revision 1.48
diff -p -u -r1.48 workspace.c
--- workspace.c	13 Dec 2003 03:58:55 -0000	1.48
+++ workspace.c	13 Dec 2003 18:16:46 -0000
@@ -112,11 +112,30 @@ meta_workspace_add_window (MetaWorkspace
 {
   g_return_if_fail (!meta_workspace_contains_window (workspace, window));
   
+  /* If the window is on all workspaces, we want to add it to all mru
+   * lists, otherwise just add it to this workspaces mru list
+   */
+  if (window->on_all_workspaces) 
+    {
+      if (g_list_length (window->workspaces) == 0)
+	{
+	  GList* tmp = window->screen->workspaces;
+	  while (tmp)
+	    {
+	      MetaWorkspace* work = (MetaWorkspace*) tmp->data;
+	      if (!g_list_find (work->mru_list, window))
+		work->mru_list = g_list_append (work->mru_list, window);
+
+	      tmp = tmp->next;
+	    }
+	}
+    }
+  else if (!g_list_find (workspace->mru_list, window))
+    workspace->mru_list = g_list_prepend (workspace->mru_list, window);
+
   workspace->windows = g_list_prepend (workspace->windows, window);
   window->workspaces = g_list_prepend (window->workspaces, workspace);
 
-  workspace->mru_list = g_list_append (workspace->mru_list, window);
-
   meta_window_set_current_workspace_hint (window);
   
   meta_window_queue_calc_showing (window);
@@ -142,7 +161,27 @@ meta_workspace_remove_window (MetaWorksp
 
   workspace->windows = g_list_remove (workspace->windows, window);
   window->workspaces = g_list_remove (window->workspaces, workspace);
-  workspace->mru_list = g_list_remove (workspace->mru_list, window);
+
+  /* If the window is on all workspaces, we don't want to remove it
+   * from the MRU list unless this causes it to be removed from all 
+   * workspaces
+   */
+  if (window->on_all_workspaces) 
+    {
+      if (g_list_length (window->workspaces) == 0)
+	{
+	  GList* tmp = window->screen->workspaces;
+	  while (tmp)
+	    {
+	      MetaWorkspace* work = (MetaWorkspace*) tmp->data;
+	      work->mru_list = g_list_remove (work->mru_list, window);
+
+	      tmp = tmp->next;
+	    }
+	}
+    }
+  else
+      workspace->mru_list = g_list_remove (workspace->mru_list, window);
 
   meta_window_set_current_workspace_hint (window);
   
