From 27f591e5aa85e998a2f0dc77fd08dc4e90fcea1d Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Thu, 25 Sep 2025 12:52:16 -0400 Subject: [PATCH] fix(corner-radius): fix radius from array to match iced and better respect sharp corners --- src/app/cosmic.rs | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/src/app/cosmic.rs b/src/app/cosmic.rs index 9c5a39f8..1d52ee0f 100644 --- a/src/app/cosmic.rs +++ b/src/app/cosmic.rs @@ -755,27 +755,31 @@ impl Cosmic { let cur_rad = CornerRadius { top_left: radii[0].round() as u32, top_right: radii[1].round() as u32, - bottom_left: radii[2].round() as u32, - bottom_right: radii[3].round() as u32, + bottom_right: radii[2].round() as u32, + bottom_left: radii[3].round() as u32, }; + let rounded = !self.app.core().window.sharp_corners; // Update radius for the main window let main_window_id = self .app .core() .main_window_id() .unwrap_or(window::Id::RESERVED); - let mut cmds = - vec![corner_radius(main_window_id, Some(cur_rad)).discard()]; + let mut cmds = vec![ + corner_radius(main_window_id, rounded.then_some(cur_rad)).discard(), + ]; // Update radius for each tracked view with the window surface type for (id, (_, surface_type, _)) in self.surface_views.iter() { if let SurfaceIdWrapper::Window(_) = surface_type { - cmds.push(corner_radius(*id, Some(cur_rad)).discard()); + cmds.push( + corner_radius(*id, rounded.then_some(cur_rad)).discard(), + ); } } // Update radius for all tracked windows for id in self.tracked_windows.iter() { - cmds.push(corner_radius(*id, Some(cur_rad)).discard()); + cmds.push(corner_radius(*id, rounded.then_some(cur_rad)).discard()); } return Task::batch(cmds); @@ -853,9 +857,10 @@ impl Cosmic { let cur_rad = CornerRadius { top_left: radii[0].round() as u32, top_right: radii[1].round() as u32, - bottom_left: radii[2].round() as u32, - bottom_right: radii[3].round() as u32, + bottom_right: radii[2].round() as u32, + bottom_left: radii[3].round() as u32, }; + let rounded = !self.app.core().window.sharp_corners; // Update radius for the main window let main_window_id = self @@ -863,17 +868,24 @@ impl Cosmic { .core() .main_window_id() .unwrap_or(window::Id::RESERVED); - let mut cmds = - vec![corner_radius(main_window_id, Some(cur_rad)).discard()]; + let mut cmds = vec![ + corner_radius(main_window_id, rounded.then_some(cur_rad)) + .discard(), + ]; // Update radius for each tracked view with the window surface type for (id, (_, surface_type, _)) in self.surface_views.iter() { if let SurfaceIdWrapper::Window(_) = surface_type { - cmds.push(corner_radius(*id, Some(cur_rad)).discard()); + cmds.push( + corner_radius(*id, rounded.then_some(cur_rad)) + .discard(), + ); } } // Update radius for all tracked windows for id in self.tracked_windows.iter() { - cmds.push(corner_radius(*id, Some(cur_rad)).discard()); + cmds.push( + corner_radius(*id, rounded.then_some(cur_rad)).discard(), + ); } return Task::batch(cmds); @@ -1076,11 +1088,14 @@ impl Cosmic { let cur_rad = CornerRadius { top_left: radii[0].round() as u32, top_right: radii[1].round() as u32, - bottom_left: radii[2].round() as u32, - bottom_right: radii[3].round() as u32, + bottom_right: radii[2].round() as u32, + bottom_left: radii[3].round() as u32, }; + // TODO do we need per window sharp corners? + let rounded = !self.app.core().window.sharp_corners; + return Task::batch(vec![ - corner_radius(id, Some(cur_rad)).discard(), + corner_radius(id, rounded.then_some(cur_rad)).discard(), iced_runtime::window::run_with_handle(id, init_windowing_system), ]); }