diff --git a/src/app/cosmic.rs b/src/app/cosmic.rs index 030ed041..da006b6d 100644 --- a/src/app/cosmic.rs +++ b/src/app/cosmic.rs @@ -411,7 +411,7 @@ where pub fn style(&self, theme: &Theme) -> theme::Style { if let Some(style) = self.app.style() { style - } else if self.app.core().window.is_maximized { + } else if self.app.core().window.is_maximized || !self.app.core().window.client_decorations { let theme = THEME.lock().unwrap(); crate::style::iced::application::style(theme.borrow()) } else { diff --git a/src/app/mod.rs b/src/app/mod.rs index f78beac7..65f1946e 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 { @@ -610,7 +617,7 @@ impl ApplicationExt for App { fn view_main(&self) -> Element<'_, crate::Action> { let core = self.core(); let is_condensed = core.is_condensed(); - let sharp_corners = core.window.sharp_corners; + let sharp_corners = core.window.sharp_corners || !core.window.client_decorations; let maximized = core.window.is_maximized; let content_container = core.window.content_container; let show_context = core.window.show_context; @@ -774,7 +781,6 @@ impl ApplicationExt for App { .maximized(maximized) .sharp_corners(sharp_corners) .transparent(content_container) - .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)); @@ -791,19 +797,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_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_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_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 5c903f09..19efcde7 100644 --- a/src/app/settings.rs +++ b/src/app/settings.rs @@ -83,6 +83,9 @@ impl Default for Settings { #[cfg(all(feature = "wayland", target_os = "linux"))] 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 9807961c..a343cada 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -43,6 +43,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 { @@ -95,6 +100,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, @@ -117,6 +125,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 970a5351..701b9cea 100644 --- a/src/core.rs +++ b/src/core.rs @@ -39,6 +39,7 @@ pub struct Window { pub show_maximize: bool, pub show_minimize: bool, pub is_maximized: bool, + pub client_decorations: bool, height: f32, width: f32, } @@ -143,6 +144,7 @@ impl Default for Core { show_minimize: true, show_window_menu: false, is_maximized: false, + client_decorations: true, height: 0., width: 0., },