[x11] Proper fix for the ClutterStage resize race

Continuation of the fix in commit 00a3c69868.

Instead of using a separate flag for the resize process, just
delay the setting of the CLUTTER_ACTOR_SYNC_MATRICES flag on the
stage to the point when we receive a ConfigureNotify event from
X11.

This commit will break the stage embedding into other toolkits.
This commit is contained in:
Emmanuele Bassi 2009-01-12 11:15:41 +00:00
parent 2693ea3ddc
commit 4f6cc0b25f
5 changed files with 22 additions and 28 deletions

View File

@ -251,9 +251,6 @@ _clutter_backend_ensure_context (ClutterBackend *backend,
* potential issue of GL calls with no context)
*/
current_context_stage = stage;
if (stage)
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES);
}
else
CLUTTER_NOTE (MULTISTAGE, "Stage is the same");

View File

@ -147,8 +147,7 @@ _clutter_stage_maybe_relayout (ClutterActor *stage)
void
_clutter_stage_maybe_setup_viewport (ClutterStage *stage)
{
if ((CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_ACTOR_SYNC_MATRICES) &&
!(CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_STAGE_IN_RESIZE))
if (CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_ACTOR_SYNC_MATRICES)
{
ClutterPerspective perspective;
guint width, height;

View File

@ -62,8 +62,7 @@ typedef enum {
*/
CLUTTER_ACTOR_IN_PAINT = 1 << 4, /* Used to avoid recursion */
CLUTTER_ACTOR_IN_RELAYOUT = 1 << 5, /* Used to avoid recursion */
CLUTTER_TEXTURE_IN_CLONE_PAINT = 1 << 6, /* Used for safety in clones */
CLUTTER_STAGE_IN_RESIZE = 1 << 7 /* Used to mark stage resizes */
CLUTTER_TEXTURE_IN_CLONE_PAINT = 1 << 6 /* Used for safety in clones */
} ClutterPrivateFlags;
typedef enum {

View File

@ -433,17 +433,23 @@ event_translate (ClutterBackend *backend,
it from trying to resize the window again */
stage_x11->handling_configure = TRUE;
CLUTTER_NOTE (BACKEND, "%s: ConfigureNotify[%x] (%d, %d)",
G_STRLOC,
(unsigned int) stage_x11->xwin,
xevent->xconfigure.width,
xevent->xconfigure.height);
clutter_actor_set_size (CLUTTER_ACTOR (stage),
xevent->xconfigure.width,
xevent->xconfigure.height);
stage_x11->handling_configure = FALSE;
/* the resize process is complete, so we can remove the
* in-resize flag and allow the viewport to be resized
/* the resize process is complete, so we can ask the stage
* to set up the GL viewport with the new size
*/
CLUTTER_UNSET_PRIVATE_FLAGS (CLUTTER_ACTOR (stage_x11->wrapper),
CLUTTER_STAGE_IN_RESIZE);
CLUTTER_SET_PRIVATE_FLAGS (CLUTTER_ACTOR (stage_x11->wrapper),
CLUTTER_ACTOR_SYNC_MATRICES);
}
res = FALSE;
break;

View File

@ -286,27 +286,18 @@ clutter_stage_x11_allocate (ClutterActor *self,
!stage_x11->is_foreign_xwin &&
!stage_x11->handling_configure)
{
CLUTTER_NOTE (BACKEND, "%s: XResizeWindow[%x] (%d, %d)",
G_STRLOC,
(unsigned int) stage_x11->xwin,
stage_x11->xwin_width,
stage_x11->xwin_height);
XResizeWindow (stage_x11->xdpy,
stage_x11->xwin,
stage_x11->xwin_width,
stage_x11->xwin_height);
/* resizing is an asynchronous process; to avoid races
* with the window manager, we flag the wrapper as being
* "in resize", so that the SYNC_MATRICES flag will not
* cause a call to cogl_get_viewport().
*
* the flag is unset inside clutter-event-x11.c, after
* we receive a ConfigureNotify event. XXX - need to
* check what happens when running without a window manager
*/
CLUTTER_SET_PRIVATE_FLAGS (CLUTTER_ACTOR (stage_x11->wrapper),
CLUTTER_STAGE_IN_RESIZE);
}
CLUTTER_SET_PRIVATE_FLAGS (CLUTTER_ACTOR (stage_x11->wrapper),
CLUTTER_ACTOR_SYNC_MATRICES);
clutter_stage_x11_fix_window_size (stage_x11);
if (stage_x11->xpixmap != None)
@ -411,6 +402,8 @@ clutter_stage_x11_set_fullscreen (ClutterStageWindow *stage_window,
if (!stage)
return;
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES);
if (is_fullscreen)
{
int width, height;
@ -493,8 +486,6 @@ clutter_stage_x11_set_fullscreen (ClutterStageWindow *stage_window,
stage_x11->fullscreen_on_map = FALSE;
}
}
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES);
}
static void
@ -754,6 +745,8 @@ clutter_x11_set_stage_foreign (ClutterStage *stage,
clutter_actor_set_geometry (actor, &geom);
clutter_actor_realize (actor);
CLUTTER_SET_PRIVATE_FLAGS (actor, CLUTTER_ACTOR_SYNC_MATRICES);
return TRUE;
}