Index: libwnck/pager-accessible.c
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/pager-accessible.c,v
retrieving revision 1.4
diff -p -u -r1.4 pager-accessible.c
--- libwnck/pager-accessible.c	11 Feb 2005 09:53:46 -0000	1.4
+++ libwnck/pager-accessible.c	16 Feb 2005 08:26:18 -0000
@@ -169,7 +169,8 @@ wnck_pager_add_selection (AtkSelection *
    * Activate the following worksapce as current workspace
    */
   wspace = _wnck_pager_get_workspace (pager, i);
-  _wnck_pager_activate_workspace (wspace);
+  /* FIXME: Is gtk_get_current_event_time() good enough here?  I have no idea */
+  _wnck_pager_activate_workspace (wspace, gtk_get_current_event_time ());
  
   return TRUE;
 }
Index: libwnck/pager.c
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/pager.c,v
retrieving revision 1.43
diff -p -u -r1.43 pager.c
--- libwnck/pager.c	11 Feb 2005 09:53:46 -0000	1.43
+++ libwnck/pager.c	16 Feb 2005 08:26:18 -0000
@@ -63,6 +63,7 @@ struct _WnckPagerPrivate
 
   guint dnd_activate;
   gint  dnd_workspace_number;
+  guint dnd_time;
 };
 
 enum
@@ -1126,7 +1127,7 @@ wnck_pager_drag_motion_timeout (gpointer
 
   if (dnd_workspace &&
       (pager->priv->dnd_workspace_number != wnck_workspace_get_number (active_workspace)))
-    wnck_workspace_activate (dnd_workspace);
+    wnck_workspace_activate (dnd_workspace, pager->priv->dnd_time);
 
   return FALSE;
 }
@@ -1148,6 +1149,7 @@ wnck_pager_drag_motion (GtkWidget       
                                                pager);
 
   pager->priv->dnd_workspace_number = workspace_at_point (pager, x, y, NULL, NULL);
+  pager->priv->dnd_time = time;
   gdk_drag_status (context, 0, time);
 
   return (pager->priv->dnd_workspace_number != -1);
@@ -1166,6 +1168,7 @@ wnck_pager_drag_motion_leave (GtkWidget 
     {
       g_source_remove (pager->priv->dnd_activate);
       pager->priv->dnd_workspace_number = -1;
+      pager->priv->dnd_time = 0;
       pager->priv->dnd_activate = 0;
     }
 }
@@ -1225,7 +1228,7 @@ wnck_pager_button_release (GtkWidget    
               wnck_window_move_to_workspace (pager->priv->drag_window,
                                              space);
               if (space == wnck_screen_get_active_workspace (pager->priv->screen))
-                wnck_window_activate (pager->priv->drag_window);
+                wnck_window_activate (pager->priv->drag_window, event->time);
             }	  
 	}
       
@@ -1242,7 +1245,7 @@ wnck_pager_button_release (GtkWidget    
 
 	    /* Don't switch the desktop if we're already there */
 	    if (space != wnck_screen_get_active_workspace (pager->priv->screen))
-	      wnck_workspace_activate (space);
+	      wnck_workspace_activate (space, event->time);
 
 	    /* EWMH only lets us move the viewport for the active workspace,
 	     * but we just go ahead and hackily assume that the activate
@@ -1859,9 +1862,10 @@ _wnck_pager_get_workspace (WnckPager *pa
 } 
 
 void 
-_wnck_pager_activate_workspace (WnckWorkspace *wspace)
+_wnck_pager_activate_workspace (WnckWorkspace *wspace,
+                                guint32        timestamp)
 {
-  wnck_workspace_activate (wspace);
+  wnck_workspace_activate (wspace, timestamp);
 }
 
 void
Index: libwnck/private.h
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/private.h,v
retrieving revision 1.18
diff -p -u -r1.18 private.h
--- libwnck/private.h	22 Jan 2005 21:06:19 -0000	1.18
+++ libwnck/private.h	16 Feb 2005 08:26:18 -0000
@@ -106,7 +106,8 @@ SnDisplay* _wnck_screen_get_sn_display (
 
 WnckScreen* _wnck_screen_get_existing (int number);
 
-void           _wnck_pager_activate_workspace   (WnckWorkspace *wspace);
+void           _wnck_pager_activate_workspace   (WnckWorkspace *wspace,
+                                                 guint32        timestamp);
 int            _wnck_pager_get_n_workspaces     (WnckPager     *pager);
 const char*    _wnck_pager_get_workspace_name   (WnckPager     *pager,
                                                  int            i);
Index: libwnck/selector.c
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/selector.c,v
retrieving revision 1.4
diff -p -u -r1.4 selector.c
--- libwnck/selector.c	12 Feb 2005 17:52:04 -0000	1.4
+++ libwnck/selector.c	16 Feb 2005 08:26:18 -0000
@@ -357,15 +357,8 @@ wnck_selector_active_window_changed (Wnc
 static void
 wnck_selector_activate_window (WnckWindow *window)
 {
-  WnckWorkspace *workspace;
-
-  workspace = wnck_window_get_workspace (window);
-  wnck_workspace_activate (workspace);
-
-  if (wnck_window_is_minimized (window))
-    wnck_window_unminimize (window);
-
-  wnck_window_activate (window);
+  /* We're in an activate callback, so gtk_get_current_time() works... */
+  wnck_window_activate (window, gtk_get_current_event_time ());
 }
 
 #define SELECTOR_MAX_WIDTH 50   /* maximum width in characters */
