diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-03-17 10:06:18 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-03-18 19:31:11 +0400 |
| commit | 84302796dcef622ecb2b7d4532ccea8dba351f2e (patch) | |
| tree | 8ce1bd483202e2fe8e314cb4a4a07817f2a2bd47 | |
| parent | a39e703fc3ba23a3eff0bdaf394d1afa3ecf2f67 (diff) | |
| download | niri-84302796dcef622ecb2b7d4532ccea8dba351f2e.tar.gz niri-84302796dcef622ecb2b7d4532ccea8dba351f2e.tar.bz2 niri-84302796dcef622ecb2b7d4532ccea8dba351f2e.zip | |
Take workspace switch gesture into account for visual rect
| -rw-r--r-- | src/layout/monitor.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index e9fb2271..6660d1b2 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -67,6 +67,13 @@ impl WorkspaceSwitch { } } + pub fn target_idx(&self) -> f64 { + match self { + WorkspaceSwitch::Animation(anim) => anim.to(), + WorkspaceSwitch::Gesture(gesture) => gesture.current_idx, + } + } + /// Returns `true` if the workspace switch is [`Animation`]. /// /// [`Animation`]: WorkspaceSwitch::Animation @@ -587,8 +594,19 @@ impl<W: LayoutElement> Monitor<W> { /// /// During animations, assumes the final view position. pub fn active_tile_visual_rectangle(&self) -> Option<Rectangle<i32, Logical>> { - // FIXME: switch gesture. - self.active_workspace_ref().active_tile_visual_rectangle() + let mut rect = self.active_workspace_ref().active_tile_visual_rectangle()?; + + if let Some(switch) = &self.workspace_switch { + let size = output_size(&self.output); + + let offset = switch.target_idx() - self.active_workspace_idx as f64; + let offset = (offset * size.h as f64).round() as i32; + + let clip_rect = Rectangle::from_loc_and_size((0, -offset), size); + rect = rect.intersection(clip_rect)?; + } + + Some(rect) } pub fn window_under( |
