Skip to content

Commit 8313739

Browse files
committed
feat: add SSD support via config option
1 parent 562e885 commit 8313739

File tree

5 files changed

+40
-13
lines changed

5 files changed

+40
-13
lines changed

src/app/cosmic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ where
307307
pub fn style(&self, theme: &Theme) -> iced_runtime::Appearance {
308308
if let Some(style) = self.app.style() {
309309
style
310-
} else if self.app.core().window.sharp_corners {
310+
} else if self.app.core().window.sharp_corners || !self.app.core().window.client_decorations {
311311
let theme = THEME.lock().unwrap();
312312
crate::style::iced::application::appearance(theme.borrow())
313313
} else {

src/app/mod.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,14 @@ pub(crate) fn iced_settings<App: Application>(
7575
window_settings.resize_border = border_size as u32;
7676
window_settings.resizable = true;
7777
}
78-
window_settings.decorations = !settings.client_decorations;
78+
79+
core.window.client_decorations = if cfg!(any(target_os = "windows", target_os = "macos")) {
80+
settings.client_decorations || crate::config::client_decorations()
81+
} else {
82+
settings.client_decorations && crate::config::client_decorations()
83+
};
84+
window_settings.decorations = !core.window.client_decorations;
85+
7986
window_settings.size = settings.size;
8087
let min_size = settings.size_limits.min();
8188
if min_size != iced::Size::ZERO {
@@ -551,7 +558,7 @@ impl<App: Application> ApplicationExt for App {
551558
let is_condensed = core.is_condensed();
552559
// TODO: More granularity might be needed for different window border
553560
// handling of maximized and tiled windows
554-
let sharp_corners = core.window.sharp_corners;
561+
let sharp_corners = core.window.sharp_corners || !core.window.client_decorations;
555562
let content_container = core.window.content_container;
556563
let show_context = core.window.show_context;
557564
let nav_bar_active = core.nav_bar_active();
@@ -709,7 +716,6 @@ impl<App: Application> ApplicationExt for App {
709716
let mut header = crate::widget::header_bar()
710717
.focused(focused)
711718
.maximized(sharp_corners)
712-
.title(&core.window.header_title)
713719
.on_drag(crate::Action::Cosmic(Action::Drag))
714720
.on_right_click(crate::Action::Cosmic(Action::ShowWindowMenu))
715721
.on_double_click(crate::Action::Cosmic(Action::Maximize))
@@ -727,19 +733,23 @@ impl<App: Application> ApplicationExt for App {
727733

728734
header = header.start(toggle);
729735
}
736+
if core.window.client_decorations {
737+
header = header.title(&core.window.header_title);
738+
739+
if core.window.show_close {
740+
header = header.on_close(crate::Action::Cosmic(Action::Close));
741+
}
730742

731-
if core.window.show_close {
732-
header = header.on_close(crate::Action::Cosmic(Action::Close));
733-
}
743+
if core.window.show_maximize && crate::config::show_maximize() {
744+
header = header.on_maximize(crate::Action::Cosmic(Action::Maximize));
745+
}
734746

735-
if core.window.show_maximize && crate::config::show_maximize() {
736-
header = header.on_maximize(crate::Action::Cosmic(Action::Maximize));
737-
}
747+
if core.window.show_minimize && crate::config::show_minimize() {
748+
header = header.on_minimize(crate::Action::Cosmic(Action::Minimize));
749+
}
738750

739-
if core.window.show_minimize && crate::config::show_minimize() {
740-
header = header.on_minimize(crate::Action::Cosmic(Action::Minimize));
741751
}
742-
752+
743753
for element in self.header_start() {
744754
header = header.start(element.map(crate::Action::App));
745755
}

src/app/settings.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ impl Default for Settings {
8383
#[cfg(feature = "wayland")]
8484
autosize: false,
8585
no_main_window: false,
86+
#[cfg(any(target_os = "windows", target_os = "macos"))]
87+
client_decorations: false,
88+
#[cfg(target_os = "linux")]
8689
client_decorations: true,
8790
debug: false,
8891
default_font: font::default(),

src/config/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ pub fn apply_theme_global() -> bool {
4040
COSMIC_TK.read().unwrap().apply_theme_global
4141
}
4242

43+
/// Enable client-side decorations.
44+
pub fn client_decorations() -> bool {
45+
COSMIC_TK.read().unwrap().client_decorations
46+
}
47+
4348
/// Show minimize button in window header.
4449
#[allow(clippy::missing_panics_doc)]
4550
pub fn show_minimize() -> bool {
@@ -92,6 +97,9 @@ pub struct CosmicTk {
9297
/// Show maximize button in window header.
9398
pub show_maximize: bool,
9499

100+
/// Enables client-side decorations.
101+
pub client_decorations: bool,
102+
95103
/// Preferred icon theme.
96104
pub icon_theme: String,
97105

@@ -114,6 +122,10 @@ impl Default for CosmicTk {
114122
apply_theme_global: false,
115123
show_minimize: true,
116124
show_maximize: true,
125+
#[cfg(any(target_os = "windows", target_os = "macos"))]
126+
client_decorations: false,
127+
#[cfg(target_os = "linux")]
128+
client_decorations: true,
117129
icon_theme: String::from("Cosmic"),
118130
header_size: Density::Standard,
119131
interface_density: Density::Standard,

src/core.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub struct Window {
3838
pub show_close: bool,
3939
pub show_maximize: bool,
4040
pub show_minimize: bool,
41+
pub client_decorations: bool,
4142
height: f32,
4243
width: f32,
4344
}
@@ -138,6 +139,7 @@ impl Default for Core {
138139
show_maximize: true,
139140
show_minimize: true,
140141
show_window_menu: false,
142+
client_decorations: true,
141143
height: 0.,
142144
width: 0.,
143145
},

0 commit comments

Comments
 (0)