aboutsummaryrefslogtreecommitdiff
path: root/src/layout/tile.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-02-10 08:47:44 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-02-10 07:29:33 -0800
commit55e2ea0c3bb0bccae351aa6e82987a0b77da54ae (patch)
treed1d4d6ce033fe458e4be0cfdfaf3b04b76a7e442 /src/layout/tile.rs
parent1d883931b4ae7704128f02fd566486fb02351196 (diff)
downloadniri-55e2ea0c3bb0bccae351aa6e82987a0b77da54ae.tar.gz
niri-55e2ea0c3bb0bccae351aa6e82987a0b77da54ae.tar.bz2
niri-55e2ea0c3bb0bccae351aa6e82987a0b77da54ae.zip
layout: Extract tile.hit(), HitType::hit_tile()
Diffstat (limited to 'src/layout/tile.rs')
-rw-r--r--src/layout/tile.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/layout/tile.rs b/src/layout/tile.rs
index ff099bab..a08f058f 100644
--- a/src/layout/tile.rs
+++ b/src/layout/tile.rs
@@ -10,8 +10,8 @@ use super::focus_ring::{FocusRing, FocusRingRenderElement};
use super::opening_window::{OpenAnimation, OpeningWindowRenderElement};
use super::shadow::Shadow;
use super::{
- LayoutElement, LayoutElementRenderElement, LayoutElementRenderSnapshot, Options, SizeFrac,
- RESIZE_ANIMATION_THRESHOLD,
+ HitType, LayoutElement, LayoutElementRenderElement, LayoutElementRenderSnapshot, Options,
+ SizeFrac, RESIZE_ANIMATION_THRESHOLD,
};
use crate::animation::{Animation, Clock};
use crate::niri_render_elements;
@@ -606,16 +606,27 @@ impl<W: LayoutElement> Tile<W> {
loc
}
- pub fn is_in_input_region(&self, mut point: Point<f64, Logical>) -> bool {
+ fn is_in_input_region(&self, mut point: Point<f64, Logical>) -> bool {
point -= self.window_loc().to_f64();
self.window.is_in_input_region(point)
}
- pub fn is_in_activation_region(&self, point: Point<f64, Logical>) -> bool {
+ fn is_in_activation_region(&self, point: Point<f64, Logical>) -> bool {
let activation_region = Rectangle::from_size(self.tile_size());
activation_region.contains(point)
}
+ pub fn hit(&self, point: Point<f64, Logical>) -> Option<HitType> {
+ if self.is_in_input_region(point) {
+ let win_pos = self.buf_loc();
+ Some(HitType::Input { win_pos })
+ } else if self.is_in_activation_region(point) {
+ Some(HitType::Activate)
+ } else {
+ None
+ }
+ }
+
pub fn request_tile_size(
&mut self,
mut size: Size<f64, Logical>,