GtkWindow: Create renderer before realizing child widgets

This way the child widgets can rely on the renderer (for example what
type it is) to decide details about how they render (such as if they
should use OpenGL shaders).
This commit is contained in:
Alexander Larsson 2020-09-28 20:47:32 +02:00
parent a91b6b4786
commit 645fc6a9a5

View File

@ -4387,6 +4387,9 @@ gtk_window_realize (GtkWidget *widget)
priv->surface = surface; priv->surface = surface;
gdk_surface_set_widget (surface, widget); gdk_surface_set_widget (surface, widget);
if (priv->renderer == NULL)
priv->renderer = gsk_renderer_new_for_surface (surface);
g_signal_connect_swapped (surface, "notify::state", G_CALLBACK (surface_state_changed), widget); g_signal_connect_swapped (surface, "notify::state", G_CALLBACK (surface_state_changed), widget);
g_signal_connect_swapped (surface, "size-changed", G_CALLBACK (surface_size_changed), widget); g_signal_connect_swapped (surface, "size-changed", G_CALLBACK (surface_size_changed), widget);
g_signal_connect (surface, "render", G_CALLBACK (surface_render), widget); g_signal_connect (surface, "render", G_CALLBACK (surface_render), widget);
@ -4397,9 +4400,6 @@ gtk_window_realize (GtkWidget *widget)
gtk_root_start_layout (GTK_ROOT (window)); gtk_root_start_layout (GTK_ROOT (window));
if (priv->renderer == NULL)
priv->renderer = gsk_renderer_new_for_surface (surface);
if (priv->transient_parent && if (priv->transient_parent &&
_gtk_widget_get_realized (GTK_WIDGET (priv->transient_parent))) _gtk_widget_get_realized (GTK_WIDGET (priv->transient_parent)))
{ {