1- use crate :: title_bar_settings :: TitleBarSettings ;
1+ use crate :: WindowControlsPosition ;
22use gpui:: {
33 AnyElement , Context , Decorations , Entity , Hsla , InteractiveElement , IntoElement , MouseButton ,
44 ParentElement , Pixels , StatefulInteractiveElement , Styled , Window , WindowControlArea , div, px,
55} ;
6- use settings:: { Settings , WindowControlsPosition } ;
76use smallvec:: SmallVec ;
87use std:: mem;
98use ui:: prelude:: * ;
@@ -19,19 +18,37 @@ pub struct PlatformTitleBar {
1918 children : SmallVec < [ AnyElement ; 2 ] > ,
2019 should_move : bool ,
2120 system_window_tabs : Entity < SystemWindowTabs > ,
21+ window_controls_position : WindowControlsPosition ,
2222}
2323
2424impl PlatformTitleBar {
2525 pub fn new ( id : impl Into < ElementId > , cx : & mut Context < Self > ) -> Self {
2626 let platform_style = PlatformStyle :: platform ( ) ;
2727 let system_window_tabs = cx. new ( |_cx| SystemWindowTabs :: new ( ) ) ;
28+ let window_controls_position = if cfg ! ( target_os = "linux" ) {
29+ if let Ok ( Some ( value) ) =
30+ dconf:: read_string ( "/org/gnome/desktop/wm/preferences/button-layout" )
31+ {
32+ // This is the value that GNOME Tweaks sets when setting window button position to left.
33+ if value == "close,minimize,maximize:icon" {
34+ WindowControlsPosition :: Left
35+ } else {
36+ WindowControlsPosition :: Right
37+ }
38+ } else {
39+ WindowControlsPosition :: Right
40+ }
41+ } else {
42+ WindowControlsPosition :: Right
43+ } ;
2844
2945 Self {
3046 id : id. into ( ) ,
3147 platform_style,
3248 children : SmallVec :: new ( ) ,
3349 should_move : false ,
3450 system_window_tabs,
51+ window_controls_position,
3552 }
3653 }
3754
@@ -112,8 +129,7 @@ impl Render for PlatformTitleBar {
112129 . items_center ( )
113130 . map ( |this| {
114131 if self . platform_style == PlatformStyle :: Linux {
115- let title_bar_settings = TitleBarSettings :: get ( None , cx) ;
116- match title_bar_settings. window_controls_position {
132+ match self . window_controls_position {
117133 WindowControlsPosition :: Left => this. justify_start ( ) ,
118134 WindowControlsPosition :: Right => this. justify_between ( ) ,
119135 }
@@ -144,15 +160,15 @@ impl Render for PlatformTitleBar {
144160 PlatformStyle :: Mac => title_bar,
145161 PlatformStyle :: Linux => {
146162 if matches ! ( decorations, Decorations :: Client { .. } ) {
147- let title_bar_settings = TitleBarSettings :: get ( None , cx) ;
148- match title_bar_settings. window_controls_position {
163+ match self . window_controls_position {
149164 WindowControlsPosition :: Left => {
150165 // macOS style: controls at the beginning of the title bar
151166 h_flex ( )
152167 . w_full ( )
153168 . bg ( titlebar_color)
154169 . child ( platform_linux:: LinuxWindowControls :: new (
155170 close_action,
171+ WindowControlsPosition :: Left ,
156172 ) )
157173 . child ( title_bar)
158174 . when ( supported_controls. window_menu , |titlebar| {
@@ -192,6 +208,7 @@ impl Render for PlatformTitleBar {
192208 title_bar
193209 . child ( platform_linux:: LinuxWindowControls :: new (
194210 close_action,
211+ WindowControlsPosition :: Right ,
195212 ) )
196213 . when ( supported_controls. window_menu , |titlebar| {
197214 titlebar. on_mouse_down (
0 commit comments