From b13892ca637cccfb496e3204b2793c069af17ccb Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 28 Dec 2023 08:45:12 +0400 Subject: Activate windows when clicking on the border --- src/layout/workspace.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/layout/workspace.rs') diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 32302187..090e27dd 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -761,7 +761,10 @@ impl Workspace { self.column_x(self.active_column_idx) + self.view_offset } - pub fn window_under(&self, pos: Point) -> Option<(&W, Point)> { + pub fn window_under( + &self, + pos: Point, + ) -> Option<(&W, Option>)> { if self.columns.is_empty() { return None; } @@ -775,8 +778,12 @@ impl Workspace { self.column_x(self.active_column_idx) - view_pos, col.tile_y(col.active_tile_idx), )); - if active_tile.is_in_input_region(pos - tile_pos.to_f64()) { - return Some((active_tile.window(), tile_pos + active_tile.buf_loc())); + let pos_within_tile = pos - tile_pos.to_f64(); + if active_tile.is_in_input_region(pos_within_tile) { + let pos_within_surface = tile_pos + active_tile.buf_loc(); + return Some((active_tile.window(), Some(pos_within_surface))); + } else if active_tile.is_in_activation_region(pos_within_tile) { + return Some((active_tile.window(), None)); } let mut x = -view_pos; @@ -788,8 +795,12 @@ impl Workspace { } let tile_pos = Point::from((x, y)); - if tile.is_in_input_region(pos - tile_pos.to_f64()) { - return Some((tile.window(), tile_pos + tile.buf_loc())); + let pos_within_tile = pos - tile_pos.to_f64(); + if tile.is_in_input_region(pos_within_tile) { + let pos_within_surface = tile_pos + tile.buf_loc(); + return Some((tile.window(), Some(pos_within_surface))); + } else if tile.is_in_activation_region(pos_within_tile) { + return Some((tile.window(), None)); } } -- cgit