Index: libwnck/tasklist.c
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/tasklist.c,v
retrieving revision 1.74
diff -p -u -r1.74 tasklist.c
--- libwnck/tasklist.c	12 Feb 2005 17:52:04 -0000	1.74
+++ libwnck/tasklist.c	16 Feb 2005 08:26:19 -0000
@@ -116,6 +116,8 @@ struct _WnckTask
   guint was_active : 1;      /* used to fixup activation behavior */ 
 
   guint button_activate;
+
+  guint32 dnd_timestamp;
 };
 
 struct _WnckTaskClass
@@ -240,7 +242,8 @@ static void     wnck_tasklist_connect_wi
 static void     wnck_tasklist_change_active_task       (WnckTasklist *tasklist,
 							WnckTask *active_task);
 static gboolean wnck_tasklist_change_active_timeout    (gpointer data);
-static void     wnck_tasklist_activate_task_window     (WnckTask *task);
+static void     wnck_tasklist_activate_task_window     (WnckTask *task,
+                                                        guint32   timestamp);
 
 static void     wnck_tasklist_update_icon_geometries   (WnckTasklist *tasklist,
 							GList        *visible_tasks);
@@ -1915,11 +1918,15 @@ wnck_task_menu_activated (GtkMenuItem *m
 {
   WnckTask *task = WNCK_TASK (data);
 
-  wnck_tasklist_activate_task_window (task);
+  /* This is an "activate" callback function so gtk_get_current_event_time()
+   * will suffice.
+   */
+  wnck_tasklist_activate_task_window (task, gtk_get_current_event_time ());
 }
 
 static void
-wnck_tasklist_activate_task_window (WnckTask *task)
+wnck_tasklist_activate_task_window (WnckTask *task,
+                                    guint32   timestamp)
 {
   WnckTasklist *tasklist;
   WnckWindowState state;
@@ -1940,10 +1947,10 @@ wnck_tasklist_activate_task_window (Wnck
       window_ws = wnck_window_get_workspace (task->window);
       if (window_ws &&
           active_ws != window_ws &&
-	  !tasklist->priv->switch_workspace_on_unminimize)
-	wnck_workspace_activate (window_ws);
-	  
-      wnck_window_activate_transient (task->window);
+          tasklist->priv->switch_workspace_on_unminimize)
+        wnck_window_move_to_workspace (task->window, active_ws);
+
+      wnck_window_activate_transient (task->window, timestamp);
     }
   else
     {
@@ -1955,14 +1962,8 @@ wnck_tasklist_activate_task_window (Wnck
 	}
       else
 	{
-          WnckWorkspace *window_ws;
-          
-          window_ws = wnck_window_get_workspace (task->window);
-          if (window_ws)
-            wnck_workspace_activate (window_ws);
-
-	  wnck_window_activate_transient (task->window);
-	}
+          wnck_window_activate_transient (task->window, timestamp);
+        }
     }
   
 
