Skip to content

Commit 14233c2

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

File tree

5 files changed

+39
-13
lines changed

5 files changed

+39
-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: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@ 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+
#[cfg(any(target_os = "windows", target_os = "macos"))]
80+
core.window.client_decorations = settings.client_decorations || crate::config::client_decorations();
81+
#[cfg(target_os = "linux")]
82+
core.window.client_decorations = settings.client_decorations && crate::config::client_decorations();
83+
window_settings.decorations = !core.window.client_decorations;
84+
7985
window_settings.size = settings.size;
8086
let min_size = settings.size_limits.min();
8187
if min_size != iced::Size::ZERO {
@@ -551,7 +557,7 @@ impl<App: Application> ApplicationExt for App {
551557
let is_condensed = core.is_condensed();
552558
// TODO: More granularity might be needed for different window border
553559
// handling of maximized and tiled windows
554-
let sharp_corners = core.window.sharp_corners;
560+
let sharp_corners = core.window.sharp_corners || !core.window.client_decorations;
555561
let content_container = core.window.content_container;
556562
let show_context = core.window.show_context;
557563
let nav_bar_active = core.nav_bar_active();
@@ -709,7 +715,6 @@ impl<App: Application> ApplicationExt for App {
709715
let mut header = crate::widget::header_bar()
710716
.focused(focused)
711717
.maximized(sharp_corners)
712-
.title(&core.window.header_title)
713718
.on_drag(crate::Action::Cosmic(Action::Drag))
714719
.on_right_click(crate::Action::Cosmic(Action::ShowWindowMenu))
715720
.on_double_click(crate::Action::Cosmic(Action::Maximize))
@@ -727,19 +732,23 @@ impl<App: Application> ApplicationExt for App {
727732

728733
header = header.start(toggle);
729734
}
735+
if core.window.client_decorations {
736+
header = header.title(&core.window.header_title);
737+
738+
if core.window.show_close {
739+
header = header.on_close(crate::Action::Cosmic(Action::Close));
740+
}
730741

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

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

739-
if core.window.show_minimize && crate::config::show_minimize() {
740-
header = header.on_minimize(crate::Action::Cosmic(Action::Minimize));
741750
}
742-
751+
743752
for element in self.header_start() {
744753
header = header.start(element.map(crate::Action::App));
745754
}

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)