diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-06-17 20:20:26 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-06-18 14:01:34 +0300 |
| commit | 793e1bdbc5fdbf99e264558375bd27cffabc4ec8 (patch) | |
| tree | aee646c7ab7b6c451278b92533bf0704dfc09841 /src/layout | |
| parent | d62721d5f8dafca9b247ac7763aa93078a5063a5 (diff) | |
| download | niri-793e1bdbc5fdbf99e264558375bd27cffabc4ec8.tar.gz niri-793e1bdbc5fdbf99e264558375bd27cffabc4ec8.tar.bz2 niri-793e1bdbc5fdbf99e264558375bd27cffabc4ec8.zip | |
Animate xdg-activation and foreign-toplevel workspace switches
These are a bit jarring without an animation.
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/mod.rs | 14 | ||||
| -rw-r--r-- | src/layout/monitor.rs | 15 |
2 files changed, 17 insertions, 12 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index ffc5e0e8..b8b13560 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -43,8 +43,8 @@ use smithay::output::{self, Output}; use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; use smithay::utils::{Logical, Point, Scale, Serial, Size, Transform}; -use self::monitor::Monitor; pub use self::monitor::MonitorRenderElement; +use self::monitor::{Monitor, WorkspaceSwitch}; use self::workspace::{compute_working_area, Column, ColumnWidth, OutputId, Workspace}; use crate::niri_render_elements; use crate::render_helpers::renderer::NiriRenderer; @@ -963,9 +963,13 @@ impl<W: LayoutElement> Layout<W> { *active_monitor_idx = monitor_idx; ws.activate_window(window); - // Switch to that workspace if not already during a transition. - if mon.workspace_switch.is_none() { - mon.switch_workspace(workspace_idx); + // If currently in the middle of a vertical swipe between the target workspace + // and some other, don't switch the workspace. + match &mon.workspace_switch { + Some(WorkspaceSwitch::Gesture(gesture)) + if gesture.current_idx.floor() == workspace_idx as f64 + || gesture.current_idx.ceil() == workspace_idx as f64 => {} + _ => mon.switch_workspace(workspace_idx, true), } break; @@ -1388,7 +1392,7 @@ impl<W: LayoutElement> Layout<W> { let Some(monitor) = self.active_monitor() else { return; }; - monitor.switch_workspace(idx); + monitor.switch_workspace(idx, false); } pub fn switch_workspace_auto_back_and_forth(&mut self, idx: usize) { diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index eb72242f..911e0480 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -569,12 +569,13 @@ impl<W: LayoutElement> Monitor<W> { self.workspaces.iter().position(|w| w.id() == id) } - pub fn switch_workspace(&mut self, idx: usize) { + pub fn switch_workspace(&mut self, idx: usize, animate: bool) { self.activate_workspace(min(idx, self.workspaces.len() - 1)); - // Don't animate this action. - self.workspace_switch = None; - self.clean_up_workspaces(); + if !animate { + self.workspace_switch = None; + self.clean_up_workspaces(); + } } pub fn switch_workspace_auto_back_and_forth(&mut self, idx: usize) { @@ -582,16 +583,16 @@ impl<W: LayoutElement> Monitor<W> { if idx == self.active_workspace_idx { if let Some(prev_idx) = self.previous_workspace_idx() { - self.switch_workspace(prev_idx); + self.switch_workspace(prev_idx, false); } } else { - self.switch_workspace(idx); + self.switch_workspace(idx, false); } } pub fn switch_workspace_previous(&mut self) { if let Some(idx) = self.previous_workspace_idx() { - self.switch_workspace(idx); + self.switch_workspace(idx, false); } } |