@@ -2002,7 +2003,10 @@ wnck_task_unminimize_all (GtkMenuItem *m
   while (l)
     {
       WnckTask *child = WNCK_TASK (l->data);
-      wnck_window_unminimize (child->window);
+      /* This is inside an activate callback, so gtk_get_current_event_time()
+       * will work.
+       */
+      wnck_window_unminimize (child->window, gtk_get_current_event_time ());
       l = l->next;
     }
 }
@@ -2165,8 +2169,11 @@ wnck_task_button_toggled (GtkButton *but
     case WNCK_TASK_WINDOW:
       if (task->window == NULL)
 	return;
-      
-      wnck_tasklist_activate_task_window (task);
+
+      /* This should only be called by clicking on the task button, so
+       * gtk_get_current_event_time() should be fine here...
+       */
+      wnck_tasklist_activate_task_window (task, gtk_get_current_event_time ());
       break;
     case WNCK_TASK_STARTUP_SEQUENCE:
       break;
@@ -2510,7 +2517,9 @@ wnck_task_motion_timeout (gpointer data)
 
   task->button_activate = 0;
 
-  wnck_window_activate_transient (task->window);
+  wnck_window_activate_transient (task->window, task->dnd_timestamp);
+
+  task->dnd_timestamp = 0;
 
   return FALSE;
 }
@@ -2536,14 +2545,14 @@ wnck_task_drag_motion (GtkWidget        
 		       guint               time,
 		       WnckTask            *task)
 {
+  task->dnd_timestamp = time;
+  if (task->button_activate == 0 && task->type == WNCK_TASK_WINDOW)
+      task->button_activate = g_timeout_add (WNCK_ACTIVATE_TIMEOUT,
+                                             wnck_task_motion_timeout,
+                                             task);
+  gdk_drag_status (context,0,time);
 
-   if (task->button_activate == 0 && task->type == WNCK_TASK_WINDOW)
-       task->button_activate = g_timeout_add (WNCK_ACTIVATE_TIMEOUT,
-                                              wnck_task_motion_timeout,
-                                              task);
-   gdk_drag_status (context,0,time);
-
-   return TRUE;
+  return TRUE;
 }
 
 static gboolean
