refactor: set sharp corner window radius to 0 instead of unsetting
This commit is contained in:
parent
6c5b799b34
commit
0059fe182b
1 changed files with 122 additions and 10 deletions
|
|
@ -657,7 +657,21 @@ impl<T: Application> Cosmic<T> {
|
||||||
};
|
};
|
||||||
let rounded = !self.app.core().window.sharp_corners;
|
let rounded = !self.app.core().window.sharp_corners;
|
||||||
return Task::batch(vec![
|
return Task::batch(vec![
|
||||||
corner_radius(id, rounded.then_some(cur_rad)).discard(),
|
corner_radius(
|
||||||
|
id,
|
||||||
|
if rounded {
|
||||||
|
Some(cur_rad)
|
||||||
|
} else {
|
||||||
|
let rad_0 = t.radius_0();
|
||||||
|
Some(CornerRadius {
|
||||||
|
top_left: rad_0[0].round() as u32,
|
||||||
|
top_right: rad_0[1].round() as u32,
|
||||||
|
bottom_right: rad_0[2].round() as u32,
|
||||||
|
bottom_left: rad_0[3].round() as u32,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.discard(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -792,19 +806,63 @@ impl<T: Application> Cosmic<T> {
|
||||||
.main_window_id()
|
.main_window_id()
|
||||||
.unwrap_or(window::Id::RESERVED);
|
.unwrap_or(window::Id::RESERVED);
|
||||||
let mut cmds = vec![
|
let mut cmds = vec![
|
||||||
corner_radius(main_window_id, rounded.then_some(cur_rad)).discard(),
|
corner_radius(
|
||||||
|
main_window_id,
|
||||||
|
if rounded {
|
||||||
|
Some(cur_rad)
|
||||||
|
} else {
|
||||||
|
let rad_0 = t.radius_0();
|
||||||
|
Some(CornerRadius {
|
||||||
|
top_left: rad_0[0].round() as u32,
|
||||||
|
top_right: rad_0[1].round() as u32,
|
||||||
|
bottom_right: rad_0[2].round() as u32,
|
||||||
|
bottom_left: rad_0[3].round() as u32,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.discard(),
|
||||||
];
|
];
|
||||||
// Update radius for each tracked view with the window surface type
|
// Update radius for each tracked view with the window surface type
|
||||||
for (id, (_, surface_type, _)) in self.surface_views.iter() {
|
for (id, (_, surface_type, _)) in self.surface_views.iter() {
|
||||||
if let SurfaceIdWrapper::Window(_) = surface_type {
|
if let SurfaceIdWrapper::Window(_) = surface_type {
|
||||||
cmds.push(
|
cmds.push(
|
||||||
corner_radius(*id, rounded.then_some(cur_rad)).discard(),
|
corner_radius(
|
||||||
|
*id,
|
||||||
|
if rounded {
|
||||||
|
Some(cur_rad)
|
||||||
|
} else {
|
||||||
|
let rad_0 = t.radius_0();
|
||||||
|
Some(CornerRadius {
|
||||||
|
top_left: rad_0[0].round() as u32,
|
||||||
|
top_right: rad_0[1].round() as u32,
|
||||||
|
bottom_right: rad_0[2].round() as u32,
|
||||||
|
bottom_left: rad_0[3].round() as u32,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.discard(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Update radius for all tracked windows
|
// Update radius for all tracked windows
|
||||||
for id in self.tracked_windows.iter() {
|
for id in self.tracked_windows.iter() {
|
||||||
cmds.push(corner_radius(*id, rounded.then_some(cur_rad)).discard());
|
cmds.push(
|
||||||
|
corner_radius(
|
||||||
|
*id,
|
||||||
|
if rounded {
|
||||||
|
Some(cur_rad)
|
||||||
|
} else {
|
||||||
|
let rad_0 = t.radius_0();
|
||||||
|
Some(CornerRadius {
|
||||||
|
top_left: rad_0[0].round() as u32,
|
||||||
|
top_right: rad_0[1].round() as u32,
|
||||||
|
bottom_right: rad_0[2].round() as u32,
|
||||||
|
bottom_left: rad_0[3].round() as u32,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.discard(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task::batch(cmds);
|
return Task::batch(cmds);
|
||||||
|
|
@ -894,22 +952,62 @@ impl<T: Application> Cosmic<T> {
|
||||||
.main_window_id()
|
.main_window_id()
|
||||||
.unwrap_or(window::Id::RESERVED);
|
.unwrap_or(window::Id::RESERVED);
|
||||||
let mut cmds = vec![
|
let mut cmds = vec![
|
||||||
corner_radius(main_window_id, rounded.then_some(cur_rad))
|
corner_radius(
|
||||||
.discard(),
|
main_window_id,
|
||||||
|
if rounded {
|
||||||
|
Some(cur_rad)
|
||||||
|
} else {
|
||||||
|
let rad_0 = t.radius_0();
|
||||||
|
Some(CornerRadius {
|
||||||
|
top_left: rad_0[0].round() as u32,
|
||||||
|
top_right: rad_0[1].round() as u32,
|
||||||
|
bottom_right: rad_0[2].round() as u32,
|
||||||
|
bottom_left: rad_0[3].round() as u32,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.discard(),
|
||||||
];
|
];
|
||||||
// Update radius for each tracked view with the window surface type
|
// Update radius for each tracked view with the window surface type
|
||||||
for (id, (_, surface_type, _)) in self.surface_views.iter() {
|
for (id, (_, surface_type, _)) in self.surface_views.iter() {
|
||||||
if let SurfaceIdWrapper::Window(_) = surface_type {
|
if let SurfaceIdWrapper::Window(_) = surface_type {
|
||||||
cmds.push(
|
cmds.push(
|
||||||
corner_radius(*id, rounded.then_some(cur_rad))
|
corner_radius(
|
||||||
.discard(),
|
*id,
|
||||||
|
if rounded {
|
||||||
|
Some(cur_rad)
|
||||||
|
} else {
|
||||||
|
let rad_0 = t.radius_0();
|
||||||
|
Some(CornerRadius {
|
||||||
|
top_left: rad_0[0].round() as u32,
|
||||||
|
top_right: rad_0[1].round() as u32,
|
||||||
|
bottom_right: rad_0[2].round() as u32,
|
||||||
|
bottom_left: rad_0[3].round() as u32,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.discard(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Update radius for all tracked windows
|
// Update radius for all tracked windows
|
||||||
for id in self.tracked_windows.iter() {
|
for id in self.tracked_windows.iter() {
|
||||||
cmds.push(
|
cmds.push(
|
||||||
corner_radius(*id, rounded.then_some(cur_rad)).discard(),
|
corner_radius(
|
||||||
|
*id,
|
||||||
|
if rounded {
|
||||||
|
Some(cur_rad)
|
||||||
|
} else {
|
||||||
|
let rad_0 = t.radius_0();
|
||||||
|
Some(CornerRadius {
|
||||||
|
top_left: rad_0[0].round() as u32,
|
||||||
|
top_right: rad_0[1].round() as u32,
|
||||||
|
bottom_right: rad_0[2].round() as u32,
|
||||||
|
bottom_left: rad_0[3].round() as u32,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.discard(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1120,7 +1218,21 @@ impl<T: Application> Cosmic<T> {
|
||||||
let rounded = !self.app.core().window.sharp_corners;
|
let rounded = !self.app.core().window.sharp_corners;
|
||||||
|
|
||||||
return Task::batch(vec![
|
return Task::batch(vec![
|
||||||
corner_radius(id, rounded.then_some(cur_rad)).discard(),
|
corner_radius(
|
||||||
|
id,
|
||||||
|
if rounded {
|
||||||
|
Some(cur_rad)
|
||||||
|
} else {
|
||||||
|
let rad_0 = t.radius_0();
|
||||||
|
Some(CornerRadius {
|
||||||
|
top_left: rad_0[0].round() as u32,
|
||||||
|
top_right: rad_0[1].round() as u32,
|
||||||
|
bottom_right: rad_0[2].round() as u32,
|
||||||
|
bottom_left: rad_0[3].round() as u32,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.discard(),
|
||||||
iced_runtime::window::run_with_handle(id, init_windowing_system),
|
iced_runtime::window::run_with_handle(id, init_windowing_system),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue