aboutsummaryrefslogtreecommitdiff
path: root/src/layout/workspace.rs
diff options
context:
space:
mode:
authorFluxTape <fluxtape.contact@gmail.com>2024-02-26 18:47:46 +0100
committerIvan Molodetskikh <yalterz@gmail.com>2024-03-18 19:31:11 +0400
commit741bee461cbdaf0236eaa55dc86dc84b01613128 (patch)
tree13c836833f34f1c53c7148d4d8dfe3f42a99fec5 /src/layout/workspace.rs
parent0c57815fbf47c69af9ed11fa8ebc1b52158a3ba2 (diff)
downloadniri-741bee461cbdaf0236eaa55dc86dc84b01613128.tar.gz
niri-741bee461cbdaf0236eaa55dc86dc84b01613128.tar.bz2
niri-741bee461cbdaf0236eaa55dc86dc84b01613128.zip
Implement warp-mouse-to-focus
Diffstat (limited to 'src/layout/workspace.rs')
-rw-r--r--src/layout/workspace.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs
index 41c9e140..2c18b40e 100644
--- a/src/layout/workspace.rs
+++ b/src/layout/workspace.rs
@@ -181,6 +181,15 @@ impl OutputId {
}
}
+impl ViewOffsetAdjustment {
+ pub fn target_view_offset(&self) -> f64 {
+ match self {
+ ViewOffsetAdjustment::Animation(anim) => anim.to(),
+ ViewOffsetAdjustment::Gesture(gesture) => gesture.current_view_offset,
+ }
+ }
+}
+
impl ColumnWidth {
fn resolve(self, options: &Options, view_width: i32) -> i32 {
match self {
@@ -1124,6 +1133,31 @@ impl<W: LayoutElement> Workspace<W> {
first.chain(rest)
}
+ fn active_column_ref(&self) -> Option<&Column<W>> {
+ if self.columns.is_empty() {
+ return None;
+ }
+ Some(&self.columns[self.active_column_idx])
+ }
+
+ /// Returns the geometry of the active tile relative to and clamped to the view.
+ ///
+ /// During animations, assumes the final view position.
+ pub fn active_tile_visual_rectangle(&self) -> Option<Rectangle<i32, Logical>> {
+ let col = self.active_column_ref()?;
+ let view_pos = self
+ .view_offset_adj
+ .as_ref()
+ .map_or(self.view_offset, |adj| adj.target_view_offset() as i32);
+
+ let tile_pos = Point::from((-view_pos, col.tile_y(col.active_tile_idx)));
+ let tile_size = col.active_tile_ref().tile_size();
+ let tile_rect = Rectangle::from_loc_and_size(tile_pos, tile_size);
+
+ let view = Rectangle::from_loc_and_size((0, 0), self.view_size);
+ view.intersection(tile_rect)
+ }
+
pub fn window_under(
&self,
pos: Point<f64, Logical>,
@@ -2010,6 +2044,10 @@ impl<W: LayoutElement> Column<W> {
pos
})
}
+
+ fn active_tile_ref(&self) -> &Tile<W> {
+ &self.tiles[self.active_tile_idx]
+ }
}
fn compute_new_view_offset(