mirror of
https://github.com/brl/mutter.git
synced 2025-02-23 08:24:09 +00:00
gdk: Fix Stage foreign window support
The code is generally wrong, and does not work. We need to skip the GdkWindow creation when we have a foreing window, but we still need to create the Cogl onscreen buffer and connect it to the GdkWindow's native resource.
This commit is contained in:
parent
f14cbf5bdb
commit
f58d393187
@ -107,7 +107,7 @@ clutter_stage_gdk_set_gdk_geometry (ClutterStageGdk *stage)
|
||||
|
||||
static void
|
||||
clutter_stage_gdk_get_geometry (ClutterStageWindow *stage_window,
|
||||
ClutterGeometry *geometry)
|
||||
cairo_rectangle_int_t *geometry)
|
||||
{
|
||||
ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
|
||||
|
||||
@ -157,12 +157,16 @@ clutter_stage_gdk_unrealize (ClutterStageWindow *stage_window)
|
||||
{
|
||||
g_object_set_data (G_OBJECT (stage_gdk->window),
|
||||
"clutter-stage-window", NULL);
|
||||
|
||||
if (stage_gdk->foreign_window)
|
||||
g_object_unref (stage_gdk->window);
|
||||
else
|
||||
gdk_window_destroy (stage_gdk->window);
|
||||
|
||||
stage_gdk->window = NULL;
|
||||
}
|
||||
|
||||
return clutter_stage_window_parent_iface->unrealize (stage_window);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -177,22 +181,25 @@ clutter_stage_gdk_realize (ClutterStageWindow *stage_window)
|
||||
gboolean use_alpha;
|
||||
gfloat width, height;
|
||||
|
||||
if (stage_gdk->foreign_window &&
|
||||
stage_gdk->window != NULL)
|
||||
if (!stage_gdk->foreign_window)
|
||||
{
|
||||
if (stage_gdk->window != NULL)
|
||||
{
|
||||
/* complete realizing the stage */
|
||||
ClutterGeometry geometry;
|
||||
cairo_rectangle_int_t geometry;
|
||||
|
||||
clutter_stage_gdk_get_geometry (stage_window, &geometry);
|
||||
clutter_actor_set_geometry (CLUTTER_ACTOR (stage_cogl->wrapper), &geometry);
|
||||
clutter_actor_set_size (CLUTTER_ACTOR (stage_cogl->wrapper),
|
||||
geometry.width,
|
||||
geometry.height);
|
||||
|
||||
gdk_window_ensure_native (stage_gdk->window);
|
||||
gdk_window_set_events (stage_gdk->window,
|
||||
CLUTTER_STAGE_GDK_EVENT_MASK);
|
||||
gdk_window_set_events (stage_gdk->window, CLUTTER_STAGE_GDK_EVENT_MASK);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
attributes.title = NULL;
|
||||
g_object_get (stage_cogl->wrapper,
|
||||
"cursor-visible", &cursor_visible,
|
||||
@ -232,25 +239,21 @@ clutter_stage_gdk_realize (ClutterStageWindow *stage_window)
|
||||
attributes.visual = gdk_screen_get_system_visual (backend_gdk->screen);
|
||||
}
|
||||
|
||||
if (stage_gdk->window != NULL)
|
||||
{
|
||||
g_critical ("Stage realized more than once");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
stage_gdk->foreign_window = FALSE;
|
||||
stage_gdk->window = gdk_window_new (NULL, &attributes,
|
||||
GDK_WA_TITLE | GDK_WA_CURSOR | GDK_WA_VISUAL);
|
||||
gdk_window_ensure_native (stage_gdk->window);
|
||||
|
||||
g_free (attributes.title);
|
||||
}
|
||||
|
||||
clutter_stage_gdk_set_gdk_geometry (stage_gdk);
|
||||
}
|
||||
|
||||
gdk_window_ensure_native (stage_gdk->window);
|
||||
|
||||
g_object_set_data (G_OBJECT (stage_gdk->window),
|
||||
"clutter-stage-window", stage_gdk);
|
||||
|
||||
g_free (attributes.title);
|
||||
|
||||
stage_cogl->onscreen = cogl_onscreen_new (backend->cogl_context,
|
||||
width, height);
|
||||
|
||||
@ -279,7 +282,9 @@ clutter_stage_gdk_realize (ClutterStageWindow *stage_window)
|
||||
cogl_object_unref (stage_cogl->onscreen);
|
||||
stage_cogl->onscreen = NULL;
|
||||
|
||||
if (!stage_gdk->foreign_window)
|
||||
gdk_window_destroy (stage_gdk->window);
|
||||
|
||||
stage_gdk->window = NULL;
|
||||
|
||||
return FALSE;
|
||||
@ -570,6 +575,7 @@ clutter_gdk_set_stage_foreign (ClutterStage *stage,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
gdk_window_get_user_data (window, >k_data);
|
||||
if (gtk_data != NULL)
|
||||
{
|
||||
@ -577,6 +583,7 @@ clutter_gdk_set_stage_foreign (ClutterStage *stage,
|
||||
"Use a child GdkWindow for embedding instead");
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
closure.stage_gdk = stage_gdk;
|
||||
closure.window = g_object_ref (window);
|
||||
|
Loading…
x
Reference in New Issue
Block a user