clutter-stage-x11: Don't ensure the viewport when the window moves

When we receive a ConfigureNotify event that doesn't affect the size
of the window (only the position) then we were still calling
clutter_stage_ensure_viewport which ends up queueing a full stage
redraw. This patch makes it so that it only ensures the viewport when
the size changes as it already did for avoiding queueing a relayout.

It now also avoids setting the clipped redraws cool off period when
the window only moves under the assumption that it's only necessary
for size changes.
This commit is contained in:
Neil Roberts 2011-01-25 15:53:35 +00:00
parent dc6f6d6445
commit e7519a149b

View File

@ -886,36 +886,23 @@ clutter_stage_x11_translate_event (ClutterEventTranslator *translator,
case ConfigureNotify:
if (!stage_x11->is_foreign_xwin)
{
gboolean size_changed = FALSE;
CLUTTER_NOTE (BACKEND, "%s: ConfigureNotify[%x] (%d, %d)",
G_STRLOC,
(unsigned int) stage_x11->xwin,
xevent->xconfigure.width,
xevent->xconfigure.height);
/* Queue a relayout - we want glViewport to be called
* with the correct values, and this is done in ClutterStage
* via _cogl_onscreen_clutter_backend_set_size ().
*
* We queue a relayout, because if this ConfigureNotify is
* in response to a size we set in the application, the
* set_size() call below is essentially a null-op.
*
* Make sure we do this only when the size has changed,
* otherwise we end up relayouting on window moves.
*/
if ((stage_x11->state & CLUTTER_STAGE_STATE_FULLSCREEN) ||
(stage_x11->xwin_width != xevent->xconfigure.width) ||
/* When fullscreen, we'll keep the xwin_width/height
variables to track the old size of the window and we'll
assume all ConfigureNotifies constitute a size change */
if ((stage_x11->state & CLUTTER_STAGE_STATE_FULLSCREEN))
size_changed = TRUE;
else if ((stage_x11->xwin_width != xevent->xconfigure.width) ||
(stage_x11->xwin_height != xevent->xconfigure.height))
{
clutter_actor_queue_relayout (CLUTTER_ACTOR (stage));
}
/* If we're fullscreened, we want these variables to
* represent the size of the window before it was set
* to fullscreen.
*/
if (!(stage_x11->state & CLUTTER_STAGE_STATE_FULLSCREEN))
{
size_changed = TRUE;
stage_x11->xwin_width = xevent->xconfigure.width;
stage_x11->xwin_height = xevent->xconfigure.height;
}
@ -924,6 +911,10 @@ clutter_stage_x11_translate_event (ClutterEventTranslator *translator,
xevent->xconfigure.width,
xevent->xconfigure.height);
CLUTTER_UNSET_PRIVATE_FLAGS (stage_x11->wrapper, CLUTTER_IN_RESIZE);
if (size_changed)
{
/* XXX: This is a workaround for a race condition when
* resizing windows while there are in-flight
* glXCopySubBuffer blits happening.
@ -960,15 +951,28 @@ clutter_stage_x11_translate_event (ClutterEventTranslator *translator,
g_source_remove (stage_x11->clipped_redraws_cool_off);
stage_x11->clipped_redraws_cool_off =
g_timeout_add_seconds (1, clipped_redraws_cool_off_cb, stage_x11);
g_timeout_add_seconds (1, clipped_redraws_cool_off_cb,
stage_x11);
CLUTTER_UNSET_PRIVATE_FLAGS (stage_x11->wrapper, CLUTTER_IN_RESIZE);
/* Queue a relayout - we want glViewport to be called
* with the correct values, and this is done in ClutterStage
* via _cogl_onscreen_clutter_backend_set_size ().
*
* We queue a relayout, because if this ConfigureNotify is
* in response to a size we set in the application, the
* set_size() call above is essentially a null-op.
*
* Make sure we do this only when the size has changed,
* otherwise we end up relayouting on window moves.
*/
clutter_actor_queue_relayout (CLUTTER_ACTOR (stage));
/* the resize process is complete, so we can ask the stage
* to set up the GL viewport with the new size
*/
clutter_stage_ensure_viewport (stage);
}
}
break;
case PropertyNotify: