summaryrefslogtreecommitdiffstats
path: root/metacity-2.16.0-currenttime-fixes.patch
blob: 8b35cace5da7c4a9a328e883f7c954712901ea86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
--- 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;
             }