From 6942ecc13a40867850fc26429da21603647e8026 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Mon, 10 Feb 2025 13:12:53 +0300 Subject: Implement clicking on tab to switch --- src/layout/tab_indicator.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/layout/tab_indicator.rs') 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, + tab_count: usize, + scale: f64, + point: Point, + ) -> Option { + 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, -- cgit