[x11] Do not ask to destroy an empty Window

The fix for bug 1750 inside commit b190448e made Clutter-GTK spew
BadWindow errors. The reason for that is that we call XDestroyWindow()
without checking if the old Window is None; this happens if we call
clutter_x11_set_stage_foreign() on a new ClutterStage before it has
been realized.

Since Clutter-GTK does not need to realize the Stage it is going to
embed anymore (the only reason for that was to obtain a proper Visual
but now there's ClutterBackendX11 API for that), the set_stage_foreign()
call is effectively setting the StageX11 Window for the first time.
This commit is contained in:
Emmanuele Bassi 2009-08-07 08:18:17 +01:00
parent 335fb07ab0
commit 420ed353b5

View File

@ -790,10 +790,15 @@ set_foreign_window_callback (ClutterActor *actor,
{
ForeignWindowData *fwd = data;
CLUTTER_NOTE (BACKEND, "Setting foreign window (0x%x)", (int) fwd->xwindow);
CLUTTER_NOTE (BACKEND, "Setting foreign window (0x%x)",
(unsigned int) fwd->xwindow);
if (fwd->destroy_old_xwindow)
XDestroyWindow (fwd->stage_x11->xdpy, fwd->stage_x11->xwin);
if (fwd->destroy_old_xwindow && fwd->stage_x11->xwin != None)
{
CLUTTER_NOTE (BACKEND, "Destroying previous window (0x%x)",
(unsigned int) fwd->xwindow);
XDestroyWindow (fwd->stage_x11->xdpy, fwd->stage_x11->xwin);
}
fwd->stage_x11->xwin = fwd->xwindow;
fwd->stage_x11->is_foreign_xwin = TRUE;
@ -862,8 +867,13 @@ clutter_x11_set_stage_foreign (ClutterStage *stage,
fwd.stage_x11 = stage_x11;
fwd.xwindow = xwindow;
/* destroy the old Window, if we own it */
fwd.destroy_old_xwindow = stage_x11->is_foreign_xwin ? FALSE : TRUE;
/* destroy the old Window, if we have one and it's ours */
if (stage_x11->xwin != None && !stage_x11->is_foreign_xwin)
fwd.destroy_old_xwindow = TRUE;
else
fwd.destroy_old_xwindow = FALSE;
fwd.geom.x = x;
fwd.geom.y = y;
fwd.geom.width = width;