Blob Blame History Raw
--- metacity-2.16.0/src/display.h.currenttime-fixes	2006-08-27 17:49:39.000000000 -0400
+++ metacity-2.16.0/src/display.h	2006-09-21 14:48:00.000000000 -0400
@@ -388,7 +388,8 @@
   )
 
 gboolean      meta_display_open                (void);
-void          meta_display_close               (MetaDisplay *display);
+void          meta_display_close               (MetaDisplay *display,
+                                                guint32      timestamp);
 MetaScreen*   meta_display_screen_for_root     (MetaDisplay *display,
                                                 Window       xroot);
 MetaScreen*   meta_display_screen_for_x_screen (MetaDisplay *display,
@@ -399,10 +400,12 @@
 void          meta_display_ungrab              (MetaDisplay *display);
 
 void          meta_display_unmanage_screen     (MetaDisplay *display,
-                                                MetaScreen  *screen);
+                                                MetaScreen  *screen,
+                                                guint32      timestamp);
 
 void          meta_display_unmanage_windows_for_screen (MetaDisplay *display,
-                                                        MetaScreen  *screen);
+                                                        MetaScreen  *screen,
+                                                        guint32      timestamp);
 
 /* A given MetaWindow may have various X windows that "belong"
  * to it, such as the frame window.
--- metacity-2.16.0/src/frames.c.currenttime-fixes	2006-08-27 17:49:41.000000000 -0400
+++ metacity-2.16.0/src/frames.c	2006-09-21 14:48:00.000000000 -0400
@@ -1254,10 +1254,12 @@
               {
                 if (flags & META_FRAME_SHADED)
                   meta_core_unshade (gdk_display,
-                                     frame->xwindow);
+                                     frame->xwindow,
+                                     event->time);
                 else
                   meta_core_shade (gdk_display,
-                                   frame->xwindow);
+                                   frame->xwindow,
+                                   event->time);
               }
           }
           break;          
--- metacity-2.16.0/src/screen.h.currenttime-fixes	2006-08-27 17:49:46.000000000 -0400
+++ metacity-2.16.0/src/screen.h	2006-09-21 14:51:55.000000000 -0400
@@ -123,7 +123,8 @@
 MetaScreen*   meta_screen_new                 (MetaDisplay                *display,
                                                int                         number,
                                                Time                        timestamp);
-void          meta_screen_free                (MetaScreen                 *screen);
+void          meta_screen_free                (MetaScreen                 *screen,
+					       guint32			   timestamp);
 void          meta_screen_manage_all_windows  (MetaScreen                 *screen);
 MetaScreen*   meta_screen_for_x_screen        (Screen                     *xscreen);
 void          meta_screen_foreach_window      (MetaScreen                 *screen,
--- metacity-2.16.0/src/window.c.currenttime-fixes	2006-08-28 18:05:39.000000000 -0400
+++ metacity-2.16.0/src/window.c	2006-09-21 14:48:00.000000000 -0400
@@ -910,7 +910,8 @@
 }
 
 void
-meta_window_free (MetaWindow  *window)
+meta_window_free (MetaWindow  *window,
+                  guint32      timestamp)
 {
   GList *tmp;
   
@@ -963,7 +964,9 @@
       meta_topic (META_DEBUG_FOCUS,
                   "Focusing default window since we're unmanaging %s\n",
                   window->desc);
-      meta_workspace_focus_default_window (window->screen->active_workspace, window, meta_display_get_current_time_roundtrip (window->display));
+      meta_workspace_focus_default_window (window->screen->active_workspace,
+                                           window,
+                                           timestamp);
     }
   else if (window->display->expected_focus_window == window)
     {
@@ -971,7 +974,9 @@
                   "Focusing default window since expected focus window freed %s\n",
                   window->desc);
       window->display->expected_focus_window = NULL;
-      meta_workspace_focus_default_window (window->screen->active_workspace, window, meta_display_get_current_time_roundtrip (window->display));
+      meta_workspace_focus_default_window (window->screen->active_workspace,
+                                           window,
+                                           timestamp);
     }
   else
     {
@@ -992,8 +997,7 @@
     }
   
   if (window->display->grab_window == window)
-    meta_display_end_grab_op (window->display,
-                              meta_display_get_current_time (window->display));
+    meta_display_end_grab_op (window->display, timestamp);
 
   g_assert (window->display->grab_window != window);
   
@@ -1338,14 +1342,20 @@
 		 gpointer	   data)
 {
   MetaWindow *window = data;
+  /* FIXME: It really sucks to put timestamp pinging here; it'd
+   * probably make more sense in implement_showing() so that it's at
+   * least not duplicated in meta_window_show; but since
+   * finish_minimize is a callback making things just slightly icky, I
+   * haven't done that yet.
+   */
+  guint32 timestamp = meta_display_get_current_time_roundtrip (window->display);
   
   meta_window_hide (window);
   if (window->has_focus)
     {
-      meta_workspace_focus_default_window
-	(window->screen->active_workspace,
-	 window,
-	 meta_display_get_current_time_roundtrip (window->display));
+      meta_workspace_focus_default_window (window->screen->active_workspace,
+                                           window, 
+                                           timestamp);
     }
 }
 
