Merge lp:~3v1n0/gtk/unity-maximized-headerbar-buttons-hide into lp:~ubuntu-desktop/gtk/ubuntugtk3

Proposed by Marco Trevisan (Treviño)
Status: Merged
Merged at revision: 511
Proposed branch: lp:~3v1n0/gtk/unity-maximized-headerbar-buttons-hide
Merge into: lp:~ubuntu-desktop/gtk/ubuntugtk3
Prerequisite: lp:~3v1n0/gtk/unity-border-radius-support
Diff against target: 162 lines (+139/-0)
3 files modified
debian/changelog (+2/-0)
debian/patches/series (+1/-0)
debian/patches/unity-headerbar-maximized-mode.patch (+136/-0)
To merge this branch: bzr merge lp:~3v1n0/gtk/unity-maximized-headerbar-buttons-hide
Reviewer Review Type Date Requested Status
Ubuntu Desktop Pending
Review via email: mp+288552@code.launchpad.net

Commit message

debian/patches/gtk-shell-shows-window-buttons.patch:
  - Hide headerbar window buttons when a window is maximized in Unity

Description of the change

This will work once lp:~3v1n0/unity/gtk-border-radius-support lands, as it depends on the _UNITY_SHELL atom that we don't export yet.

To post a comment you must log in.
506. By Marco Trevisan (Treviño)

debian/patches/unity-border-radius.patch:
 - Don't draw window border in unity for any theme. Add unity-csd style class.

507. By Marco Trevisan (Treviño)

debian/patches/unity-headerbar-maximized-mode.patch:
  - Hide headerbar window buttons when a window is maximized in Unity

508. By Marco Trevisan (Treviño)

debian/patches/unity-headerbar-maximized-mode.patch: hide title label when maximized

509. By Marco Trevisan (Treviño)

Merging with lp:~3v1n0/gtk/unity-border-radius-support

510. By Marco Trevisan (Treviño)

debian/patches/unity-headerbar-maximized-mode.patch: hide title in unity when maximized

Also, set the toolbar-mode style class also when the headerbar has no window controls

511. By Marco Trevisan (Treviño)

debian/patches/unity-headerbar-maximized-mode.patch: hide label on construction if toplevel is maximized

512. By Marco Trevisan (Treviño)

debian/patches/unity-headerbar-maximized-mode.patch: only hide title if it matches with the toplevel title

513. By Marco Trevisan (Treviño)

debian/patches/unity-headerbar-maximized-mode.patch: use gtk_widget_set_visible

514. By Marco Trevisan (Treviño)

Merging with lp:~3v1n0/gtk/unity-border-radius-support

Revision history for this message
Allison Karlitskaya (desrt) wrote :

Should we perhaps consider integrating this into the logic in gtkwindow.c about gtk_window_set_hide_titlebar_when_maximized()? The logic here seems to be a little bit inside out with regard to registering for events on the window and then verifying with the window that we are indeed the correct titlebar for receiving these actions, when the window itself knows which one is the real titlebar...

We have a bad history of unexpected things happening when we hide widgets like this... we used to hide GtkMenuBar from dbusmenu and it broke all kinds of things... I can imagine some app code somewhere getting upset because of this.

515. By Marco Trevisan (Treviño)

Merging with lp:~ubuntu-desktop/gtk/ubuntugtk3

516. By Marco Trevisan (Treviño)

debian/patches/unity-headerbar-maximized-mode.patch: hide titlebar if the current headerbar is the window titlebar

Revision history for this message
Allison Karlitskaya (desrt) wrote :

