diff --git a/src/app/cosmic.rs b/src/app/cosmic.rs index c8a8dfebffa..580e1dd9a95 100644 --- a/src/app/cosmic.rs +++ b/src/app/cosmic.rs @@ -307,7 +307,7 @@ where pub fn style(&self, theme: &Theme) -> iced_runtime::Appearance { if let Some(style) = self.app.style() { style - } else if self.app.core().window.sharp_corners { + } else if self.app.core().window.sharp_corners || !self.app.core().window.client_decorations { let theme = THEME.lock().unwrap(); crate::style::iced::application::appearance(theme.borrow()) } else { diff --git a/src/app/mod.rs b/src/app/mod.rs index 1b10b68d466..15dc08de4fb 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -75,7 +75,14 @@ pub(crate) fn iced_settings( window_settings.resize_border = border_size as u32; window_settings.resizable = true; } - window_settings.decorations = !settings.client_decorations; + + core.window.client_decorations = if cfg!(any(target_os = "windows", target_os = "macos")) { + settings.client_decorations || crate::config::client_decorations() + } else { + settings.client_decorations && crate::config::client_decorations() + }; + window_settings.decorations = !core.window.client_decorations; + window_settings.size = settings.size; let min_size = settings.size_limits.min(); if min_size != iced::Size::ZERO { @@ -551,7 +558,7 @@ impl ApplicationExt for App { let is_condensed = core.is_condensed(); // TODO: More granularity might be needed for different window border // handling of maximized and tiled windows - let sharp_corners = core.window.sharp_corners; + let sharp_corners = core.window.sharp_corners || !core.window.client_decorations; let content_container = core.window.content_container; let show_context = core.window.show_context; let nav_bar_active = core.nav_bar_active(); @@ -709,7 +716,6 @@ impl ApplicationExt for App { let mut header = crate::widget::header_bar() .focused(focused) .maximized(sharp_corners) - .title(&core.window.header_title) .on_drag(crate::Action::Cosmic(Action::Drag)) .on_right_click(crate::Action::Cosmic(Action::ShowWindowMenu)) .on_double_click(crate::Action::Cosmic(Action::Maximize)) @@ -727,19 +733,23 @@ impl ApplicationExt for App { header = header.start(toggle); } + if core.window.client_decorations { + header = header.title(&core.window.header_title); + + if core.window.show_close { + header = header.on_close(crate::Action::Cosmic(Action::Close)); + } - if core.window.show_close { - header = header.on_close(crate::Action::Cosmic(Action::Close)); - } + if core.window.show_maximize && crate::config::show_maximize() { + header = header.on_maximize(crate::Action::Cosmic(Action::Maximize)); + } - if core.window.show_maximize && crate::config::show_maximize() { - header = header.on_maximize(crate::Action::Cosmic(Action::Maximize)); - } + if core.window.show_minimize && crate::config::show_minimize() { + header = header.on_minimize(crate::Action::Cosmic(Action::Minimize)); + } - if core.window.show_minimize && crate::config::show_minimize() { - header = header.on_minimize(crate::Action::Cosmic(Action::Minimize)); } - + for element in self.header_start() { header = header.start(element.map(crate::Action::App)); } diff --git a/src/app/settings.rs b/src/app/settings.rs index 926181e1196..b005657e5f0 100644 --- a/src/app/settings.rs +++ b/src/app/settings.rs @@ -83,6 +83,9 @@ impl Default for Settings { #[cfg(feature = "wayland")] autosize: false, no_main_window: false, + #[cfg(any(target_os = "windows", target_os = "macos"))] + client_decorations: false, + #[cfg(target_os = "linux")] client_decorations: true, debug: false, default_font: font::default(), diff --git a/src/config/mod.rs b/src/config/mod.rs index dedadbc2ea0..bf87a39a414 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -40,6 +40,11 @@ pub fn apply_theme_global() -> bool { COSMIC_TK.read().unwrap().apply_theme_global } +/// Enable client-side decorations. +pub fn client_decorations() -> bool { + COSMIC_TK.read().unwrap().client_decorations +} + /// Show minimize button in window header. #[allow(clippy::missing_panics_doc)] pub fn show_minimize() -> bool { @@ -92,6 +97,9 @@ pub struct CosmicTk { /// Show maximize button in window header. pub show_maximize: bool, + /// Enables client-side decorations. + pub client_decorations: bool, + /// Preferred icon theme. pub icon_theme: String, @@ -114,6 +122,10 @@ impl Default for CosmicTk { apply_theme_global: false, show_minimize: true, show_maximize: true, + #[cfg(any(target_os = "windows", target_os = "macos"))] + client_decorations: false, + #[cfg(target_os = "linux")] + client_decorations: true, icon_theme: String::from("Cosmic"), header_size: Density::Standard, interface_density: Density::Standard, diff --git a/src/core.rs b/src/core.rs index 4b9811ec8e4..d11ac12c936 100644 --- a/src/core.rs +++ b/src/core.rs @@ -38,6 +38,7 @@ pub struct Window { pub show_close: bool, pub show_maximize: bool, pub show_minimize: bool, + pub client_decorations: bool, height: f32, width: f32, } @@ -138,6 +139,7 @@ impl Default for Core { show_maximize: true, show_minimize: true, show_window_menu: false, + client_decorations: true, height: 0., width: 0., },