@@ -1373,11 +1383,11 @@
       if (on_workspace && window->minimized && window->mapped &&
           !meta_prefs_get_reduced_resources ())
         {
-	  MetaRectangle icon_rect, window_rect;
-	  gboolean result;
-	  
-	  /* Check if the window has an icon geometry */
-	  result = meta_window_get_icon_geometry (window, &icon_rect);
+          MetaRectangle icon_rect, window_rect;
+          gboolean result;
+          
+          /* Check if the window has an icon geometry */
+          result = meta_window_get_icon_geometry (window, &icon_rect);
           
           if (!result)
             {
@@ -1392,16 +1402,16 @@
 
           meta_window_get_outer_rect (window, &window_rect);
 
-	  meta_effect_run_minimize (window,
-				    &window_rect,
-				    &icon_rect,
-				    finish_minimize,
-				    window);
-	}
+          meta_effect_run_minimize (window,
+                                    &window_rect,
+                                    &icon_rect,
+                                    finish_minimize,
+                                    window);
+        }
       else
-	{
-	  finish_minimize (NULL, window);
-	}
+        {
+          finish_minimize (NULL, window);
+        }
     }
   else
     {
@@ -1851,6 +1861,13 @@
   gboolean place_on_top_on_map;
   gboolean needs_stacking_adjustment;
   MetaWindow *focus_window;
+  guint32     timestamp;
+
+  /* FIXME: It really sucks to put timestamp pinging here; it'd
+   * probably make more sense in implement_showing() so that it's at
+   * least not duplicated in finish_minimize.  *shrug*
+   */
+  timestamp = meta_display_get_current_time_roundtrip (window->display);
 
   meta_topic (META_DEBUG_WINDOW_STATE,
               "Showing window %s, shaded: %d iconic: %d placed: %d\n",
@@ -1884,7 +1901,9 @@
                       "ancestor.\n",
                       focus_window->desc, window->desc);
 
-          meta_display_focus_the_no_focus_window (window->display, window->screen, meta_display_get_current_time_roundtrip (window->display));
+          meta_display_focus_the_no_focus_window (window->display,
+                                                  window->screen,
+                                                  timestamp);
         }
       else
         {
@@ -2000,8 +2019,7 @@
       window->showing_for_first_time = FALSE;
       if (takes_focus_on_map)
         {                
-          meta_window_focus (window,
-                             meta_display_get_current_time_roundtrip (window->display));
+          meta_window_focus (window, timestamp);
         }
       else
         {
@@ -2251,7 +2269,14 @@
       (maximize_vertically   && !window->maximized_vertically))
     {
       if (window->shaded && maximize_vertically)
-        meta_window_unshade (window);
+        {
+          /* Shading sucks anyway; I'm not adding a timestamp argument
+           * to this function just for this niche usage & corner case.
+           */
+          guint32 timestamp = 
+            meta_display_get_current_time_roundtrip (window->display);
+          meta_window_unshade (window, timestamp);
+        }
       
       /* if the window hasn't been placed yet, we'll maximize it then
        */
@@ -2374,7 +2399,14 @@
                   "Fullscreening %s\n", window->desc);
 
       if (window->shaded)
-        meta_window_unshade (window);
+        {
+          /* Shading sucks anyway; I'm not adding a timestamp argument
+           * to this function just for this niche usage & corner case.
+           */
+          guint32 timestamp = 
+            meta_display_get_current_time_roundtrip (window->display);
+          meta_window_unshade (window, timestamp);
+        }
 
       meta_window_save_rect (window);
       
@@ -2428,7 +2460,8 @@
 }
 
 void
