Partial audit to fix timestamp usage. One step towards fixing #355180; see

2006-09-18  Elijah Newren  <newren gmail com>

	Partial audit to fix timestamp usage.  One step towards fixing
	#355180; see important comments in that bug.

	* src/core.[ch] (meta_core_unshade, meta_core_shade):
	* src/delete.c (meta_window_present_delete_dialog,
	  delete_ping_timeout_func):
	* src/display.[ch] (meta_display_open, meta_display_close,
	  event_callback, meta_display_begin_grab_op,
	  process_selection_clear, meta_display_unmanage_screen,
	  meta_display_unmanage_windows_for_screen):
	* src/frames.c (meta_frames_button_press_event):
	* src/keybindings.c (handle_toggle_shade):
	* src/main.c (main):
	* src/screen.[ch] (update_num_workspaces, meta_screen_new,
	  meta_screen_free, prefs_changed_callback):
	* src/window.[ch] (meta_window_free, finish_minimize,
	  implement_showing, meta_window_show, meta_window_maximize,
	  meta_window_make_fullscreen_internal,
	  meta_window_unmake_fullscreen, meta_window_shade,
	  meta_window_unshade, window_activate, send_sync_request,
	  meta_window_client_message, menu_callback,
	  meta_window_update_keyboard_resize):
	Remove usage of CurrentTime, meta_display_get_current_time() and
	meta_display_get_current_time_roundtrip() where possible, or
	document why it isn't possible, or at very least add a FIXME with
	some explanation of my laziness and what needs to be done.
This commit is contained in:
Elijah Newren 2006-09-18 17:27:24 +00:00 committed by Elijah Newren
parent 87100b64d9
commit 5c587726ae
13 changed files with 269 additions and 120 deletions

View File

@ -1,3 +1,32 @@
2006-09-18 Elijah Newren <newren gmail com>
Partial audit to fix timestamp usage. One step towards fixing
#355180; see important comments in that bug.
* src/core.[ch] (meta_core_unshade, meta_core_shade):
* src/delete.c (meta_window_present_delete_dialog,
delete_ping_timeout_func):
* src/display.[ch] (meta_display_open, meta_display_close,
event_callback, meta_display_begin_grab_op,
process_selection_clear, meta_display_unmanage_screen,
meta_display_unmanage_windows_for_screen):
* src/frames.c (meta_frames_button_press_event):
* src/keybindings.c (handle_toggle_shade):
* src/main.c (main):
* src/screen.[ch] (update_num_workspaces, meta_screen_new,
meta_screen_free, prefs_changed_callback):
* src/window.[ch] (meta_window_free, finish_minimize,
implement_showing, meta_window_show, meta_window_maximize,
meta_window_make_fullscreen_internal,
meta_window_unmake_fullscreen, meta_window_shade,
meta_window_unshade, window_activate, send_sync_request,
meta_window_client_message, menu_callback,
meta_window_update_keyboard_resize):
Remove usage of CurrentTime, meta_display_get_current_time() and
meta_display_get_current_time_roundtrip() where possible, or
document why it isn't possible, or at very least add a FIXME with
some explanation of my laziness and what needs to be done.
2006-09-18 Elijah Newren <newren gmail com> 2006-09-18 Elijah Newren <newren gmail com>
* src/spring-model.c (on_end_move, model_is_calm): Patch from Maik * src/spring-model.c (on_end_move, model_is_calm): Patch from Maik

View File

