Implement freezing of updates during resize

Replace the unused meta_compositor_set_updates() with
a reversed-meaning meta_compositor_set_updates_frozen(), and use
it to implement freezing application window updates during
interactive resizing. This avoids drawing new areas of the window
with blank content before the application has a chance to repaint.

https://bugzilla.gnome.org/show_bug.cgi?id=685463
This commit is contained in:
Owen W. Taylor
2011-06-13 17:53:23 -04:00
parent f6c3e48aa5
commit 8b57ecebda
6 changed files with 92 additions and 18 deletions

View File

@ -336,6 +336,9 @@ struct _MetaWindow
/* if non-NULL, the bounds of the window frame */
cairo_region_t *frame_bounds;
/* if TRUE, we are freezing updates during a resize */
guint updates_frozen_for_resize : 1;
/* Note: can be NULL */
GSList *struts;
@ -655,4 +658,6 @@ gboolean meta_window_can_tile_side_by_side (MetaWindow *window);
void meta_window_compute_tile_match (MetaWindow *window);
gboolean meta_window_updates_are_frozen (MetaWindow *window);
#endif

View File

@ -4466,6 +4466,37 @@ send_sync_request (MetaWindow *window)
}
#endif
/**
* meta_window_updates_are_frozen:
* @window: a #MetaWindow
*
* Gets whether the compositor should be updating the window contents;
* window content updates may be frozen at client request by setting
* an odd value in the extended _NET_WM_SYNC_REQUEST_COUNTER counter r
* by the window manager during a resize operation while waiting for
* the client to redraw.
*
* Return value: %TRUE if updates are currently frozen
*/
gboolean
meta_window_updates_are_frozen (MetaWindow *window)
{
return window->updates_frozen_for_resize;
}
static void
meta_window_set_updates_frozen_for_resize (MetaWindow *window,
gboolean updates_frozen)
{
if (updates_frozen != window->updates_frozen_for_resize)
{
window->updates_frozen_for_resize = updates_frozen;
if (window->display->compositor)
meta_compositor_set_updates_frozen (window->display->compositor, window,
meta_window_updates_are_frozen (window));
}
}
static gboolean
maybe_move_attached_dialog (MetaWindow *window,
void *data)
@ -4966,8 +4997,7 @@ meta_window_move_resize_internal (MetaWindow *window,
window->sync_request_time.tv_sec == 0)
{
/* turn off updating */
if (window->display->compositor)
meta_compositor_set_updates (window->display->compositor, window, FALSE);
meta_window_set_updates_frozen_for_resize (window, TRUE);
send_sync_request (window);
}
@ -9097,8 +9127,7 @@ update_resize (MetaWindow *window,
}
/* If we get here, it means the client should have redrawn itself */
if (window->display->compositor)
meta_compositor_set_updates (window->display->compositor, window, TRUE);
meta_window_set_updates_frozen_for_resize (window, FALSE);
/* Remove any scheduled compensation events */
if (window->display->grab_resize_timeout_id)
@ -9380,8 +9409,7 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
xev->root_x,
xev->root_y,
TRUE);
if (window->display->compositor)
meta_compositor_set_updates (window->display->compositor, window, TRUE);
meta_window_set_updates_frozen_for_resize (window, FALSE);
/* If a tiled window has been dragged free with a
* mouse resize without snapping back to the tiled