Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/cosmic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
34 changes: 22 additions & 12 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,14 @@ pub(crate) fn iced_settings<App: Application>(
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 {
Expand Down Expand Up @@ -551,7 +558,7 @@ impl<App: Application> 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();
Expand Down Expand Up @@ -709,7 +716,6 @@ impl<App: Application> 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))
Expand All @@ -727,19 +733,23 @@ impl<App: Application> 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));
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
12 changes: 12 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,

Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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.,
},
Expand Down