Fix no outputs case handling in a few places
Browse files at this commitf4cdde1f4f89729f91336ea2f5ad7a1265e3bf70Parent: 56e02a33 changed files +26 -8
- src/handlers/layer_shell.rs +11 -5
- src/handlers/mod.rs +1 -1
- src/protocols/screencopy.rs +14 -2
src/handlers/layer_shell.rsmodified+11 -5
| @@ -24,11 +24,17 @@ impl WlrLayerShellHandler for State { | |||
| 24 | _layer: Layer, | 24 | _layer: Layer, |
| 25 | namespace: String, | 25 | namespace: String, |
| 26 | ) { | 26 | ) { |
| 27 | - let output = wl_output | 27 | + let output = if let Some(wl_output) = &wl_output { |
| 28 | - .as_ref() | 28 | + Output::from_resource(wl_output) |
| 29 | - .and_then(Output::from_resource) | 29 | + } else { |
| 30 | - .or_else(|| self.niri.layout.active_output().cloned()) | 30 | + self.niri.layout.active_output().cloned() |
| 31 | - .unwrap(); | 31 | + }; |
| 32 | + let Some(output) = output else { | ||
| 33 | + warn!("no output for new layer surface, closing"); | ||
| 34 | + surface.send_close(); | ||
| 35 | + return; | ||
| 36 | + }; | ||
| 37 | + | ||
| 32 | let mut map = layer_map_for_output(&output); | 38 | let mut map = layer_map_for_output(&output); |
| 33 | map.map_layer(&LayerSurface::new(surface, namespace)) | 39 | map.map_layer(&LayerSurface::new(surface, namespace)) |
| 34 | .unwrap(); | 40 | .unwrap(); |
src/handlers/mod.rsmodified+1 -1
| @@ -288,7 +288,7 @@ impl SessionLockHandler for State { | |||
| 288 | 288 | ||
| 289 | fn new_surface(&mut self, surface: LockSurface, output: WlOutput) { | 289 | fn new_surface(&mut self, surface: LockSurface, output: WlOutput) { |
| 290 | let Some(output) = Output::from_resource(&output) else { | 290 | let Some(output) = Output::from_resource(&output) else { |
| 291 | - error!("no Output matching WlOutput"); | 291 | + warn!("no Output matching WlOutput"); |
| 292 | return; | 292 | return; |
| 293 | }; | 293 | }; |
| 294 | 294 | ||
src/protocols/screencopy.rsmodified+14 -2
| @@ -94,7 +94,13 @@ where | |||
| 94 | overlay_cursor, | 94 | overlay_cursor, |
| 95 | output, | 95 | output, |
| 96 | } => { | 96 | } => { |
| 97 | - let output = Output::from_resource(&output).unwrap(); | 97 | + let Some(output) = Output::from_resource(&output) else { |
| 98 | + trace!("screencopy client requested non-existent output"); | ||
| 99 | + let frame = data_init.init(frame, ScreencopyFrameState::Failed); | ||
| 100 | + frame.failed(); | ||
| 101 | + return; | ||
| 102 | + }; | ||
| 103 | + | ||
| 98 | let buffer_size = output.current_mode().unwrap().size; | 104 | let buffer_size = output.current_mode().unwrap().size; |
| 99 | let region_loc = Point::from((0, 0)); | 105 | let region_loc = Point::from((0, 0)); |
| 100 | 106 | ||
| @@ -116,7 +122,13 @@ where | |||
| 116 | return; | 122 | return; |
| 117 | } | 123 | } |
| 118 | 124 | ||
| 119 | - let output = Output::from_resource(&output).unwrap(); | 125 | + let Some(output) = Output::from_resource(&output) else { |
| 126 | + trace!("screencopy client requested non-existent output"); | ||
| 127 | + let frame = data_init.init(frame, ScreencopyFrameState::Failed); | ||
| 128 | + frame.failed(); | ||
| 129 | + return; | ||
| 130 | + }; | ||
| 131 | + | ||
| 120 | let output_transform = output.current_transform(); | 132 | let output_transform = output.current_transform(); |
| 121 | let output_physical_size = | 133 | let output_physical_size = |
| 122 | output_transform.transform_size(output.current_mode().unwrap().size); | 134 | output_transform.transform_size(output.current_mode().unwrap().size); |