Extract is_layout_obscured_under()
Browse files at this commit5cd8040d1ae46b1c1631fc6b61cde5cbf86883ddParent: 86351931 changed file +24 -12
- src/niri.rs +24 -12
src/niri.rsmodified+24 -12
| @@ -2837,17 +2837,11 @@ impl Niri { | |||
| 2837 | Some((output, pos_within_output)) | 2837 | Some((output, pos_within_output)) |
| 2838 | } | 2838 | } |
| 2839 | 2839 | ||
| 2840 | - /// Returns the window under the position to be activated. | 2840 | + pub fn is_layout_obscured_under( |
| 2841 | - /// | 2841 | + &self, |
| 2842 | - /// The cursor may be inside the window's activation region, but not within the window's input | 2842 | + output: &Output, |
| 2843 | - /// region. | 2843 | + pos_within_output: Point<f64, Logical>, |
| 2844 | - pub fn window_under(&self, pos: Point<f64, Logical>) -> Option<&Mapped> { | 2844 | + ) -> bool { |
| 2845 | - if self.is_locked() || self.screenshot_ui.is_open() { | ||
| 2846 | - return None; | ||
| 2847 | - } | ||
| 2848 | - | ||
| 2849 | - let (output, pos_within_output) = self.output_under(pos)?; | ||
| 2850 | - | ||
| 2851 | // The ordering here must be consistent with the ordering in render() so that input is | 2845 | // The ordering here must be consistent with the ordering in render() so that input is |
| 2852 | // consistent with the visuals. | 2846 | // consistent with the visuals. |
| 2853 | 2847 | ||
| @@ -2874,7 +2868,7 @@ impl Niri { | |||
| 2874 | let layer_popup_under = |layer| layer_surface_under(layer, true); | 2868 | let layer_popup_under = |layer| layer_surface_under(layer, true); |
| 2875 | 2869 | ||
| 2876 | if layer_popup_under(Layer::Overlay) || layer_toplevel_under(Layer::Overlay) { | 2870 | if layer_popup_under(Layer::Overlay) || layer_toplevel_under(Layer::Overlay) { |
| 2877 | - return None; | 2871 | + return true; |
| 2878 | } | 2872 | } |
| 2879 | 2873 | ||
| 2880 | let mon = self.layout.monitor_for_output(output).unwrap(); | 2874 | let mon = self.layout.monitor_for_output(output).unwrap(); |
| @@ -2884,6 +2878,24 @@ impl Niri { | |||
| 2884 | || layer_popup_under(Layer::Bottom) | 2878 | || layer_popup_under(Layer::Bottom) |
| 2885 | || layer_popup_under(Layer::Background)) | 2879 | || layer_popup_under(Layer::Background)) |
| 2886 | { | 2880 | { |
| 2881 | + return true; | ||
| 2882 | + } | ||
| 2883 | + | ||
| 2884 | + false | ||
| 2885 | + } | ||
| 2886 | + | ||
| 2887 | + /// Returns the window under the position to be activated. | ||
| 2888 | + /// | ||
| 2889 | + /// The cursor may be inside the window's activation region, but not within the window's input | ||
| 2890 | + /// region. | ||
| 2891 | + pub fn window_under(&self, pos: Point<f64, Logical>) -> Option<&Mapped> { | ||
| 2892 | + if self.is_locked() || self.screenshot_ui.is_open() { | ||
| 2893 | + return None; | ||
| 2894 | + } | ||
| 2895 | + | ||
| 2896 | + let (output, pos_within_output) = self.output_under(pos)?; | ||
| 2897 | + | ||
| 2898 | + if self.is_layout_obscured_under(output, pos_within_output) { | ||
| 2887 | return None; | 2899 | return None; |
| 2888 | } | 2900 | } |
| 2889 | 2901 | ||