-meta_window_shade (MetaWindow  *window)
+meta_window_shade (MetaWindow  *window,
+                   guint32      timestamp)
 {
   meta_topic (META_DEBUG_WINDOW_OPS,
               "Shading %s\n", window->desc);
@@ -2469,15 +2502,15 @@
       meta_topic (META_DEBUG_FOCUS,
                   "Re-focusing window %s after shading it\n",
                   window->desc);
-      meta_window_focus (window,
-                         meta_display_get_current_time_roundtrip (window->display));
+      meta_window_focus (window, timestamp);
       
       set_net_wm_state (window);
     }
 }
 
 void
-meta_window_unshade (MetaWindow  *window)
+meta_window_unshade (MetaWindow  *window,
+                     guint32      timestamp)
 {
   meta_topic (META_DEBUG_WINDOW_OPS,
               "Unshading %s\n", window->desc);
@@ -2491,8 +2524,7 @@
       meta_topic (META_DEBUG_FOCUS,
                   "Focusing window %s after unshading it\n",
                   window->desc);
-      meta_window_focus (window,
-                         meta_display_get_current_time_roundtrip (window->display));
+      meta_window_focus (window, timestamp);
 
       set_net_wm_state (window);
     }
@@ -2546,11 +2578,12 @@
     }
 
   /* For those stupid pagers, get a valid timestamp and show a warning */  
-  if (timestamp == 0) {
-    meta_warning ("meta_window_activate called by a pager with a 0 timestamp; "
-                  "the pager needs to be fixed.\n");
-    timestamp = meta_display_get_current_time_roundtrip (window->display);
-  }
+  if (timestamp == 0)
+    {
+      meta_warning ("meta_window_activate called by a pager with a 0 timestamp; "
+                    "the pager needs to be fixed.\n");
+      timestamp = meta_display_get_current_time_roundtrip (window->display);
+    }
 
   meta_window_set_user_time (window, timestamp);
 
@@ -2564,7 +2597,7 @@
     meta_window_change_workspace (window, workspace);
   
   if (window->shaded)
-    meta_window_unshade (window);
+    meta_window_unshade (window, timestamp);
 
   unminimize_window_and_all_transient_parents (window);
 
@@ -2762,6 +2795,11 @@
   ev.message_type = window->display->atom_wm_protocols;
   ev.format = 32;
   ev.data.l[0] = window->display->atom_net_wm_sync_request;
+  /* FIXME: meta_display_get_current_time() is bad, but since calls
+   * come from meta_window_move_resize_internal (which in turn come
+   * from all over), I'm not sure what we can do to fix it.  Do we
+   * want to use _roundtrip, though?
+   */
   ev.data.l[1] = meta_display_get_current_time (window->display);
   ev.data.l[2] = XSyncValueLow32 (value);
   ev.data.l[3] = XSyncValueHigh32 (value);
@@ -4416,7 +4454,13 @@
       if (event->xclient.data.l[0] != 0)
 	timestamp = event->xclient.data.l[0];
       else
-	timestamp = meta_display_get_current_time (window->display);
+        {
+          meta_warning ("Receiving a NET_CLOSE_WINDOW message for %s without "
+                        "a timestamp!  This means some buggy (outdated) "
+                        "application is on the loose!\n",
+                        window->desc);
+          timestamp = meta_display_get_current_time (window->display);
+        }
       
       meta_window_delete (window, timestamp);
 
