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,40 @@ 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+ // GNOME Tweaks has settings to put the window buttons on left or right,
33+ // as well as hide minimize/maximize buttons. Regardless of the state of
34+ // the minimize/maximize toggles, whenever the buttons are on the left,
35+ // the dconf value string ends with ":icon".
36+ if value. ends_with ( ":icon" ) {
37+ WindowControlsPosition :: Left
38+ } else {
39+ WindowControlsPosition :: Right
40+ }
41+ } else {
42+ WindowControlsPosition :: Right
43+ }
44+ } else {
45+ WindowControlsPosition :: Right
46+ } ;
2847
2948 Self {
3049 id : id. into ( ) ,
3150 platform_style,
3251 children : SmallVec :: new ( ) ,
3352 should_move : false ,
3453 system_window_tabs,
54+ window_controls_position,
3555 }
3656 }
3757
@@ -112,8 +132,7 @@ impl Render for PlatformTitleBar {
112132 . items_center ( )
113133 . map ( |this| {
114134 if self . platform_style == PlatformStyle :: Linux {
115- let title_bar_settings = TitleBarSettings :: get ( None , cx) ;
116- match title_bar_settings. window_controls_position {
135+ match self . window_controls_position {
117136 WindowControlsPosition :: Left => this. justify_start ( ) ,
118137 WindowControlsPosition :: Right => this. justify_between ( ) ,
119138 }
@@ -144,15 +163,15 @@ impl Render for PlatformTitleBar {
144163 PlatformStyle :: Mac => title_bar,
145164 PlatformStyle :: Linux => {
146165 if matches ! ( decorations, Decorations :: Client { .. } ) {
147- let title_bar_settings = TitleBarSettings :: get ( None , cx) ;
148- match title_bar_settings. window_controls_position {
166+ match self . window_controls_position {
149167 WindowControlsPosition :: Left => {
150168 // macOS style: controls at the beginning of the title bar
151169 h_flex ( )
152170 . w_full ( )
153171 . bg ( titlebar_color)
154172 . child ( platform_linux:: LinuxWindowControls :: new (
155173 close_action,
174+ WindowControlsPosition :: Left ,
156175 ) )
157176 . child ( title_bar)
158177 . when ( supported_controls. window_menu , |titlebar| {
@@ -192,6 +211,7 @@ impl Render for PlatformTitleBar {
192211 title_bar
193212 . child ( platform_linux:: LinuxWindowControls :: new (
194213 close_action,
214+ WindowControlsPosition :: Right ,
195215 ) )
196216 . when ( supported_controls. window_menu , |titlebar| {
197217 titlebar. on_mouse_down (
0 commit comments