aboutsummaryrefslogtreecommitdiff
path: root/src/layout/tab_indicator.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-02-10 13:12:53 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-02-10 07:29:33 -0800
commit6942ecc13a40867850fc26429da21603647e8026 (patch)
treefaa00e99985eb8d24acb09235d93b7fe2822b301 /src/layout/tab_indicator.rs
parent963ff14ed025eeb5d6785dbcd4c073251ef7a9e9 (diff)
downloadniri-6942ecc13a40867850fc26429da21603647e8026.tar.gz
niri-6942ecc13a40867850fc26429da21603647e8026.tar.bz2
niri-6942ecc13a40867850fc26429da21603647e8026.zip
Implement clicking on tab to switch
Diffstat (limited to 'src/layout/tab_indicator.rs')
-rw-r--r--src/layout/tab_indicator.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/layout/tab_indicator.rs b/src/layout/tab_indicator.rs
index 451f2224..ad457386 100644
--- a/src/layout/tab_indicator.rs
+++ b/src/layout/tab_indicator.rs
@@ -182,6 +182,27 @@ impl TabIndicator {
}
}
+ pub fn hit(
+ &self,
+ area: Rectangle<f64, Logical>,
+ tab_count: usize,
+ scale: f64,
+ point: Point<f64, Logical>,
+ ) -> Option<usize> {
+ if self.config.off {
+ return None;
+ }
+
+ let count = tab_count;
+ if self.config.hide_when_single_tab && count == 1 {
+ return None;
+ }
+
+ self.tab_rects(area, count, scale)
+ .enumerate()
+ .find_map(|(idx, rect)| rect.contains(point).then_some(idx))
+ }
+
pub fn render(
&self,
renderer: &mut impl NiriRenderer,