@@ -4496,13 +4540,20 @@
           second == display->atom_net_wm_state_shaded)
         {
           gboolean shade;
+          guint32 timestamp;
+
+          /* Stupid protocol has no timestamp; of course, shading
+           * sucks anyway so who really cares that we're forced to do
+           * a roundtrip here? 
+           */
+          timestamp = meta_display_get_current_time_roundtrip (window->display);
 
           shade = (action == _NET_WM_STATE_ADD ||
                    (action == _NET_WM_STATE_TOGGLE && !window->shaded));
           if (shade && window->has_shade_func)
-            meta_window_shade (window);
+            meta_window_shade (window, timestamp);
           else
-            meta_window_unshade (window);
+            meta_window_unshade (window, timestamp);
         }
 
       if (first == display->atom_net_wm_state_fullscreen ||
@@ -4648,12 +4699,18 @@
       int action;
       MetaGrabOp op;
       int button;
+      guint32 timestamp;
       
       x_root = event->xclient.data.l[0];
       y_root = event->xclient.data.l[1];
       action = event->xclient.data.l[2];
       button = event->xclient.data.l[3];
 
+      /* FIXME: What a braindead protocol; no timestamp?!? */
+      timestamp = meta_display_get_current_time_roundtrip (display);
+      meta_warning ("Received a _NET_WM_MOVERESIZE message for %s; these "
+                    "messages lack timestamps and therefore suck.\n",
+                    window->desc);
       meta_topic (META_DEBUG_WINDOW_OPS,
                   "Received _NET_WM_MOVERESIZE message on %s, %d,%d action = %d, button %d\n",
                   window->desc,
@@ -4703,10 +4760,7 @@
           ((window->has_move_func && op == META_GRAB_OP_KEYBOARD_MOVING) ||
            (window->has_resize_func && op == META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN)))
         {
-
-          meta_window_begin_grab_op (window,
-                                     op,
-                                     meta_display_get_current_time (window->display));
+          meta_window_begin_grab_op (window, op, timestamp);
         }
       else if (op != META_GRAB_OP_NONE &&
                ((window->has_move_func && op == META_GRAB_OP_MOVING) ||
@@ -4756,7 +4810,7 @@
                                           op,
                                           FALSE, 0 /* event_serial */,
                                           button, 0,
-                                          meta_display_get_current_time (window->display),
+                                          timestamp,
                                           x_root,
                                           y_root);
             }
@@ -4780,8 +4834,13 @@
         source_indication = META_CLIENT_TYPE_UNKNOWN;
 
       if (timestamp == 0)
-        /* Client using older EWMH _NET_ACTIVE_WINDOW without a timestamp */
-        timestamp = meta_display_get_current_time (window->display);
+        {
+          /* Client using older EWMH _NET_ACTIVE_WINDOW without a timestamp */
+          meta_warning ("Buggy client sent a _NET_ACTIVE_WINDOW message with a "
+                        "timestamp of 0 for %s\n",
+                        window->desc);
+          timestamp = meta_display_get_current_time (display);
+        }
 
       window_activate (window, timestamp, source_indication, NULL);
       return TRUE;
@@ -6085,11 +6144,11 @@
           break;
 
         case META_MENU_OP_UNSHADE:
-          meta_window_unshade (window);
+          meta_window_unshade (window, timestamp);
           break;
       
         case META_MENU_OP_SHADE:
-          meta_window_shade (window);
+          meta_window_shade (window, timestamp);
           break;
       
         case META_MENU_OP_MOVE_LEFT:
@@ -6136,13 +6195,13 @@
         case META_MENU_OP_MOVE:
           meta_window_begin_grab_op (window,
                                      META_GRAB_OP_KEYBOARD_MOVING,
-                                     meta_display_get_current_time (window->display));
+                                     timestamp);
           break;
 
         case META_MENU_OP_RESIZE:
           meta_window_begin_grab_op (window,
                                      META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN,
-                                     meta_display_get_current_time (window->display));
+                                     timestamp);
           break;
 
         case META_MENU_OP_RECOVER:
@@ -6694,7 +6753,7 @@
 update_resize (MetaWindow *window,
                gboolean    snap,
                int x, int y,
-	       gboolean force)
+               gboolean force)
 {
   int dx, dy;
   int new_w, new_h;
@@ -7037,7 +7096,7 @@
                          window->display->grab_last_user_action_was_snap,
                          window->display->grab_latest_motion_x,
                          window->display->grab_latest_motion_y,
-			 TRUE);
+                         TRUE);
           break;
           
         default:
