forked from AuroraMiddleware/gtk
window: Create default titlebar directly in realize
Instead of having two functions that are only called from one place but look like they can be called from anywhere.
This commit is contained in:
parent
ee9d99cba3
commit
9cc6ddf80d
@ -3762,17 +3762,6 @@ update_window_actions (GtkWindow *window)
|
||||
update_csd_visibility (window);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_titlebar (GtkWindow *window)
|
||||
{
|
||||
GtkWidget *titlebar = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (titlebar), TRUE);
|
||||
gtk_widget_add_css_class (titlebar, GTK_STYLE_CLASS_TITLEBAR);
|
||||
gtk_widget_add_css_class (titlebar, "default-decoration");
|
||||
|
||||
return titlebar;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_window_request_csd (GtkWindow *window)
|
||||
{
|
||||
@ -3817,28 +3806,6 @@ gtk_window_should_use_csd (GtkWindow *window)
|
||||
return (g_strcmp0 (csd_env, "1") == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
create_decoration (GtkWidget *widget)
|
||||
{
|
||||
GtkWindow *window = GTK_WINDOW (widget);
|
||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
||||
|
||||
priv->use_client_shadow = gtk_window_supports_client_shadow (window);
|
||||
if (!priv->use_client_shadow)
|
||||
return;
|
||||
|
||||
gtk_window_enable_csd (window);
|
||||
|
||||
if (priv->title_box == NULL)
|
||||
{
|
||||
priv->titlebar = create_titlebar (window);
|
||||
gtk_widget_set_parent (priv->titlebar, widget);
|
||||
priv->title_box = priv->titlebar;
|
||||
}
|
||||
|
||||
update_window_actions (window);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_window_show (GtkWidget *widget)
|
||||
{
|
||||
@ -4331,8 +4298,28 @@ gtk_window_realize (GtkWidget *widget)
|
||||
GdkSurface *surface;
|
||||
GtkBorder shadow;
|
||||
|
||||
/* Create default title bar */
|
||||
if (!priv->client_decorated && gtk_window_should_use_csd (window))
|
||||
create_decoration (widget);
|
||||
{
|
||||
priv->use_client_shadow = gtk_window_supports_client_shadow (window);
|
||||
if (priv->use_client_shadow)
|
||||
{
|
||||
gtk_window_enable_csd (window);
|
||||
|
||||
if (priv->title_box == NULL)
|
||||
{
|
||||
priv->titlebar = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (priv->titlebar), TRUE);
|
||||
gtk_widget_add_css_class (priv->titlebar, GTK_STYLE_CLASS_TITLEBAR);
|
||||
gtk_widget_add_css_class (priv->titlebar, "default-decoration");
|
||||
|
||||
gtk_widget_set_parent (priv->titlebar, widget);
|
||||
priv->title_box = priv->titlebar;
|
||||
}
|
||||
|
||||
update_window_actions (window);
|
||||
}
|
||||
}
|
||||
|
||||
get_shadow_width (window, &shadow);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user