pointer input for layer surface
Browse files at this commite7857efbd2a86e261d988ec62f73dd26d72e7a9cParent: ee8404b1 changed file +38 -13
- src/niri.rs +38 -13
src/niri.rsmodified+38 -13
| @@ -939,10 +939,9 @@ impl Niri { | |||
| 939 | pos: Point<f64, Logical>, | 939 | pos: Point<f64, Logical>, |
| 940 | ) -> Option<PointerFocus> { | 940 | ) -> Option<PointerFocus> { |
| 941 | let (output, pos_within_output) = self.output_under(pos)?; | 941 | let (output, pos_within_output) = self.output_under(pos)?; |
| 942 | - let output = output.clone(); | ||
| 943 | 942 | ||
| 944 | if self.is_locked() { | 943 | if self.is_locked() { |
| 945 | - let state = self.output_state.get(&output)?; | 944 | + let state = self.output_state.get(output)?; |
| 946 | let surface = state.lock_surface.as_ref()?; | 945 | let surface = state.lock_surface.as_ref()?; |
| 947 | // We put lock surfaces at (0, 0). | 946 | // We put lock surfaces at (0, 0). |
| 948 | let point = pos_within_output; | 947 | let point = pos_within_output; |
| @@ -953,7 +952,7 @@ impl Niri { | |||
| 953 | WindowSurfaceType::ALL, | 952 | WindowSurfaceType::ALL, |
| 954 | )?; | 953 | )?; |
| 955 | return Some(PointerFocus { | 954 | return Some(PointerFocus { |
| 956 | - output, | 955 | + output: output.clone(), |
| 957 | surface: (surface, point), | 956 | surface: (surface, point), |
| 958 | }); | 957 | }); |
| 959 | } | 958 | } |
| @@ -962,20 +961,46 @@ impl Niri { | |||
| 962 | return None; | 961 | return None; |
| 963 | } | 962 | } |
| 964 | 963 | ||
| 965 | - let (window, win_pos_within_output) = | 964 | + let layers = layer_map_for_output(output); |
| 966 | - self.layout.window_under(&output, pos_within_output)?; | 965 | + let layer_surface = |first: Layer, second: Layer| { |
| 966 | + layers | ||
| 967 | + .layer_under(first, pos_within_output) | ||
| 968 | + .or_else(|| layers.layer_under(second, pos_within_output)) | ||
| 969 | + .and_then(|layer| { | ||
| 970 | + let layer_pos_within_output = layers.layer_geometry(layer).unwrap().loc; | ||
| 971 | + layer | ||
| 972 | + .surface_under( | ||
| 973 | + pos_within_output - layer_pos_within_output.to_f64(), | ||
| 974 | + WindowSurfaceType::ALL, | ||
| 975 | + ) | ||
| 976 | + .map(|(surface, pos_within_layer)| { | ||
| 977 | + (surface, pos_within_layer + layer_pos_within_output) | ||
| 978 | + }) | ||
| 979 | + }) | ||
| 980 | + }; | ||
| 967 | 981 | ||
| 968 | - let (surface, surface_pos_within_output) = window | 982 | + let (surface, surface_pos_within_output) = layer_surface(Layer::Overlay, Layer::Top) |
| 969 | - .surface_under( | 983 | + .or_else(|| { |
| 970 | - pos_within_output - win_pos_within_output.to_f64(), | 984 | + self.layout |
| 971 | - WindowSurfaceType::ALL, | 985 | + .window_under(output, pos_within_output) |
| 972 | - ) | 986 | + .and_then(|(window, win_pos_within_output)| { |
| 973 | - .map(|(s, pos_within_window)| (s, pos_within_window + win_pos_within_output))?; | 987 | + window |
| 974 | - let output_pos_in_global_space = self.global_space.output_geometry(&output).unwrap().loc; | 988 | + .surface_under( |
| 989 | + pos_within_output - win_pos_within_output.to_f64(), | ||
| 990 | + WindowSurfaceType::ALL, | ||
| 991 | + ) | ||
| 992 | + .map(|(s, pos_within_window)| { | ||
| 993 | + (s, pos_within_window + win_pos_within_output) | ||
| 994 | + }) | ||
| 995 | + }) | ||
| 996 | + }) | ||
| 997 | + .or_else(|| layer_surface(Layer::Bottom, Layer::Background))?; | ||
| 998 | + | ||
| 999 | + let output_pos_in_global_space = self.global_space.output_geometry(output).unwrap().loc; | ||
| 975 | let surface_loc_in_global_space = surface_pos_within_output + output_pos_in_global_space; | 1000 | let surface_loc_in_global_space = surface_pos_within_output + output_pos_in_global_space; |
| 976 | 1001 | ||
| 977 | Some(PointerFocus { | 1002 | Some(PointerFocus { |
| 978 | - output, | 1003 | + output: output.clone(), |
| 979 | surface: (surface, surface_loc_in_global_space), | 1004 | surface: (surface, surface_loc_in_global_space), |
| 980 | }) | 1005 | }) |
| 981 | } | 1006 | } |