This patch looks pretty good now, but as usual, I cannot ACK (nor comment on the debian/ bits).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2016-03-18 18:26:51 +0000
3+++ debian/changelog 2016-03-23 16:07:42 +0000
4@@ -4,6 +4,8 @@
5 - Export windows corners radius as an X11 property in unity (LP: #1516403)
6 * debian/patches/unity_rbga_tooltips.patch:
7 - Removed as it's now included in the border-radius patch
8+ * debian/patches/unity-headerbar-maximized-mode.patch:
9+ - Hide headerbar window buttons when a window is maximized in Unity (LP: #1515810)
10
11 -- Marco Trevisan (Treviño) <marco@ubuntu.com> Tue, 15 Mar 2016 18:40:42 +0100
12
13
14=== modified file 'debian/patches/series'
15--- debian/patches/series 2016-03-15 17:41:31 +0000
16+++ debian/patches/series 2016-03-23 16:07:42 +0000
17@@ -25,3 +25,4 @@
18 0001-gtkwindow-set-transparent-background-color.patch
19 ubuntu_fileselector_behaviour.patch
20 unity-border-radius.patch
21+unity-headerbar-maximized-mode.patch
22
23=== added file 'debian/patches/unity-headerbar-maximized-mode.patch'
24--- debian/patches/unity-headerbar-maximized-mode.patch 1970-01-01 00:00:00 +0000
25+++ debian/patches/unity-headerbar-maximized-mode.patch 2016-03-23 16:07:42 +0000
26@@ -0,0 +1,136 @@
27+Description: Hide Headerbar window buttons and title when running in Unity
28+ and the window is maximized.
29+ Plus define the "toolbar-mode" style class on these maximized bars.
30+Author: Marco Trevisan <marco.trevisan@canonical.com>
31+Bug-Ubuntu: https://launchpad.net/bugs/1515810
32+
33+Index: gtk+3.0-3.18.8/gtk/gtkheaderbar.c
34+===================================================================
35+--- gtk+3.0-3.18.8.orig/gtk/gtkheaderbar.c
36++++ gtk+3.0-3.18.8/gtk/gtkheaderbar.c
37+@@ -31,6 +31,10 @@
38+
39+ #include <string.h>
40+
41++#ifdef GDK_WINDOWING_X11
42++#include "x11/gdkx.h"
43++#endif
44++
45+ /**
46+ * SECTION:gtkheaderbar
47+ * @Short_description: A box with a centered child
48+@@ -65,6 +69,7 @@ struct _GtkHeaderBarPrivate
49+ GtkWidget *custom_title;
50+ gint spacing;
51+ gboolean has_subtitle;
52++ gboolean unity_environment;
53+
54+ GList *children;
55+
56+@@ -276,6 +281,36 @@ _gtk_header_bar_update_separator_visibil
57+ gtk_widget_set_visible (priv->titlebar_end_separator, have_visible_at_end);
58+ }
59+
60++static void
61++check_title_visibility (GtkHeaderBar *bar)
62++{
63++ GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
64++ gboolean visible = TRUE;
65++
66++ if (!priv->title_label)
67++ return;
68++
69++
70++ if (priv->unity_environment)
71++ {
72++ GtkWidget *widget = GTK_WIDGET (bar);
73++ GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
74++
75++ if (GTK_IS_WINDOW (toplevel))
76++ {
77++ GtkWindow *window = GTK_WINDOW (toplevel);
78++
79++ if (gtk_window_is_maximized (window) &&
80++ gtk_window_get_titlebar (window) == widget)
81++ {
82++ visible = FALSE;
83++ }
84++ }
85++ }
86++
87++ gtk_widget_set_visible (priv->title_label, visible);
88++}
89++
90+ void
91+ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
92+ {
93+@@ -307,6 +342,20 @@ _gtk_header_bar_update_window_buttons (G
94+ }
95+
96+ priv->titlebar_icon = NULL;
97++ window = GTK_WINDOW (gtk_widget_get_toplevel (widget));
98++
99++ if (priv->unity_environment)
100++ {
101++ check_title_visibility (bar);
102++
103++ if (gtk_window_is_maximized (window))
104++ {
105++ gtk_style_context_add_class (gtk_widget_get_style_context (widget), "toolbar-mode");
106++ return;
107++ }
108++
109++ gtk_style_context_remove_class (gtk_widget_get_style_context (widget), "toolbar-mode");
110++ }
111+
112+ if (!priv->shows_wm_decorations)
113+ return;
114+@@ -324,7 +373,6 @@ _gtk_header_bar_update_window_buttons (G
115+ layout_desc = g_strdup (priv->decoration_layout);
116+ }
117+
118+- window = GTK_WINDOW (gtk_widget_get_toplevel (widget));
119+
120+ if (!shown_by_shell && gtk_window_get_application (window))
121+ menu = gtk_application_get_app_menu (gtk_window_get_application (window));
122+@@ -580,6 +628,8 @@ construct_label_box (GtkHeaderBar *bar)
123+ &priv->subtitle_label);
124+ gtk_header_bar_reorder_css_node (bar, GTK_PACK_START, priv->label_box);
125+ gtk_widget_set_parent (priv->label_box, GTK_WIDGET (bar));
126++
127++ check_title_visibility (bar);
128+ }
129+
130+ static void
131+@@ -1808,6 +1858,22 @@ gtk_header_bar_realize (GtkWidget *widge
132+
133+ GTK_WIDGET_CLASS (gtk_header_bar_parent_class)->realize (widget);
134+
135++#ifdef GDK_WINDOWING_X11
136++ GtkHeaderBar *bar;
137++ GtkHeaderBarPrivate *priv;
138++ GdkScreen *screen;
139++
140++ bar = GTK_HEADER_BAR (widget);
141++ priv = gtk_header_bar_get_instance_private (bar);
142++ screen = gtk_widget_get_screen (widget);
143++
144++ if (GDK_IS_X11_SCREEN (screen))
145++ {
146++ GdkAtom unity_atom = gdk_atom_intern_static_string ("_UNITY_SHELL");
147++ priv->unity_environment = gdk_x11_screen_supports_net_wm_hint (screen, unity_atom);
148++ }
149++#endif
150++
151+ settings = gtk_widget_get_settings (widget);
152+ g_signal_connect_swapped (settings, "notify::gtk-shell-shows-app-menu",
153+ G_CALLBACK (_gtk_header_bar_update_window_buttons), widget);
154+@@ -1856,6 +1922,8 @@ gtk_header_bar_hierarchy_changed (GtkWid
155+ if (toplevel)
156+ g_signal_connect_after (toplevel, "window-state-event",
157+ G_CALLBACK (window_state_changed), widget);
158++
159++ check_title_visibility (GTK_HEADER_BAR (widget));
160+ }
161+
162+ static void

Subscribers

People subscribed via source and target branches