From 9fb729ccc01dadc674aab23981cff78eaef2059f Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 21 Sep 2021 03:39:19 +0200 Subject: [PATCH] window: Improve set_titlebar() function Get rid of a goto and check if the titlebar is already set. --- gtk/gtkwindow.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index a1a34359c9..dcb39a05c2 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -3000,6 +3000,9 @@ gtk_window_set_titlebar (GtkWindow *window, g_return_if_fail (GTK_IS_WINDOW (window)); + if (priv->title_box == titlebar) + return; + if ((!priv->title_box && titlebar) || (priv->title_box && !titlebar)) { was_mapped = _gtk_widget_get_mapped (widget); @@ -3020,19 +3023,18 @@ gtk_window_set_titlebar (GtkWindow *window, priv->client_decorated = FALSE; gtk_widget_remove_css_class (widget, "csd"); gtk_widget_remove_css_class (widget, "solid-csd"); + } + else + { + priv->use_client_shadow = gtk_window_supports_client_shadow (window); - goto out; + gtk_window_enable_csd (window); + priv->title_box = titlebar; + gtk_widget_insert_before (priv->title_box, widget, NULL); + + gtk_widget_add_css_class (titlebar, "titlebar"); } - priv->use_client_shadow = gtk_window_supports_client_shadow (window); - - gtk_window_enable_csd (window); - priv->title_box = titlebar; - gtk_widget_insert_before (priv->title_box, widget, NULL); - - gtk_widget_add_css_class (titlebar, "titlebar"); - -out: if (was_mapped) gtk_widget_map (widget); }