Index: libwnck/test-wnck.c
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/test-wnck.c,v
retrieving revision 1.12
diff -p -u -r1.12 test-wnck.c
--- libwnck/test-wnck.c	25 Sep 2002 02:36:53 -0000	1.12
+++ libwnck/test-wnck.c	16 Feb 2005 08:26:19 -0000
@@ -611,7 +611,11 @@ minimized_toggled_callback (GtkCellRende
   window = get_window (model, &iter);
 
   if (wnck_window_is_minimized (window))
-    wnck_window_unminimize (window);
+    /* The toggled callback will only be called in reaction to user
+     * button presses or key presses, so gtk_get_current_event_time()
+     * should be okay here.
+     */
+    wnck_window_unminimize (window, gtk_get_current_event_time ());
   else
     wnck_window_minimize (window);
   
@@ -716,7 +720,11 @@ selection_func (GtkTreeSelection  *selec
         return TRUE;
       else
         {
-          wnck_window_activate (window);
+          /* This should only be called in reaction to user button
+           * presses or key presses (I hope), so
+           * gtk_get_current_event_time() should be okay here.
+           */
+          wnck_window_activate (window, gtk_get_current_event_time ());
           return FALSE;
         }
     }
Index: libwnck/window-action-menu.c
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/window-action-menu.c,v
retrieving revision 1.16
diff -p -u -r1.16 window-action-menu.c
--- libwnck/window-action-menu.c	31 Jan 2005 20:45:24 -0000	1.16
+++ libwnck/window-action-menu.c	16 Feb 2005 08:26:19 -0000
@@ -111,12 +111,14 @@ item_activated_callback (GtkWidget *menu
   switch (action)
     {
     case CLOSE:
+      /* In an activate callback, so gtk_get_current_event_time() suffices */
       wnck_window_close (amd->window,
 			 gtk_get_current_event_time ());
       break;
     case MINIMIZE:
       if (wnck_window_is_minimized (amd->window))
-        wnck_window_unminimize (amd->window);
+        wnck_window_unminimize (amd->window,
+                                gtk_get_current_event_time ());
       else
         wnck_window_minimize (amd->window);
       break;
Index: libwnck/window.c
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/window.c,v
retrieving revision 1.53
diff -p -u -r1.53 window.c
--- libwnck/window.c	12 Feb 2005 17:52:04 -0000	1.53
+++ libwnck/window.c	16 Feb 2005 08:26:20 -0000
@@ -852,11 +852,12 @@ wnck_window_minimize                (Wnc
 }
 
 void
-wnck_window_unminimize              (WnckWindow *window)
+wnck_window_unminimize              (WnckWindow *window,
+                                     guint32     timestamp)
 {
   g_return_if_fail (WNCK_IS_WINDOW (window));
 
-  wnck_window_activate_transient (window);
+  wnck_window_activate_transient (window, timestamp);
 }
 
 void
@@ -1092,12 +1093,14 @@ wnck_window_unpin (WnckWindow *window)
  * window manager may choose to raise @window along with focusing it.
  **/
 void
-wnck_window_activate (WnckWindow *window)
+wnck_window_activate (WnckWindow *window,
+                      guint32     timestamp)
 {
   g_return_if_fail (WNCK_IS_WINDOW (window));
 
   _wnck_activate (WNCK_SCREEN_XSCREEN (window->priv->screen),
-		  window->priv->xwindow);
+                  window->priv->xwindow,
+                  timestamp);
 }
 
 /**
@@ -1187,7 +1190,8 @@ find_last_transient_for (GList *windows,
  * 
  **/
 void
-wnck_window_activate_transient (WnckWindow *window)
+wnck_window_activate_transient (WnckWindow *window,
+                                guint32     timestamp)
 {
   GList *windows;
   WnckWindow *transient;
@@ -1215,9 +1219,9 @@ wnck_window_activate_transient (WnckWind
     }
 
   if (transient != NULL)
-    wnck_window_activate (transient);
+    wnck_window_activate (transient, timestamp);
   else
-    wnck_window_activate (window);
+    wnck_window_activate (window, timestamp);
 }
 
 /**
Index: libwnck/window.h
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/window.h,v
retrieving revision 1.30
diff -p -u -r1.30 window.h
--- libwnck/window.h	12 Feb 2005 17:52:04 -0000	1.30
+++ libwnck/window.h	16 Feb 2005 08:26:20 -0000
@@ -168,9 +168,10 @@ void wnck_window_set_fullscreen (WnckWin
                                  gboolean fullscreen);
 
 void wnck_window_close                   (WnckWindow *window,
-					  guint32     timestamp);
+                                          guint32     timestamp);
 void wnck_window_minimize                (WnckWindow *window);
-void wnck_window_unminimize              (WnckWindow *window);
+void wnck_window_unminimize              (WnckWindow *window,
+                                          guint32     timestamp);
 void wnck_window_maximize                (WnckWindow *window);
 void wnck_window_unmaximize              (WnckWindow *window);
 void wnck_window_maximize_horizontally   (WnckWindow *window);
@@ -193,10 +194,12 @@ gboolean wnck_window_is_pinned (WnckWind
 void     wnck_window_pin       (WnckWindow *window);
 void     wnck_window_unpin     (WnckWindow *window);
 
-void     wnck_window_activate  (WnckWindow *window);
+void     wnck_window_activate  (WnckWindow *window,
+                                guint32     timestamp);
 gboolean wnck_window_is_active (WnckWindow *window);
 gboolean wnck_window_is_most_recently_activated (WnckWindow *window);
-void     wnck_window_activate_transient (WnckWindow *window);
+void     wnck_window_activate_transient (WnckWindow *window,
+                                         guint32     timestamp);
 gboolean wnck_window_transient_is_active (WnckWindow *window);
 
 GdkPixbuf* wnck_window_get_icon      (WnckWindow *window);
Index: libwnck/workspace.c
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/workspace.c,v
retrieving revision 1.12
diff -p -u -r1.12 workspace.c
--- libwnck/workspace.c	11 Jul 2003 19:37:33 -0000	1.12
+++ libwnck/workspace.c	16 Feb 2005 08:26:20 -0000
@@ -187,11 +187,14 @@ wnck_workspace_change_name (WnckWorkspac
  * 
  **/
 void
-wnck_workspace_activate (WnckWorkspace *space)
+wnck_workspace_activate (WnckWorkspace *space,
+                         guint32        timestamp)
 {
   g_return_if_fail (WNCK_IS_WORKSPACE (space));
 
-  _wnck_activate_workspace (WNCK_SCREEN_XSCREEN (space->priv->screen), space->priv->number);
+  _wnck_activate_workspace (WNCK_SCREEN_XSCREEN (space->priv->screen),
+                            space->priv->number,
+                            timestamp);
 }
 
 WnckWorkspace*
Index: libwnck/workspace.h
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/workspace.h,v
retrieving revision 1.9
diff -p -u -r1.9 workspace.h
--- libwnck/workspace.h	11 Jul 2003 19:37:33 -0000	1.9
+++ libwnck/workspace.h	16 Feb 2005 08:26:20 -0000
@@ -57,7 +57,8 @@ int         wnck_workspace_get_number   
 const char* wnck_workspace_get_name       (WnckWorkspace *space);
 void        wnck_workspace_change_name    (WnckWorkspace *space,
                                            const char    *name);
-void        wnck_workspace_activate       (WnckWorkspace *space);
+void        wnck_workspace_activate       (WnckWorkspace *space,
+                                           guint32        timestamp);
 int         wnck_workspace_get_width      (WnckWorkspace *space);
 int         wnck_workspace_get_height     (WnckWorkspace *space);
 int         wnck_workspace_get_viewport_x (WnckWorkspace *space);
Index: libwnck/xutils.c
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/xutils.c,v
retrieving revision 1.46
diff -p -u -r1.46 xutils.c
--- libwnck/xutils.c	8 Aug 2004 00:01:44 -0000	1.46
+++ libwnck/xutils.c	16 Feb 2005 08:26:20 -0000
@@ -972,13 +972,11 @@ _wnck_change_workspace (Screen     *scre
 
 void
 _wnck_activate (Screen *screen,
-		Window  xwindow)
+                Window  xwindow,
+                Time    timestamp)
 {
   XEvent xev;
 
-  Time timestamp;
-
-  timestamp = gtk_get_current_event_time();
   if (timestamp == 0)
     g_warning ("Received a timestamp of 0; window activation may not "
                "function properly.\n");
@@ -993,6 +991,8 @@ _wnck_activate (Screen *screen,
   xev.xclient.data.l[0] = 2;
   xev.xclient.data.l[1] = timestamp;
   xev.xclient.data.l[2] = 0;
+  xev.xclient.data.l[3] = 0;
+  xev.xclient.data.l[4] = 0;
 
   XSendEvent (gdk_display,
 	      RootWindowOfScreen (screen),
@@ -1003,7 +1003,8 @@ _wnck_activate (Screen *screen,
 
 void
 _wnck_activate_workspace (Screen *screen,
-			  int     new_active_space)
+                          int     new_active_space,
+                          Time    timestamp)
 {
   XEvent xev;
   
@@ -1015,8 +1016,10 @@ _wnck_activate_workspace (Screen *screen
   xev.xclient.message_type = _wnck_atom_get ("_NET_CURRENT_DESKTOP");
   xev.xclient.format = 32;
   xev.xclient.data.l[0] = new_active_space;
-  xev.xclient.data.l[1] = 0;
+  xev.xclient.data.l[1] = timestamp;
   xev.xclient.data.l[2] = 0;
+  xev.xclient.data.l[3] = 0;
+  xev.xclient.data.l[4] = 0;
 
   XSendEvent (gdk_display,
 	      RootWindowOfScreen (screen),
Index: libwnck/xutils.h
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/xutils.h,v
retrieving revision 1.24
diff -p -u -r1.24 xutils.h
--- libwnck/xutils.h	21 Jun 2004 16:48:12 -0000	1.24
+++ libwnck/xutils.h	16 Feb 2005 08:26:21 -0000
@@ -100,9 +100,11 @@ void _wnck_change_workspace (Screen  *sc
 			     Window   xwindow,
                              int      new_space);
 void _wnck_activate         (Screen  *screen,
-			     Window   xwindow);
+                             Window   xwindow,
+                             Time     timestamp);
 void _wnck_activate_workspace (Screen *screen,
-			       int     new_active_space);
+                               int     new_active_space,
+                               Time    timestamp);
 void _wnck_change_viewport (Screen *screen,
 			    int     x,
 			    int     y);
