Skip to content

Commit 264f84e

Browse files
committed
Bug 1974861 - Stop trying to read titlebar button spacing from the theme. r=stransky
We're getting the spacing from the wrong box (the headerbar, rather than the button box container). Even with that, some themes would use additional ways of creating spacing (paddings or margins). So in practice the 6px between buttons is just incorrect. Instead, just use the Adwaita spacing. We're using Adwaita styling anyways, so this makes the headerbar match perfectly in Gnome. With the Breeze theme (for KDE), this patch is closer than before (even though personally I might take some time to get used to it). We can also reduce it back to 6px between buttons in some DEs, if somebody complains, which is what we're shipping, effectively. Differential Revision: https://phabricator.services.mozilla.com/D256180
1 parent ee89fea commit 264f84e

File tree

6 files changed

+11
-28
lines changed

6 files changed

+11
-28
lines changed

browser/themes/linux/browser.css

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@
163163
.titlebar-buttonbox {
164164
z-index: 1;
165165
align-items: stretch;
166+
/* The spacing on each side of the titlebar button. In libadwaita, that's
167+
* 3px of gap + 5px * 2 of padding = 13px / 2, see:
168+
* https://gitlab.gnome.org/GNOME/libadwaita/-/blob/fe21c3c823443a8f2333cf3cc09ba3d0fa753228/src/stylesheet/widgets/_header-bar.scss#L164
169+
* We want a contiguous hit region so we use 6.5px of padding instead.
170+
*/
171+
--titlebar-button-spacing: 6.5px;
172+
--titlebar-button-end-spacing: 10px;
166173
--max-titlebar-button-position: max(
167174
env(-moz-gtk-csd-maximize-button-position),
168175
env(-moz-gtk-csd-minimize-button-position),
@@ -181,11 +188,10 @@
181188
color: inherit;
182189
align-items: center;
183190
padding: 0;
184-
padding-inline: calc(env(-moz-gtk-csd-titlebar-button-spacing) / 2);
185-
/* We want double the end spacing for the last button */
191+
padding-inline: var(--titlebar-button-spacing);
186192
padding-inline-end: max(
187-
env(-moz-gtk-csd-titlebar-button-spacing) / 2,
188-
env(-moz-gtk-csd-titlebar-button-spacing) * (var(--titlebar-button-position) - var(--max-titlebar-button-position) + 1)
193+
var(--titlebar-button-spacing),
194+
var(--titlebar-button-end-spacing) * (var(--titlebar-button-position) - var(--max-titlebar-button-position) + 1)
189195
);
190196
order: var(--titlebar-button-position);
191197
/* In GTK applications, you can drag the window by titlebar buttons */

servo/components/style/custom_properties.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,12 @@ fn eval_gtk_csd_titlebar_radius(device: &Device, url_data: &UrlExtraData) -> Var
153153
VariableValue::pixels(int_pixels as f32 * unzoomed_scale, url_data)
154154
}
155155

156-
static CHROME_ENVIRONMENT_VARIABLES: [EnvironmentVariable; 11] = [
156+
static CHROME_ENVIRONMENT_VARIABLES: [EnvironmentVariable; 10] = [
157157
lnf_int_variable!(
158158
atom!("-moz-mac-titlebar-height"),
159159
MacTitlebarHeight,
160160
int_pixels
161161
),
162-
lnf_int_variable!(
163-
atom!("-moz-gtk-csd-titlebar-button-spacing"),
164-
TitlebarButtonSpacing,
165-
int_pixels
166-
),
167162
make_variable!(
168163
atom!("-moz-gtk-csd-titlebar-radius"),
169164
eval_gtk_csd_titlebar_radius

widget/LookAndFeel.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,6 @@ class LookAndFeel {
302302
/** GTK titlebar radius */
303303
TitlebarRadius,
304304

305-
/** GTK button-to-button spacing in the inline axis */
306-
TitlebarButtonSpacing,
307-
308305
/** GTK tooltip radius */
309306
TooltipRadius,
310307

widget/gtk/nsLookAndFeel.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,11 +1144,6 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
11441144
aResult = EffectiveTheme().mTitlebarRadius;
11451145
break;
11461146
}
1147-
case IntID::TitlebarButtonSpacing: {
1148-
EnsureInit();
1149-
aResult = EffectiveTheme().mTitlebarButtonSpacing;
1150-
break;
1151-
}
11521147
case IntID::AllowOverlayScrollbarsOverlap: {
11531148
aResult = 1;
11541149
break;
@@ -2301,14 +2296,6 @@ void nsLookAndFeel::PerThemeData::Init() {
23012296
mTitlebar = GetColorPair(style, GTK_STATE_FLAG_NORMAL);
23022297
mTitlebarInactive = GetColorPair(style, GTK_STATE_FLAG_BACKDROP);
23032298
mTitlebarRadius = GetBorderRadius(style);
2304-
mTitlebarButtonSpacing = [&] {
2305-
// Account for the spacing property in the header bar.
2306-
// Default to 6 pixels (gtk/gtkheaderbar.c)
2307-
gint spacing = 6;
2308-
g_object_get(GtkWidgets::Get(GtkWidgets::Type::HeaderBar), "spacing",
2309-
&spacing, nullptr);
2310-
return spacing;
2311-
}();
23122299
}
23132300

23142301
// We special-case the header bar color in Adwaita, Yaru and Breeze to be the

widget/gtk/nsLookAndFeel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
174174
float mCaretRatio = 0.0f;
175175
int32_t mTitlebarRadius = 0;
176176
int32_t mTooltipRadius = 0;
177-
int32_t mTitlebarButtonSpacing = 0;
178177
char16_t mInvisibleCharacter = 0;
179178
bool mMenuSupportsDrag = false;
180179

widget/nsXPLookAndFeel.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ static const char sIntPrefs[][45] = {
157157
"ui.systemScrollbarSize",
158158
"ui.touchDeviceSupportPresent",
159159
"ui.titlebarRadius",
160-
"ui.titlebarButtonSpacing",
161160
"ui.tooltipRadius",
162161
"ui.dynamicRange",
163162
"ui.panelAnimations",

0 commit comments

Comments
 (0)