Simplify compositor and shell conditionals
Flatten nested guards in swipe cleanup, recording updates and popup dismissal. Use an eager optional fallback for workspace layouts and an array in the malformed-opacity test.
This commit is contained in:
1 parent
3ba1f3522d
commit
5706a71941
5 files changed
+13
-15
No files matched your search
@@ -590,7 +590,7 @@ mod tests {
|
||||
assert_eq!(decode_region_opacities(&[]), Some(vec![]));
|
||||
assert!(decode_region_opacities(&bytes[..11]).is_none());
|
||||
assert!(decode_region_opacities(&1001u32.to_ne_bytes()).is_none());
|
||||
assert!(decode_region_opacities(&vec![0; 33 * 4]).is_none());
|
||||
assert!(decode_region_opacities(&[0; 33 * 4]).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -160,12 +160,11 @@ impl Ferese {
|
||||
.focus_swipe
|
||||
.as_ref()
|
||||
.is_some_and(|swipe| !self.focus_swipe_is_current(swipe))
|
||||
&& let Some(swipe) = self.focus_swipe.take()
|
||||
{
|
||||
if let Some(swipe) = self.focus_swipe.take() {
|
||||
self.presentation_dependencies
|
||||
.restore_viewport(swipe.workspace, swipe.dependencies);
|
||||
self.release_presentation_dependencies();
|
||||
}
|
||||
self.presentation_dependencies
|
||||
.restore_viewport(swipe.workspace, swipe.dependencies);
|
||||
self.release_presentation_dependencies();
|
||||
}
|
||||
|
||||
let mut active_animation = false;
|
||||
|
||||
@@ -330,7 +330,7 @@ impl Ferese {
|
||||
.as_ref()
|
||||
.filter(|swipe| swipe.workspace == workspace.id)
|
||||
.and_then(|swipe| swipe.layout.as_ref())
|
||||
.or_else(|| match &workspace.layout {
|
||||
.or(match &workspace.layout {
|
||||
WorkspaceLayout::Scrolling(layout) => Some(layout),
|
||||
_ => None,
|
||||
});
|
||||
|
||||
@@ -159,10 +159,8 @@ impl Recorder {
|
||||
match event {
|
||||
Event::Update(update) => match update.state.as_str() {
|
||||
"selecting" if self.control.is_some() => self.state = State::Selecting,
|
||||
"recording" if self.control.is_some() => {
|
||||
if !matches!(self.state, State::Recording(_)) {
|
||||
self.state = State::Recording(Instant::now());
|
||||
}
|
||||
"recording" if self.control.is_some() && !matches!(self.state, State::Recording(_)) => {
|
||||
self.state = State::Recording(Instant::now());
|
||||
}
|
||||
"saving" => self.state = State::Saving,
|
||||
"saved" => {
|
||||
|
||||
@@ -153,10 +153,11 @@ impl FereseShell {
|
||||
}
|
||||
|
||||
pub fn animate_menu(&mut self) -> Task<Message> {
|
||||
if let Some(menu) = &self.menu {
|
||||
if menu.motion.closing() && !menu.animating() {
|
||||
return self.destroy_menu();
|
||||
}
|
||||
if let Some(menu) = &self.menu
|
||||
&& menu.motion.closing()
|
||||
&& !menu.animating()
|
||||
{
|
||||
return self.destroy_menu();
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user