@@ -7587,12 +7646,15 @@
 
   if (update_cursor)
     {
+      guint32 timestamp;
+      /* FIXME: Using CurrentTime is really bad mojo */
+      timestamp = CurrentTime;
       meta_display_set_grab_op_cursor (window->display,
                                        NULL,
                                        window->display->grab_op,
                                        TRUE,
                                        window->display->grab_xwindow,
-                                       meta_display_get_current_time (window->display));
+                                       timestamp);
     }
 }
 
--- metacity-2.16.0/src/core.c.currenttime-fixes	2006-08-27 17:49:38.000000000 -0400
+++ metacity-2.16.0/src/core.c	2006-09-21 14:48:00.000000000 -0400
@@ -339,20 +339,22 @@
 
 void
 meta_core_unshade (Display *xdisplay,
-                   Window   frame_xwindow)
+                   Window   frame_xwindow,
+                   guint32  timestamp)
 {
   MetaWindow *window = get_window (xdisplay, frame_xwindow);
 
-  meta_window_unshade (window);
+  meta_window_unshade (window, timestamp);
 }
 
 void
 meta_core_shade (Display *xdisplay,
-                 Window   frame_xwindow)
+                 Window   frame_xwindow,
+                 guint32  timestamp)
 {
   MetaWindow *window = get_window (xdisplay, frame_xwindow);
   
-  meta_window_shade (window);
+  meta_window_shade (window, timestamp);
 }
 
 void
--- metacity-2.16.0/src/window.h.currenttime-fixes	2006-08-27 17:49:56.000000000 -0400
+++ metacity-2.16.0/src/window.h	2006-09-21 14:48:00.000000000 -0400
@@ -381,7 +381,8 @@
                                             Window       xwindow,
                                             gboolean     must_be_viewable,
                                             XWindowAttributes *attrs);
-void        meta_window_free               (MetaWindow  *window);
+void        meta_window_free               (MetaWindow  *window,
+                                            guint32      timestamp);
 void        meta_window_calc_showing       (MetaWindow  *window);
 void        meta_window_queue_calc_showing (MetaWindow  *window);
 void        meta_window_minimize           (MetaWindow  *window);
@@ -395,8 +396,10 @@
                                             MetaMaximizeFlags  directions);
 void        meta_window_make_above         (MetaWindow  *window);
 void        meta_window_unmake_above       (MetaWindow  *window);
-void        meta_window_shade              (MetaWindow  *window);
-void        meta_window_unshade            (MetaWindow  *window);
+void        meta_window_shade              (MetaWindow  *window,
+                                            guint32      timestamp);
+void        meta_window_unshade            (MetaWindow  *window,
+                                            guint32      timestamp);
 void        meta_window_change_workspace   (MetaWindow  *window,
                                             MetaWorkspace *workspace);
 void        meta_window_stick              (MetaWindow  *window);
--- metacity-2.16.0/src/core.h.currenttime-fixes	2006-08-27 17:49:38.000000000 -0400
+++ metacity-2.16.0/src/core.h	2006-09-21 14:48:00.000000000 -0400
@@ -95,9 +95,11 @@
                                  Window   frame_xwindow,
                                  guint32  timestamp);
 void meta_core_unshade          (Display *xdisplay,
-                                 Window   frame_xwindow);
+                                 Window   frame_xwindow,
+                                 guint32  timestamp);
 void meta_core_shade            (Display *xdisplay,
-                                 Window   frame_xwindow);
+                                 Window   frame_xwindow,
+                                 guint32  timestamp);
 void meta_core_unstick          (Display *xdisplay,
                                  Window   frame_xwindow);
 void meta_core_stick            (Display *xdisplay,
--- metacity-2.16.0/src/keybindings.c.currenttime-fixes	2006-09-21 14:48:00.000000000 -0400
+++ metacity-2.16.0/src/keybindings.c	2006-09-21 14:48:00.000000000 -0400
@@ -3300,9 +3300,9 @@
   if (window)
     {
       if (window->shaded)
-        meta_window_unshade (window);
+        meta_window_unshade (window, event->xkey.time);
       else if (window->has_shade_func)
-        meta_window_shade (window);
+        meta_window_shade (window, event->xkey.time);
     }
 }
 
--- metacity-2.16.0/src/main.c.currenttime-fixes	2006-08-27 17:49:43.000000000 -0400
+++ metacity-2.16.0/src/main.c	2006-09-21 14:48:00.000000000 -0400
@@ -399,7 +399,9 @@
     tmp = displays;
     while (tmp != NULL)
       {
-        meta_display_close (tmp->data);
+        guint32 timestamp;
+        timestamp = CurrentTime; /* I doubt correct timestamps matter here */
+        meta_display_close (tmp->data, timestamp);
         tmp = tmp->next;
       }
     g_slist_free (displays);
--- metacity-2.16.0/src/display.c.currenttime-fixes	2006-09-21 14:48:00.000000000 -0400
+++ metacity-2.16.0/src/display.c	2006-09-21 14:48:00.000000000 -0400
@@ -705,7 +705,7 @@
       /* This would typically happen because all the screens already
        * have window managers.
        */
-      meta_display_close (display);
+      meta_display_close (display, timestamp);
       return FALSE;
     }
  
@@ -840,7 +840,8 @@
 }
 
 void
-meta_display_close (MetaDisplay *display)
+meta_display_close (MetaDisplay *display,
+                    guint32      timestamp)
 {
   GSList *tmp;
 
@@ -866,7 +867,7 @@
   while (tmp != NULL)
     {
       MetaScreen *screen = tmp->data;
-      meta_screen_free (screen);
+      meta_screen_free (screen, timestamp);
       tmp = tmp->next;
     }
 
@@ -1998,9 +1999,16 @@
     case DestroyNotify:
       if (window)
         {
+          /* FIXME: It sucks that DestroyNotify events don't come with
+           * a timestamp; could we do something better here?  Maybe X
+           * will change one day?
+           */
+          guint32 timestamp;
+          timestamp = meta_display_get_current_time_roundtrip (display);
+
           if (display->grab_op != META_GRAB_OP_NONE &&
               display->grab_window == window)
-            meta_display_end_grab_op (display, CurrentTime);
+            meta_display_end_grab_op (display, timestamp);
           
           if (frame_was_receiver)
             {
@@ -2012,7 +2020,8 @@
             }
           else
             {
-              meta_window_free (window); /* Unmanage destroyed window */
+              /* Unmanage destroyed window */
+              meta_window_free (window, timestamp);
               window = NULL;
             }
         }
@@ -2020,10 +2029,17 @@
     case UnmapNotify:
       if (window)
         {
+          /* FIXME: It sucks that UnmapNotify events don't come with
+           * a timestamp; could we do something better here?  Maybe X
+           * will change one day?
+           */
+          guint32 timestamp;
+          timestamp = meta_display_get_current_time_roundtrip (display);
+
           if (display->grab_op != META_GRAB_OP_NONE &&
               display->grab_window == window &&
               ((window->frame == NULL) || !window->frame->mapped))
-            meta_display_end_grab_op (display, CurrentTime);      
+            meta_display_end_grab_op (display, timestamp);
       
           if (!frame_was_receiver)
             {
@@ -2033,10 +2049,11 @@
                               "Window %s withdrawn\n",
                               window->desc);
 
-		  meta_effect_run_close (window, NULL, NULL);
-		  
+                  meta_effect_run_close (window, NULL, NULL);
+
+                  /* Unmanage withdrawn window */		  
                   window->withdrawn = TRUE;
-                  meta_window_free (window); /* Unmanage withdrawn window */
+                  meta_window_free (window, timestamp);
                   window = NULL;
                 }
               else
@@ -2204,7 +2221,12 @@
       /* do this here instead of at end of function
        * so we can return
        */
+
+      /* FIXME: Clearing display->current_time here makes no sense to
+       * me; who put this here and why?
+       */
       display->current_time = CurrentTime;
+
       process_selection_clear (display, event);
       /* Note that processing that may have resulted in
        * closing the display... so return right away.
@@ -2254,7 +2276,12 @@
 
                   /* Handle clients using the older version of the spec... */
                   if (time == 0 && workspace)
-                    time = meta_display_get_current_time_roundtrip (display);
+                    {
+                      meta_warning ("Received a NET_CURRENT_DESKTOP message "
+                                    "from a broken (outdated) client who sent "
+                                    "a 0 timestamp\n");
+                      time = meta_display_get_current_time_roundtrip (display);
+                    }
 
                   if (workspace)
                     meta_workspace_activate (workspace, time);
@@ -2273,22 +2300,26 @@
 
                   meta_prefs_set_num_workspaces (num_spaces);
                 }
