Skip to content

Commit 2338164

Browse files
authored
Revert "title_bar: Add configurable window controls position (#38834)" (#40839)
This reverts commit b479d1e. This PR was accidentally merged prematurely. #38834 (comment) cc @danilo-leal Release Notes: - N/A
1 parent 2deafd8 commit 2338164

File tree

4 files changed

+53
-162
lines changed

4 files changed

+53
-162
lines changed

crates/settings/src/settings_content.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -260,32 +260,6 @@ impl strum::VariantNames for BaseKeymapContent {
260260
];
261261
}
262262

263-
/// Position of window control buttons on Linux.
264-
///
265-
/// Valid values: "left" (macOS style) or "right" (Windows/Linux style)
266-
#[derive(
267-
Copy,
268-
Clone,
269-
Debug,
270-
Serialize,
271-
Deserialize,
272-
JsonSchema,
273-
MergeFrom,
274-
PartialEq,
275-
Eq,
276-
Default,
277-
strum::VariantArray,
278-
strum::VariantNames,
279-
)]
280-
#[serde(rename_all = "snake_case")]
281-
pub enum WindowControlsPosition {
282-
/// Window controls on the left side (macOS style)
283-
Left,
284-
/// Window controls on the right side (Windows style)
285-
#[default]
286-
Right,
287-
}
288-
289263
#[skip_serializing_none]
290264
#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
291265
pub struct TitleBarSettingsContent {
@@ -317,10 +291,6 @@ pub struct TitleBarSettingsContent {
317291
///
318292
/// Default: false
319293
pub show_menus: Option<bool>,
320-
/// Position of window control buttons (minimize, maximize, close) on Linux.
321-
///
322-
/// Default: right
323-
pub window_controls_position: Option<WindowControlsPosition>,
324294
}
325295

326296
/// Configuration of audio in Zed.

crates/title_bar/src/platform_title_bar.rs

Lines changed: 29 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ use gpui::{
22
AnyElement, Context, Decorations, Entity, Hsla, InteractiveElement, IntoElement, MouseButton,
33
ParentElement, Pixels, StatefulInteractiveElement, Styled, Window, WindowControlArea, div, px,
44
};
5-
use settings::{Settings, WindowControlsPosition};
65
use smallvec::SmallVec;
76
use std::mem;
87
use ui::prelude::*;
98

109
use crate::{
1110
platforms::{platform_linux, platform_mac, platform_windows},
1211
system_window_tabs::SystemWindowTabs,
13-
title_bar_settings::TitleBarSettings,
1412
};
1513

1614
pub struct PlatformTitleBar {
@@ -136,78 +134,35 @@ impl Render for PlatformTitleBar {
136134
PlatformStyle::Mac => title_bar,
137135
PlatformStyle::Linux => {
138136
if matches!(decorations, Decorations::Client { .. }) {
139-
let title_bar_settings = TitleBarSettings::get(None, cx);
140-
match title_bar_settings.window_controls_position {
141-
WindowControlsPosition::Left => h_flex()
142-
.w_full()
143-
.bg(titlebar_color)
144-
.child(platform_linux::LinuxWindowControls::new(close_action))
145-
.child(title_bar)
146-
.when(supported_controls.window_menu, |titlebar| {
147-
titlebar.on_mouse_down(
148-
MouseButton::Right,
149-
move |ev, window, _| {
150-
window.show_window_menu(ev.position)
151-
},
152-
)
153-
})
154-
.on_mouse_move(cx.listener(move |this, _ev, window, _| {
155-
if this.should_move {
156-
this.should_move = false;
157-
window.start_window_move();
158-
}
159-
}))
160-
.on_mouse_down_out(cx.listener(
161-
move |this, _ev, _window, _cx| {
162-
this.should_move = false;
163-
},
164-
))
165-
.on_mouse_up(
166-
MouseButton::Left,
167-
cx.listener(move |this, _ev, _window, _cx| {
168-
this.should_move = false;
169-
}),
170-
)
171-
.on_mouse_down(
172-
MouseButton::Left,
173-
cx.listener(move |this, _ev, _window, _cx| {
174-
this.should_move = true;
175-
}),
176-
),
177-
WindowControlsPosition::Right => title_bar
178-
.child(platform_linux::LinuxWindowControls::new(close_action))
179-
.when(supported_controls.window_menu, |titlebar| {
180-
titlebar.on_mouse_down(
181-
MouseButton::Right,
182-
move |ev, window, _| {
183-
window.show_window_menu(ev.position)
184-
},
185-
)
186-
})
187-
.on_mouse_move(cx.listener(move |this, _ev, window, _| {
188-
if this.should_move {
189-
this.should_move = false;
190-
window.start_window_move();
191-
}
192-
}))
193-
.on_mouse_down_out(cx.listener(
194-
move |this, _ev, _window, _cx| {
195-
this.should_move = false;
196-
},
197-
))
198-
.on_mouse_up(
199-
MouseButton::Left,
200-
cx.listener(move |this, _ev, _window, _cx| {
201-
this.should_move = false;
202-
}),
203-
)
204-
.on_mouse_down(
205-
MouseButton::Left,
206-
cx.listener(move |this, _ev, _window, _cx| {
207-
this.should_move = true;
208-
}),
209-
),
210-
}
137+
title_bar
138+
.child(platform_linux::LinuxWindowControls::new(close_action))
139+
.when(supported_controls.window_menu, |titlebar| {
140+
titlebar
141+
.on_mouse_down(MouseButton::Right, move |ev, window, _| {
142+
window.show_window_menu(ev.position)
143+
})
144+
})
145+
.on_mouse_move(cx.listener(move |this, _ev, window, _| {
146+
if this.should_move {
147+
this.should_move = false;
148+
window.start_window_move();
149+
}
150+
}))
151+
.on_mouse_down_out(cx.listener(move |this, _ev, _window, _cx| {
152+
this.should_move = false;
153+
}))
154+
.on_mouse_up(
155+
MouseButton::Left,
156+
cx.listener(move |this, _ev, _window, _cx| {
157+
this.should_move = false;
158+
}),
159+
)
160+
.on_mouse_down(
161+
MouseButton::Left,
162+
cx.listener(move |this, _ev, _window, _cx| {
163+
this.should_move = true;
164+
}),
165+
)
211166
} else {
212167
title_bar
213168
}

crates/title_bar/src/platforms/platform_linux.rs

Lines changed: 23 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use crate::title_bar_settings::TitleBarSettings;
21
use gpui::{Action, Hsla, MouseButton, prelude::*, svg};
3-
use settings::{Settings, WindowControlsPosition};
42
use ui::prelude::*;
53

64
#[derive(IntoElement)]
@@ -16,62 +14,33 @@ impl LinuxWindowControls {
1614
}
1715
}
1816

19-
impl LinuxWindowControls {
20-
/// Builds the window controls based on the position setting.
21-
fn build_controls(
22-
position: WindowControlsPosition,
23-
window: &Window,
24-
close_action: Box<dyn Action>,
25-
cx: &mut App,
26-
) -> Vec<WindowControl> {
27-
let maximize_type = if window.is_maximized() {
28-
WindowControlType::Restore
29-
} else {
30-
WindowControlType::Maximize
31-
};
32-
33-
match position {
34-
WindowControlsPosition::Left => {
35-
// Left side: Close, Minimize, Maximize (left to right)
36-
vec![
37-
WindowControl::new_close("close", WindowControlType::Close, close_action, cx),
38-
WindowControl::new("minimize", WindowControlType::Minimize, cx),
39-
WindowControl::new("maximize-or-restore", maximize_type, cx),
40-
]
41-
}
42-
WindowControlsPosition::Right => {
43-
// Right side: Minimize, Maximize, Close (left to right)
44-
vec![
45-
WindowControl::new("minimize", WindowControlType::Minimize, cx),
46-
WindowControl::new("maximize-or-restore", maximize_type, cx),
47-
WindowControl::new_close("close", WindowControlType::Close, close_action, cx),
48-
]
49-
}
50-
}
51-
}
52-
}
53-
5417
impl RenderOnce for LinuxWindowControls {
5518
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
56-
let title_bar_settings = TitleBarSettings::get(None, cx);
57-
let controls = Self::build_controls(
58-
title_bar_settings.window_controls_position,
59-
window,
60-
self.close_window_action,
61-
cx,
62-
);
63-
64-
let mut element = h_flex()
19+
h_flex()
6520
.id("generic-window-controls")
6621
.px_3()
6722
.gap_3()
68-
.on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation());
69-
70-
for control in controls {
71-
element = element.child(control);
72-
}
73-
74-
element
23+
.on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
24+
.child(WindowControl::new(
25+
"minimize",
26+
WindowControlType::Minimize,
27+
cx,
28+
))
29+
.child(WindowControl::new(
30+
"maximize-or-restore",
31+
if window.is_maximized() {
32+
WindowControlType::Restore
33+
} else {
34+
WindowControlType::Maximize
35+
},
36+
cx,
37+
))
38+
.child(WindowControl::new_close(
39+
"close",
40+
WindowControlType::Close,
41+
self.close_window_action,
42+
cx,
43+
))
7544
}
7645
}
7746

@@ -111,7 +80,7 @@ impl WindowControlStyle {
11180
let colors = cx.theme().colors();
11281

11382
Self {
114-
background: colors.title_bar_background,
83+
background: colors.ghost_element_background,
11584
background_hover: colors.ghost_element_hover,
11685
icon: colors.icon,
11786
icon_hover: colors.icon_muted,
@@ -216,7 +185,6 @@ impl RenderOnce for WindowControl {
216185
.rounded_2xl()
217186
.w_5()
218187
.h_5()
219-
.bg(self.style.background)
220188
.hover(|this| this.bg(self.style.background_hover))
221189
.active(|this| this.bg(self.style.background_hover))
222190
.child(icon)

crates/title_bar/src/title_bar_settings.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use settings::{Settings, SettingsContent, WindowControlsPosition};
1+
use settings::{Settings, SettingsContent};
22

33
#[derive(Copy, Clone, Debug)]
44
pub struct TitleBarSettings {
@@ -9,7 +9,6 @@ pub struct TitleBarSettings {
99
pub show_project_items: bool,
1010
pub show_sign_in: bool,
1111
pub show_menus: bool,
12-
pub window_controls_position: WindowControlsPosition,
1312
}
1413

1514
impl Settings for TitleBarSettings {
@@ -23,7 +22,6 @@ impl Settings for TitleBarSettings {
2322
show_project_items: content.show_project_items.unwrap(),
2423
show_sign_in: content.show_sign_in.unwrap(),
2524
show_menus: content.show_menus.unwrap(),
26-
window_controls_position: content.window_controls_position.unwrap_or_default(),
2725
}
2826
}
2927
}

0 commit comments

Comments
 (0)