From aac2c31a380590e016604eb0abf2f8505090f400 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 28 Sep 2023 13:21:11 -0600 Subject: [PATCH] Fix NextOutput and PreviousOutput when Shell::activate returns None --- src/input/mod.rs | 60 +++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/src/input/mod.rs b/src/input/mod.rs index 9af4c60d..3f277285 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -1187,19 +1187,25 @@ impl State { .cloned() { let idx = self.common.shell.workspaces.active_num(&next_output).1; - if let Ok(Some(new_pos)) = self.common.shell.activate(&next_output, idx) { - seat.set_active_output(&next_output); - if let Some(ptr) = seat.get_pointer() { - ptr.motion( - self, - None, - &MotionEvent { - location: new_pos.to_f64(), - serial, - time, - }, - ); + match self.common.shell.activate(&next_output, idx) { + Ok(Some(new_pos)) => { + seat.set_active_output(&next_output); + if let Some(ptr) = seat.get_pointer() { + ptr.motion( + self, + None, + &MotionEvent { + location: new_pos.to_f64(), + serial, + time, + }, + ); + } } + Ok(None) => { + seat.set_active_output(&next_output); + } + _ => {} } } } @@ -1217,19 +1223,25 @@ impl State { .cloned() { let idx = self.common.shell.workspaces.active_num(&prev_output).1; - if let Ok(Some(new_pos)) = self.common.shell.activate(&prev_output, idx) { - seat.set_active_output(&prev_output); - if let Some(ptr) = seat.get_pointer() { - ptr.motion( - self, - None, - &MotionEvent { - location: new_pos.to_f64(), - serial, - time, - }, - ); + match self.common.shell.activate(&prev_output, idx) { + Ok(Some(new_pos)) => { + seat.set_active_output(&prev_output); + if let Some(ptr) = seat.get_pointer() { + ptr.motion( + self, + None, + &MotionEvent { + location: new_pos.to_f64(), + serial, + time, + }, + ); + } } + Ok(None) => { + seat.set_active_output(&prev_output); + } + _ => {} } } }