-	      else if (event->xclient.message_type ==
-		       display->atom_net_showing_desktop)
-		{
-		  gboolean showing_desktop;
+              else if (event->xclient.message_type ==
+                       display->atom_net_showing_desktop)
+                {
+                  gboolean showing_desktop;
+                  guint32  timestamp;
                   
-		  showing_desktop = event->xclient.data.l[0] != 0;
-		  meta_verbose ("Request to %s desktop\n", showing_desktop ? "show" : "hide");
+                  showing_desktop = event->xclient.data.l[0] != 0;
+                  /* FIXME: Braindead protocol doesn't have a timestamp */
+                  timestamp = meta_display_get_current_time_roundtrip (display);
+                  meta_verbose ("Request to %s desktop\n",
+                                showing_desktop ? "show" : "hide");
                   
-		  if (showing_desktop)
-		    meta_screen_show_desktop (screen, meta_display_get_current_time_roundtrip (display));
-		  else
-		    {
-		      meta_screen_unshow_desktop (screen);
-		      meta_workspace_focus_default_window (screen->active_workspace, NULL, meta_display_get_current_time_roundtrip (display));
-		    }
-		}
+                  if (showing_desktop)
+                    meta_screen_show_desktop (screen, timestamp);
+                  else
+                    {
+                      meta_screen_unshow_desktop (screen);
+                      meta_workspace_focus_default_window (screen->active_workspace, NULL, timestamp);
+                    }
+                }
               else if (event->xclient.message_type ==
                        display->atom_metacity_restart_message)
                 {
@@ -3329,8 +3360,8 @@
         {
           meta_topic (META_DEBUG_WINDOW_OPS,
                       "grabbing all keys failed, ungrabbing pointer\n");
-          XUngrabPointer (display->xdisplay, CurrentTime);
-	  display->grab_have_pointer = FALSE;
+          XUngrabPointer (display->xdisplay, timestamp);
+          display->grab_have_pointer = FALSE;
           return FALSE;
         }
     }
@@ -4674,7 +4705,9 @@
       meta_verbose ("Got selection clear for screen %d on display %s\n",
                     screen->number, display->name);
       
-      meta_display_unmanage_screen (display, screen);
+      meta_display_unmanage_screen (display, 
+                                    screen,
+                                    event->xselectionclear.time);
 
       /* display and screen may both be invalid memory... */
       
