Put interactively moved window on top of background and bottom layer popups
Browse files at this commit8b878f355f43b0e76840d6bfe535ff3b61a5f5caParent: 395b6d91 changed file +38 -9
- src/niri.rs +38 -9
src/niri.rsmodified+38 -9
| @@ -2837,7 +2837,7 @@ impl Niri { | ||
| 2837 | 2837 | Some((output, pos_within_output)) |
| 2838 | 2838 | } |
| 2839 | 2839 | |
| 2840 | - pub fn is_layout_obscured_under( | |
| 2840 | + pub fn is_sticky_obscured_under( | |
| 2841 | 2841 | &self, |
| 2842 | 2842 | output: &Output, |
| 2843 | 2843 | pos_within_output: Point<f64, Logical>, |
| @@ -2876,11 +2876,34 @@ impl Niri { | ||
| 2876 | 2876 | return false; |
| 2877 | 2877 | } |
| 2878 | 2878 | |
| 2879 | - if layer_popup_under(Layer::Top) | |
| 2880 | - || layer_toplevel_under(Layer::Top) | |
| 2881 | - || layer_popup_under(Layer::Bottom) | |
| 2882 | - || layer_popup_under(Layer::Background) | |
| 2883 | - { | |
| 2879 | + if layer_popup_under(Layer::Top) || layer_toplevel_under(Layer::Top) { | |
| 2880 | + return true; | |
| 2881 | + } | |
| 2882 | + | |
| 2883 | + false | |
| 2884 | + } | |
| 2885 | + | |
| 2886 | + pub fn is_layout_obscured_under( | |
| 2887 | + &self, | |
| 2888 | + output: &Output, | |
| 2889 | + pos_within_output: Point<f64, Logical>, | |
| 2890 | + ) -> bool { | |
| 2891 | + // Check if some layer-shell surface is on top. | |
| 2892 | + let layers = layer_map_for_output(output); | |
| 2893 | + let layer_popup_under = |layer| { | |
| 2894 | + layers | |
| 2895 | + .layers_on(layer) | |
| 2896 | + .rev() | |
| 2897 | + .find_map(|layer| { | |
| 2898 | + let layer_pos_within_output = | |
| 2899 | + layers.layer_geometry(layer).unwrap().loc.to_f64(); | |
| 2900 | + let surface_type = WindowSurfaceType::POPUP | WindowSurfaceType::SUBSURFACE; | |
| 2901 | + layer.surface_under(pos_within_output - layer_pos_within_output, surface_type) | |
| 2902 | + }) | |
| 2903 | + .is_some() | |
| 2904 | + }; | |
| 2905 | + | |
| 2906 | + if layer_popup_under(Layer::Bottom) || layer_popup_under(Layer::Background) { | |
| 2884 | 2907 | return true; |
| 2885 | 2908 | } |
| 2886 | 2909 | |
| @@ -2898,7 +2921,7 @@ impl Niri { | ||
| 2898 | 2921 | |
| 2899 | 2922 | let (output, pos_within_output) = self.output_under(pos)?; |
| 2900 | 2923 | |
| 2901 | - if self.is_layout_obscured_under(output, pos_within_output) { | |
| 2924 | + if self.is_sticky_obscured_under(output, pos_within_output) { | |
| 2902 | 2925 | return None; |
| 2903 | 2926 | } |
| 2904 | 2927 | |
| @@ -2909,6 +2932,10 @@ impl Niri { | ||
| 2909 | 2932 | return Some(window); |
| 2910 | 2933 | } |
| 2911 | 2934 | |
| 2935 | + if self.is_layout_obscured_under(output, pos_within_output) { | |
| 2936 | + return None; | |
| 2937 | + } | |
| 2938 | + | |
| 2912 | 2939 | let (window, _loc) = self.layout.window_under(output, pos_within_output)?; |
| 2913 | 2940 | Some(window) |
| 2914 | 2941 | } |
| @@ -3047,9 +3074,9 @@ impl Niri { | ||
| 3047 | 3074 | under = under |
| 3048 | 3075 | .or_else(|| layer_popup_under(Layer::Top)) |
| 3049 | 3076 | .or_else(|| layer_toplevel_under(Layer::Top)) |
| 3077 | + .or_else(interactive_moved_window_under) | |
| 3050 | 3078 | .or_else(|| layer_popup_under(Layer::Bottom)) |
| 3051 | 3079 | .or_else(|| layer_popup_under(Layer::Background)) |
| 3052 | - .or_else(interactive_moved_window_under) | |
| 3053 | 3080 | .or_else(window_under) |
| 3054 | 3081 | .or_else(|| layer_toplevel_under(Layer::Bottom)) |
| 3055 | 3082 | .or_else(|| layer_toplevel_under(Layer::Background)); |
| @@ -3847,13 +3874,15 @@ impl Niri { | ||
| 3847 | 3874 | elements.extend(layer_elems.normal.drain(..).map(OutputRenderElements::from)); |
| 3848 | 3875 | } else { |
| 3849 | 3876 | elements.extend(top_layer.into_iter().map(OutputRenderElements::from)); |
| 3850 | - elements.extend(layer_elems.popups.drain(..).map(OutputRenderElements::from)); | |
| 3851 | 3877 | |
| 3852 | 3878 | elements.extend( |
| 3853 | 3879 | int_move_elements |
| 3854 | 3880 | .into_iter() |
| 3855 | 3881 | .map(OutputRenderElements::from), |
| 3856 | 3882 | ); |
| 3883 | + | |
| 3884 | + elements.extend(layer_elems.popups.drain(..).map(OutputRenderElements::from)); | |
| 3885 | + | |
| 3857 | 3886 | elements.extend(monitor_elements.into_iter().map(OutputRenderElements::from)); |
| 3858 | 3887 | |
| 3859 | 3888 | elements.extend(layer_elems.normal.drain(..).map(OutputRenderElements::from)); |