@ -339,20 +339,22 @@ meta_core_delete (Display *xdisplay,
void void
meta_core_unshade (Display *xdisplay, meta_core_unshade (Display *xdisplay,
Window frame_xwindow) Window frame_xwindow,
guint32 timestamp)
{ {
MetaWindow *window = get_window (xdisplay, frame_xwindow); MetaWindow *window = get_window (xdisplay, frame_xwindow);
meta_window_unshade (window); meta_window_unshade (window, timestamp);
} }
void void
meta_core_shade (Display *xdisplay, meta_core_shade (Display *xdisplay,
Window frame_xwindow) Window frame_xwindow,
guint32 timestamp)
{ {
MetaWindow *window = get_window (xdisplay, frame_xwindow); MetaWindow *window = get_window (xdisplay, frame_xwindow);
meta_window_shade (window); meta_window_shade (window, timestamp);
} }
void void

View File

@ -95,9 +95,11 @@ void meta_core_delete (Display *xdisplay,
Window frame_xwindow, Window frame_xwindow,
guint32 timestamp); guint32 timestamp);
void meta_core_unshade (Display *xdisplay, void meta_core_unshade (Display *xdisplay,
Window frame_xwindow); Window frame_xwindow,
guint32 timestamp);
void meta_core_shade (Display *xdisplay, void meta_core_shade (Display *xdisplay,
Window frame_xwindow); Window frame_xwindow,
guint32 timestamp);
void meta_core_unstick (Display *xdisplay, void meta_core_unstick (Display *xdisplay,
Window frame_xwindow); Window frame_xwindow);
void meta_core_stick (Display *xdisplay, void meta_core_stick (Display *xdisplay,

View File

@ -34,7 +34,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.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 static void
delete_ping_reply_func (MetaDisplay *display, delete_ping_reply_func (MetaDisplay *display,
@ -311,7 +312,7 @@ delete_ping_timeout_func (MetaDisplay *display,
if (window->dialog_pid >= 0) if (window->dialog_pid >= 0)
{ {
meta_window_present_delete_dialog (window); meta_window_present_delete_dialog (window, timestamp);
return; return;
} }
@ -476,7 +477,7 @@ meta_window_free_delete_dialog (MetaWindow *window)
} }
static void static void
meta_window_present_delete_dialog (MetaWindow *window) meta_window_present_delete_dialog (MetaWindow *window, guint32 timestamp)
{ {
meta_topic (META_DEBUG_PING, meta_topic (META_DEBUG_PING,
"Presenting existing ping dialog for %s\n", "Presenting existing ping dialog for %s\n",
@ -501,8 +502,7 @@ meta_window_present_delete_dialog (MetaWindow *window)
w->res_class && w->res_class &&
g_strcasecmp (w->res_class, "metacity-dialog") == 0) g_strcasecmp (w->res_class, "metacity-dialog") == 0)
{ {
meta_window_activate (w, meta_window_activate (w, timestamp);
meta_display_get_current_time (w->display));
break; break;
} }

View File

@ -707,7 +707,7 @@ meta_display_open (void)
/* This would typically happen because all the screens already /* This would typically happen because all the screens already
* have window managers. * have window managers.
*/ */
meta_display_close (display); meta_display_close (display, timestamp);
return FALSE; return FALSE;
} }
@ -842,7 +842,8 @@ meta_display_list_windows (MetaDisplay *display)
} }
void void
meta_display_close (MetaDisplay *display) meta_display_close (MetaDisplay *display,
guint32 timestamp)
{ {
GSList *tmp; GSList *tmp;
@ -868,7 +869,7 @@ meta_display_close (MetaDisplay *display)
while (tmp != NULL) while (tmp != NULL)
{ {
MetaScreen *screen = tmp->data; MetaScreen *screen = tmp->data;
meta_screen_free (screen); meta_screen_free (screen, timestamp);
tmp = tmp->next; tmp = tmp->next;
} }
@ -2000,9 +2001,16 @@ event_callback (XEvent *event,
case DestroyNotify: case DestroyNotify:
if (window) 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 && if (display->grab_op != META_GRAB_OP_NONE &&
display->grab_window == window) display->grab_window == window)
meta_display_end_grab_op (display, CurrentTime); meta_display_end_grab_op (display, timestamp);
if (frame_was_receiver) if (frame_was_receiver)
{ {
@ -2014,7 +2022,8 @@ event_callback (XEvent *event,
} }
else else
{ {
meta_window_free (window); /* Unmanage destroyed window */ /* Unmanage destroyed window */
meta_window_free (window, timestamp);
window = NULL; window = NULL;
} }
} }
@ -2022,10 +2031,17 @@ event_callback (XEvent *event,
case UnmapNotify: case UnmapNotify:
if (window) 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 && if (display->grab_op != META_GRAB_OP_NONE &&
display->grab_window == window && display->grab_window == window &&
((window->frame == NULL) || !window->frame->mapped)) ((window->frame == NULL) || !window->frame->mapped))
meta_display_end_grab_op (display, CurrentTime); meta_display_end_grab_op (display, timestamp);
if (!frame_was_receiver) if (!frame_was_receiver)
{ {
@ -2035,10 +2051,11 @@ event_callback (XEvent *event,
"Window %s withdrawn\n", "Window %s withdrawn\n",
window->desc); window->desc);
meta_effect_run_close (window, NULL, NULL); meta_effect_run_close (window, NULL, NULL);
/* Unmanage withdrawn window */
window->withdrawn = TRUE; window->withdrawn = TRUE;
meta_window_free (window); /* Unmanage withdrawn window */ meta_window_free (window, timestamp);
window = NULL; window = NULL;
} }
else else
@ -2206,7 +2223,12 @@ event_callback (XEvent *event,
/* do this here instead of at end of function /* do this here instead of at end of function
* so we can return * 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; display->current_time = CurrentTime;
process_selection_clear (display, event); process_selection_clear (display, event);
/* Note that processing that may have resulted in /* Note that processing that may have resulted in
* closing the display... so return right away. * closing the display... so return right away.
@ -2256,7 +2278,12 @@ event_callback (XEvent *event,
/* Handle clients using the older version of the spec... */ /* Handle clients using the older version of the spec... */
if (time == 0 && workspace) 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) if (workspace)
meta_workspace_activate (workspace, time); meta_workspace_activate (workspace, time);
@ -2275,22 +2302,26 @@ event_callback (XEvent *event,
meta_prefs_set_num_workspaces (num_spaces); meta_prefs_set_num_workspaces (num_spaces);
} }
else if (event->xclient.message_type == else if (event->xclient.message_type ==
display->atom_net_showing_desktop) display->atom_net_showing_desktop)
{ {
gboolean showing_desktop; gboolean showing_desktop;
guint32 timestamp;
showing_desktop = event->xclient.data.l[0] != 0; showing_desktop = event->xclient.data.l[0] != 0;
meta_verbose ("Request to %s desktop\n", showing_desktop ? "show" : "hide"); /* 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) if (showing_desktop)
meta_screen_show_desktop (screen, meta_display_get_current_time_roundtrip (display)); meta_screen_show_desktop (screen, timestamp);
else else
{ {
meta_screen_unshow_desktop (screen); meta_screen_unshow_desktop (screen);
meta_workspace_focus_default_window (screen->active_workspace, NULL, meta_display_get_current_time_roundtrip (display)); meta_workspace_focus_default_window (screen->active_workspace, NULL, timestamp);
} }
} }
else if (event->xclient.message_type == else if (event->xclient.message_type ==
display->atom_metacity_restart_message) display->atom_metacity_restart_message)
{ {
@ -3331,8 +3362,8 @@ meta_display_begin_grab_op (MetaDisplay *display,
{ {
meta_topic (META_DEBUG_WINDOW_OPS, meta_topic (META_DEBUG_WINDOW_OPS,
"grabbing all keys failed, ungrabbing pointer\n"); "grabbing all keys failed, ungrabbing pointer\n");
XUngrabPointer (display->xdisplay, CurrentTime); XUngrabPointer (display->xdisplay, timestamp);
display->grab_have_pointer = FALSE; display->grab_have_pointer = FALSE;
return FALSE; return FALSE;
} }
} }
@ -4675,7 +4706,9 @@ process_selection_clear (MetaDisplay *display,
meta_verbose ("Got selection clear for screen %d on display %s\n", meta_verbose ("Got selection clear for screen %d on display %s\n",
screen->number, display->name); 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... */ /* display and screen may both be invalid memory... */
@ -4699,23 +4732,25 @@ process_selection_clear (MetaDisplay *display,
void void
meta_display_unmanage_screen (MetaDisplay *display, meta_display_unmanage_screen (MetaDisplay *display,
MetaScreen *screen) MetaScreen *screen,
guint32 timestamp)
{ {
meta_verbose ("Unmanaging screen %d on display %s\n", meta_verbose ("Unmanaging screen %d on display %s\n",
screen->number, display->name); screen->number, display->name);
g_return_if_fail (g_slist_find (display->screens, screen) != NULL); 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); display->screens = g_slist_remove (display->screens, screen);
if (display->screens == NULL) if (display->screens == NULL)
meta_display_close (display); meta_display_close (display, timestamp);
} }
void void
meta_display_unmanage_windows_for_screen (MetaDisplay *display, meta_display_unmanage_windows_for_screen (MetaDisplay *display,
MetaScreen *screen) MetaScreen *screen,
guint32 timestamp)
{ {
GSList *tmp; GSList *tmp;
GSList *winlist; GSList *winlist;
@ -4726,7 +4761,7 @@ meta_display_unmanage_windows_for_screen (MetaDisplay *display,
tmp = winlist; tmp = winlist;
while (tmp != NULL) while (tmp != NULL)
{ {
meta_window_free (tmp->data); meta_window_free (tmp->data, timestamp);
tmp = tmp->next; tmp = tmp->next;
} }

View File

@ -388,7 +388,8 @@ struct _MetaDisplay
) )
gboolean meta_display_open (void); 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, MetaScreen* meta_display_screen_for_root (MetaDisplay *display,
Window xroot); Window xroot);
MetaScreen* meta_display_screen_for_x_screen (MetaDisplay *display, MetaScreen* meta_display_screen_for_x_screen (MetaDisplay *display,
@ -399,10 +400,12 @@ void meta_display_grab (MetaDisplay *display);
void meta_display_ungrab (MetaDisplay *display); void meta_display_ungrab (MetaDisplay *display);
void meta_display_unmanage_screen (MetaDisplay *display, void meta_display_unmanage_screen (MetaDisplay *display,
MetaScreen *screen); MetaScreen *screen,
guint32 timestamp);
void meta_display_unmanage_windows_for_screen (MetaDisplay *display, 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" /* A given MetaWindow may have various X windows that "belong"
* to it, such as the frame window. * to it, such as the frame window.

View File

@ -1254,10 +1254,12 @@ meta_frames_button_press_event (GtkWidget *widget,
{ {
if (flags & META_FRAME_SHADED) if (flags & META_FRAME_SHADED)
meta_core_unshade (gdk_display, meta_core_unshade (gdk_display,
frame->xwindow); frame->xwindow,
event->time);
else else
meta_core_shade (gdk_display, meta_core_shade (gdk_display,
frame->xwindow); frame->xwindow,
event->time);
} }
} }
break; break;

View File

@ -3300,9 +3300,9 @@ handle_toggle_shade (MetaDisplay *display,
if (window) if (window)
{ {
if (window->shaded) if (window->shaded)
meta_window_unshade (window); meta_window_unshade (window, event->xkey.time);
else if (window->has_shade_func) else if (window->has_shade_func)
meta_window_shade (window); meta_window_shade (window, event->xkey.time);
} }
} }

View File

@ -399,7 +399,9 @@ main (int argc, char **argv)
tmp = displays; tmp = displays;
while (tmp != NULL) 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; tmp = tmp->next;
} }
g_slist_free (displays); g_slist_free (displays);

View File

@ -52,7 +52,8 @@
static char* get_screen_name (MetaDisplay *display, static char* get_screen_name (MetaDisplay *display,
int number); 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 update_focus_mode (MetaScreen *screen);
static void set_workspace_names (MetaScreen *screen); static void set_workspace_names (MetaScreen *screen);
static void prefs_changed_callback (MetaPreference pref, static void prefs_changed_callback (MetaPreference pref,
@ -608,7 +609,7 @@ meta_screen_new (MetaDisplay *display,
* so create that required workspace. * so create that required workspace.
*/ */
meta_workspace_activate (meta_workspace_new (screen), timestamp); meta_workspace_activate (meta_workspace_new (screen), timestamp);
update_num_workspaces (screen); update_num_workspaces (screen, timestamp);
set_workspace_names (screen); set_workspace_names (screen);
@ -654,7 +655,8 @@ meta_screen_new (MetaDisplay *display,
} }
void void
meta_screen_free (MetaScreen *screen) meta_screen_free (MetaScreen *screen,
guint32 timestamp)
{ {
MetaDisplay *display; MetaDisplay *display;
XGCValues gc_values = { 0 }; XGCValues gc_values = { 0 };
@ -671,7 +673,7 @@ meta_screen_free (MetaScreen *screen)
screen); 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); meta_prefs_remove_listener (prefs_changed_callback, screen);
@ -855,7 +857,12 @@ prefs_changed_callback (MetaPreference pref,
if (pref == META_PREF_NUM_WORKSPACES) 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) else if (pref == META_PREF_FOCUS_MODE)
{ {
@ -1083,7 +1090,8 @@ set_desktop_viewport_hint (MetaScreen *screen)
} }
static void static void
update_num_workspaces (MetaScreen *screen) update_num_workspaces (MetaScreen *screen,
guint32 timestamp)
{ {
int new_num; int new_num;
GList *tmp; GList *tmp;
@ -1136,7 +1144,7 @@ update_num_workspaces (MetaScreen *screen)
} }
if (need_change_space) 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 */ /* Should now be safe to free the workspaces */
tmp = extras; tmp = extras;

View File

@ -123,7 +123,8 @@ struct _MetaScreen
MetaScreen* meta_screen_new (MetaDisplay *display, MetaScreen* meta_screen_new (MetaDisplay *display,
int number, int number,
guint32 timestamp); guint32 timestamp);
void meta_screen_free (MetaScreen *screen); void meta_screen_free (MetaScreen *screen,
guint32 timestamp);
void meta_screen_manage_all_windows (MetaScreen *screen); void meta_screen_manage_all_windows (MetaScreen *screen);
MetaScreen* meta_screen_for_x_screen (Screen *xscreen); MetaScreen* meta_screen_for_x_screen (Screen *xscreen);
void meta_screen_foreach_window (MetaScreen *screen, void meta_screen_foreach_window (MetaScreen *screen,

View File

@ -910,7 +910,8 @@ meta_window_apply_session_info (MetaWindow *window,
} }
void void
meta_window_free (MetaWindow *window) meta_window_free (MetaWindow *window,
guint32 timestamp)
{ {
GList *tmp; GList *tmp;
@ -963,7 +964,9 @@ meta_window_free (MetaWindow *window)
meta_topic (META_DEBUG_FOCUS, meta_topic (META_DEBUG_FOCUS,
"Focusing default window since we're unmanaging %s\n", "Focusing default window since we're unmanaging %s\n",
window->desc); 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) else if (window->display->expected_focus_window == window)
{ {
@ -971,7 +974,9 @@ meta_window_free (MetaWindow *window)
"Focusing default window since expected focus window freed %s\n", "Focusing default window since expected focus window freed %s\n",
window->desc); window->desc);
window->display->expected_focus_window = NULL; 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 else
{ {
@ -992,8 +997,7 @@ meta_window_free (MetaWindow *window)
} }
if (window->display->grab_window == window) if (window->display->grab_window == window)
meta_display_end_grab_op (window->display, meta_display_end_grab_op (window->display, timestamp);
meta_display_get_current_time (window->display));
g_assert (window->display->grab_window != window); g_assert (window->display->grab_window != window);
@ -1338,14 +1342,20 @@ finish_minimize (const MetaEffect *effect,
gpointer data) gpointer data)
{ {
MetaWindow *window = 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); meta_window_hide (window);
if (window->has_focus) if (window->has_focus)
{ {
meta_workspace_focus_default_window meta_workspace_focus_default_window (window->screen->active_workspace,
(window->screen->active_workspace, window,
window, timestamp);
meta_display_get_current_time_roundtrip (window->display));
} }
} }
@ -1373,11 +1383,11 @@ implement_showing (MetaWindow *window,
if (on_workspace && window->minimized && window->mapped && if (on_workspace && window->minimized && window->mapped &&
!meta_prefs_get_reduced_resources ()) !meta_prefs_get_reduced_resources ())
{ {
MetaRectangle icon_rect, window_rect; MetaRectangle icon_rect, window_rect;
gboolean result; gboolean result;
/* Check if the window has an icon geometry */ /* Check if the window has an icon geometry */
result = meta_window_get_icon_geometry (window, &icon_rect); result = meta_window_get_icon_geometry (window, &icon_rect);
if (!result) if (!result)
{ {
@ -1392,16 +1402,16 @@ implement_showing (MetaWindow *window,
meta_window_get_outer_rect (window, &window_rect); meta_window_get_outer_rect (window, &window_rect);
meta_effect_run_minimize (window, meta_effect_run_minimize (window,
&window_rect, &window_rect,
&icon_rect, &icon_rect,
finish_minimize, finish_minimize,
window); window);
} }
else else
{ {
finish_minimize (NULL, window); finish_minimize (NULL, window);
} }
} }
else else
{ {
@ -1852,6 +1862,13 @@ meta_window_show (MetaWindow *window)
gboolean place_on_top_on_map; gboolean place_on_top_on_map;
gboolean needs_stacking_adjustment; gboolean needs_stacking_adjustment;
MetaWindow *focus_window; 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, meta_topic (META_DEBUG_WINDOW_STATE,
"Showing window %s, shaded: %d iconic: %d placed: %d\n", "Showing window %s, shaded: %d iconic: %d placed: %d\n",
@ -1885,7 +1902,9 @@ meta_window_show (MetaWindow *window)
"ancestor.\n", "ancestor.\n",
focus_window->desc, window->desc); 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 else
{ {
@ -2054,8 +2073,7 @@ meta_window_show (MetaWindow *window)
window->showing_for_first_time = FALSE; window->showing_for_first_time = FALSE;
if (takes_focus_on_map) if (takes_focus_on_map)
{ {
meta_window_focus (window, meta_window_focus (window, timestamp);
meta_display_get_current_time_roundtrip (window->display));
} }
else else
{ {
@ -2261,7 +2279,14 @@ meta_window_maximize (MetaWindow *window,
(maximize_vertically && !window->maximized_vertically)) (maximize_vertically && !window->maximized_vertically))
{ {
if (window->shaded && maximize_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 /* if the window hasn't been placed yet, we'll maximize it then
*/ */
@ -2384,7 +2409,14 @@ meta_window_make_fullscreen_internal (MetaWindow *window)
"Fullscreening %s\n", window->desc); "Fullscreening %s\n", window->desc);
if (window->shaded) 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); meta_window_save_rect (window);
@ -2438,7 +2470,8 @@ meta_window_unmake_fullscreen (MetaWindow *window)
} }
void void
meta_window_shade (MetaWindow *window) meta_window_shade (MetaWindow *window,
guint32 timestamp)
{ {
meta_topic (META_DEBUG_WINDOW_OPS, meta_topic (META_DEBUG_WINDOW_OPS,
"Shading %s\n", window->desc); "Shading %s\n", window->desc);
@ -2479,15 +2512,15 @@ meta_window_shade (MetaWindow *window)
meta_topic (META_DEBUG_FOCUS, meta_topic (META_DEBUG_FOCUS,
"Re-focusing window %s after shading it\n", "Re-focusing window %s after shading it\n",
window->desc); window->desc);
meta_window_focus (window, meta_window_focus (window, timestamp);
meta_display_get_current_time_roundtrip (window->display));
set_net_wm_state (window); set_net_wm_state (window);
} }
} }
void void
meta_window_unshade (MetaWindow *window) meta_window_unshade (MetaWindow *window,
guint32 timestamp)
{ {
meta_topic (META_DEBUG_WINDOW_OPS, meta_topic (META_DEBUG_WINDOW_OPS,
"Unshading %s\n", window->desc); "Unshading %s\n", window->desc);
@ -2501,8 +2534,7 @@ meta_window_unshade (MetaWindow *window)
meta_topic (META_DEBUG_FOCUS, meta_topic (META_DEBUG_FOCUS,
"Focusing window %s after unshading it\n", "Focusing window %s after unshading it\n",
window->desc); window->desc);
meta_window_focus (window, meta_window_focus (window, timestamp);
meta_display_get_current_time_roundtrip (window->display));
set_net_wm_state (window); set_net_wm_state (window);
} }
@ -2556,11 +2588,12 @@ window_activate (MetaWindow *window,
} }
/* For those stupid pagers, get a valid timestamp and show a warning */ /* For those stupid pagers, get a valid timestamp and show a warning */
if (timestamp == 0) { if (timestamp == 0)
meta_warning ("meta_window_activate called by a pager with a 0 timestamp; " {
"the pager needs to be fixed.\n"); meta_warning ("meta_window_activate called by a pager with a 0 timestamp; "
timestamp = meta_display_get_current_time_roundtrip (window->display); "the pager needs to be fixed.\n");
} timestamp = meta_display_get_current_time_roundtrip (window->display);
}
meta_window_set_user_time (window, timestamp); meta_window_set_user_time (window, timestamp);
@ -2574,7 +2607,7 @@ window_activate (MetaWindow *window,
meta_window_change_workspace (window, workspace); meta_window_change_workspace (window, workspace);
if (window->shaded) if (window->shaded)
meta_window_unshade (window); meta_window_unshade (window, timestamp);
unminimize_window_and_all_transient_parents (window); unminimize_window_and_all_transient_parents (window);
@ -2772,6 +2805,11 @@ send_sync_request (MetaWindow *window)
ev.message_type = window->display->atom_wm_protocols; ev.message_type = window->display->atom_wm_protocols;
ev.format = 32; ev.format = 32;
ev.data.l[0] = window->display->atom_net_wm_sync_request; 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[1] = meta_display_get_current_time (window->display);
ev.data.l[2] = XSyncValueLow32 (value); ev.data.l[2] = XSyncValueLow32 (value);
ev.data.l[3] = XSyncValueHigh32 (value); ev.data.l[3] = XSyncValueHigh32 (value);
@ -4426,7 +4464,13 @@ meta_window_client_message (MetaWindow *window,
if (event->xclient.data.l[0] != 0) if (event->xclient.data.l[0] != 0)
timestamp = event->xclient.data.l[0]; timestamp = event->xclient.data.l[0];
else 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); meta_window_delete (window, timestamp);
@ -4506,13 +4550,20 @@ meta_window_client_message (MetaWindow *window,
second == display->atom_net_wm_state_shaded) second == display->atom_net_wm_state_shaded)
{ {
gboolean shade; 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 || shade = (action == _NET_WM_STATE_ADD ||
(action == _NET_WM_STATE_TOGGLE && !window->shaded)); (action == _NET_WM_STATE_TOGGLE && !window->shaded));
if (shade && window->has_shade_func) if (shade && window->has_shade_func)
meta_window_shade (window); meta_window_shade (window, timestamp);
else else
meta_window_unshade (window); meta_window_unshade (window, timestamp);
} }
if (first == display->atom_net_wm_state_fullscreen || if (first == display->atom_net_wm_state_fullscreen ||
@ -4658,12 +4709,18 @@ meta_window_client_message (MetaWindow *window,
int action; int action;
MetaGrabOp op; MetaGrabOp op;
int button; int button;
guint32 timestamp;
x_root = event->xclient.data.l[0]; x_root = event->xclient.data.l[0];
y_root = event->xclient.data.l[1]; y_root = event->xclient.data.l[1];
action = event->xclient.data.l[2]; action = event->xclient.data.l[2];
button = event->xclient.data.l[3]; 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, meta_topic (META_DEBUG_WINDOW_OPS,
"Received _NET_WM_MOVERESIZE message on %s, %d,%d action = %d, button %d\n", "Received _NET_WM_MOVERESIZE message on %s, %d,%d action = %d, button %d\n",
window->desc, window->desc,
@ -4713,10 +4770,7 @@ meta_window_client_message (MetaWindow *window,
((window->has_move_func && op == META_GRAB_OP_KEYBOARD_MOVING) || ((window->has_move_func && op == META_GRAB_OP_KEYBOARD_MOVING) ||
(window->has_resize_func && op == META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN))) (window->has_resize_func && op == META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN)))
{ {
meta_window_begin_grab_op (window, op, timestamp);
meta_window_begin_grab_op (window,
op,
meta_display_get_current_time (window->display));
} }
else if (op != META_GRAB_OP_NONE && else if (op != META_GRAB_OP_NONE &&
((window->has_move_func && op == META_GRAB_OP_MOVING) || ((window->has_move_func && op == META_GRAB_OP_MOVING) ||
@ -4766,7 +4820,7 @@ meta_window_client_message (MetaWindow *window,
op, op,
FALSE, 0 /* event_serial */, FALSE, 0 /* event_serial */,
button, 0, button, 0,
meta_display_get_current_time (window->display), timestamp,
x_root, x_root,
y_root); y_root);
} }
@ -4790,8 +4844,13 @@ meta_window_client_message (MetaWindow *window,
source_indication = META_CLIENT_TYPE_UNKNOWN; source_indication = META_CLIENT_TYPE_UNKNOWN;
if (timestamp == 0) 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); window_activate (window, timestamp, source_indication, NULL);
return TRUE; return TRUE;
@ -6095,11 +6154,11 @@ menu_callback (MetaWindowMenu *menu,
break; break;
case META_MENU_OP_UNSHADE: case META_MENU_OP_UNSHADE:
meta_window_unshade (window); meta_window_unshade (window, timestamp);
break; break;
case META_MENU_OP_SHADE: case META_MENU_OP_SHADE:
meta_window_shade (window); meta_window_shade (window, timestamp);
break; break;
case META_MENU_OP_MOVE_LEFT: case META_MENU_OP_MOVE_LEFT:
@ -6146,13 +6205,13 @@ menu_callback (MetaWindowMenu *menu,
case META_MENU_OP_MOVE: case META_MENU_OP_MOVE:
meta_window_begin_grab_op (window, meta_window_begin_grab_op (window,
META_GRAB_OP_KEYBOARD_MOVING, META_GRAB_OP_KEYBOARD_MOVING,
meta_display_get_current_time (window->display)); timestamp);
break; break;
case META_MENU_OP_RESIZE: case META_MENU_OP_RESIZE:
meta_window_begin_grab_op (window, meta_window_begin_grab_op (window,
META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN, META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN,
meta_display_get_current_time (window->display)); timestamp);
break; break;
case META_MENU_OP_RECOVER: case META_MENU_OP_RECOVER:
@ -6704,7 +6763,7 @@ static void
update_resize (MetaWindow *window, update_resize (MetaWindow *window,
gboolean snap, gboolean snap,
int x, int y, int x, int y,
gboolean force) gboolean force)
{ {
int dx, dy; int dx, dy;
int new_w, new_h; int new_w, new_h;
@ -7047,7 +7106,7 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
window->display->grab_last_user_action_was_snap, window->display->grab_last_user_action_was_snap,
window->display->grab_latest_motion_x, window->display->grab_latest_motion_x,
window->display->grab_latest_motion_y, window->display->grab_latest_motion_y,
TRUE); TRUE);
break; break;
default: default:
@ -7597,12 +7656,15 @@ meta_window_update_keyboard_resize (MetaWindow *window,
if (update_cursor) if (update_cursor)
{ {
guint32 timestamp;
/* FIXME: Using CurrentTime is really bad mojo */
timestamp = CurrentTime;
meta_display_set_grab_op_cursor (window->display, meta_display_set_grab_op_cursor (window->display,
NULL, NULL,
window->display->grab_op, window->display->grab_op,
TRUE, TRUE,
window->display->grab_xwindow, window->display->grab_xwindow,
meta_display_get_current_time (window->display)); timestamp);
} }
} }

View File

@ -381,7 +381,8 @@ MetaWindow* meta_window_new_with_attrs (MetaDisplay *display,
Window xwindow, Window xwindow,
gboolean must_be_viewable, gboolean must_be_viewable,
XWindowAttributes *attrs); 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_calc_showing (MetaWindow *window);
void meta_window_queue_calc_showing (MetaWindow *window); void meta_window_queue_calc_showing (MetaWindow *window);
void meta_window_minimize (MetaWindow *window); void meta_window_minimize (MetaWindow *window);
@ -395,8 +396,10 @@ void meta_window_unmaximize (MetaWindow *window,
MetaMaximizeFlags directions); MetaMaximizeFlags directions);
void meta_window_make_above (MetaWindow *window); void meta_window_make_above (MetaWindow *window);
void meta_window_unmake_above (MetaWindow *window); void meta_window_unmake_above (MetaWindow *window);
void meta_window_shade (MetaWindow *window); void meta_window_shade (MetaWindow *window,
void meta_window_unshade (MetaWindow *window); guint32 timestamp);
void meta_window_unshade (MetaWindow *window,
guint32 timestamp);
void meta_window_change_workspace (MetaWindow *window, void meta_window_change_workspace (MetaWindow *window,
MetaWorkspace *workspace); MetaWorkspace *workspace);
void meta_window_stick (MetaWindow *window); void meta_window_stick (MetaWindow *window);