@@ -4698,23 +4731,25 @@
 
 void
 meta_display_unmanage_screen (MetaDisplay *display,
-                              MetaScreen  *screen)
+                              MetaScreen  *screen,
+                              guint32      timestamp)
 {
   meta_verbose ("Unmanaging screen %d on display %s\n",
                 screen->number, display->name);
   
   g_return_if_fail (g_slist_find (display->screens, screen) != NULL);
   
-  meta_screen_free (screen);
+  meta_screen_free (screen, timestamp);
   display->screens = g_slist_remove (display->screens, screen);
 
   if (display->screens == NULL)
-    meta_display_close (display);
+    meta_display_close (display, timestamp);
 }
 
 void
 meta_display_unmanage_windows_for_screen (MetaDisplay *display,
-                                          MetaScreen  *screen)
+                                          MetaScreen  *screen,
+                                          guint32      timestamp)
 {
   GSList *tmp;
   GSList *winlist;
@@ -4724,8 +4759,8 @@
   /* Unmanage all windows */
   tmp = winlist;
   while (tmp != NULL)
-    {      
-      meta_window_free (tmp->data);
+    {
+      meta_window_free (tmp->data, timestamp);
       
       tmp = tmp->next;
     }
--- metacity-2.16.0/src/screen.c.currenttime-fixes	2006-09-04 12:55:13.000000000 -0400
+++ metacity-2.16.0/src/screen.c	2006-09-21 14:48:00.000000000 -0400
@@ -52,7 +52,8 @@
 static char* get_screen_name (MetaDisplay *display,
                               int          number);
 
-static void update_num_workspaces  (MetaScreen *screen);
+static void update_num_workspaces  (MetaScreen *screen,
+                                    guint32     timestamp);
 static void update_focus_mode      (MetaScreen *screen);
 static void set_workspace_names    (MetaScreen *screen);
 static void prefs_changed_callback (MetaPreference pref,
@@ -608,7 +609,7 @@
    * so create that required workspace.
    */
   meta_workspace_activate (meta_workspace_new (screen), timestamp);
-  update_num_workspaces (screen);
+  update_num_workspaces (screen, timestamp);
   
   set_workspace_names (screen);
 
@@ -654,7 +655,8 @@
 }
 
 void
-meta_screen_free (MetaScreen *screen)
+meta_screen_free (MetaScreen *screen,
+                  guint32     timestamp)
 {
   MetaDisplay *display;
   XGCValues gc_values = { 0 };
@@ -671,7 +673,7 @@
 				       screen);
     }
   
-  meta_display_unmanage_windows_for_screen (display, screen);
+  meta_display_unmanage_windows_for_screen (display, screen, timestamp);
   
   meta_prefs_remove_listener (prefs_changed_callback, screen);
   
@@ -855,7 +857,12 @@
   
   if (pref == META_PREF_NUM_WORKSPACES)
     {
-      update_num_workspaces (screen);
+      /* GConf doesn't provide timestamps, but luckily update_num_workspaces
+       * often doesn't need it...
+       */
+      guint32 timestamp = 
+        meta_display_get_current_time_roundtrip (screen->display);
+      update_num_workspaces (screen, timestamp);
     }
   else if (pref == META_PREF_FOCUS_MODE)
     {
@@ -1083,7 +1090,8 @@
 }
 
 static void
-update_num_workspaces (MetaScreen *screen)
+update_num_workspaces (MetaScreen *screen,
+                       guint32     timestamp)
 {
   int new_num;
   GList *tmp;
@@ -1136,7 +1144,7 @@
     }
 
   if (need_change_space)
-    meta_workspace_activate (last_remaining, meta_display_get_current_time_roundtrip (screen->display));
+    meta_workspace_activate (last_remaining, timestamp);
 
   /* Should now be safe to free the workspaces */
   tmp = extras;
--- metacity-2.16.0/src/delete.c.currenttime-fixes	2006-08-27 17:49:38.000000000 -0400
+++ metacity-2.16.0/src/delete.c	2006-09-21 14:48:00.000000000 -0400
@@ -34,7 +34,8 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-static void meta_window_present_delete_dialog (MetaWindow *window);
+static void meta_window_present_delete_dialog (MetaWindow *window,
+                                               guint32     timestamp);
 
 static void
 delete_ping_reply_func (MetaDisplay *display,
@@ -311,7 +312,7 @@
 
   if (window->dialog_pid >= 0)
     {
-      meta_window_present_delete_dialog (window);
+      meta_window_present_delete_dialog (window, timestamp);
       return;
     }
   
@@ -476,7 +477,7 @@
 }
 
 static void
-meta_window_present_delete_dialog (MetaWindow *window)
+meta_window_present_delete_dialog (MetaWindow *window, guint32 timestamp)
 {
   meta_topic (META_DEBUG_PING,
               "Presenting existing ping dialog for %s\n",
@@ -501,8 +502,7 @@
               w->res_class &&
               g_strcasecmp (w->res_class, "metacity-dialog") == 0)
             {
-              meta_window_activate (w,
-                                    meta_display_get_current_time (w->display));
+              meta_window_activate (w, timestamp);
               break;
             }