forge
Explore
Log in

Don't you dare go Hollow

Take workspace switch gesture into account for visual rect

Browse files at this commit

84302796dcef622ecb2b7d4532ccea8dba351f2eIvan MolodetskikhParent: a39e703
src/layout/monitor.rsmodified+20 -2
@@ -67,6 +67,13 @@ impl WorkspaceSwitch {
67 }67 }
68 }68 }
69 69
70+ pub fn target_idx(&self) -> f64 {
71+ match self {
72+ WorkspaceSwitch::Animation(anim) => anim.to(),
73+ WorkspaceSwitch::Gesture(gesture) => gesture.current_idx,
74+ }
75+ }
76+
70 /// Returns `true` if the workspace switch is [`Animation`].77 /// Returns `true` if the workspace switch is [`Animation`].
71 ///78 ///
72 /// [`Animation`]: WorkspaceSwitch::Animation79 /// [`Animation`]: WorkspaceSwitch::Animation
@@ -587,8 +594,19 @@ impl<W: LayoutElement> Monitor<W> {
587 ///594 ///
588 /// During animations, assumes the final view position.595 /// During animations, assumes the final view position.
589 pub fn active_tile_visual_rectangle(&self) -> Option<Rectangle<i32, Logical>> {596 pub fn active_tile_visual_rectangle(&self) -> Option<Rectangle<i32, Logical>> {
590- // FIXME: switch gesture.597+ let mut rect = self.active_workspace_ref().active_tile_visual_rectangle()?;
591- self.active_workspace_ref().active_tile_visual_rectangle()598+
599+ if let Some(switch) = &self.workspace_switch {
600+ let size = output_size(&self.output);
601+
602+ let offset = switch.target_idx() - self.active_workspace_idx as f64;
603+ let offset = (offset * size.h as f64).round() as i32;
604+
605+ let clip_rect = Rectangle::from_loc_and_size((0, -offset), size);
606+ rect = rect.intersection(clip_rect)?;
607+ }
608+
609+ Some(rect)
592 }610 }
593 611
594 pub fn window_under(612 pub fn window_under(