diff options
author | Timm Bäder <mail@baedert.org> | 2020-05-20 10:11:37 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2020-05-20 18:12:22 +0200 |
commit | 9cc6ddf80d026d9204d7ab0b67f6ebcbea6391ab (patch) | |
tree | 4944f933f31cdda130a2af4723db3d7c3da65c2c /gtk/gtkwindow.c | |
parent | ee9d99cba3803f926ffed1733d9bd282ade6f84e (diff) | |
download | gtk+-9cc6ddf80d026d9204d7ab0b67f6ebcbea6391ab.tar.gz |
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.
Diffstat (limited to 'gtk/gtkwindow.c')
-rw-r--r-- | gtk/gtkwindow.c | 55 |
1 files changed, 21 insertions, 34 deletions
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 944a1e5d2b..32d31a5ee5 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -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) { @@ -3818,28 +3807,6 @@ gtk_window_should_use_csd (GtkWindow *window) } 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) { GtkWindow *window = GTK_WINDOW (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); |