Fix no outputs case handling in a few places

This commit is contained in:
Ivan Molodetskikh
2024-05-20 15:36:08 +04:00
parent 56e02a398d
commit f4cdde1f4f
3 changed files with 26 additions and 8 deletions
+11 -5
View File
@@ -24,11 +24,17 @@ impl WlrLayerShellHandler for State {
_layer: Layer,
namespace: String,
) {
let output = wl_output
.as_ref()
.and_then(Output::from_resource)
.or_else(|| self.niri.layout.active_output().cloned())
.unwrap();
let output = if let Some(wl_output) = &wl_output {
Output::from_resource(wl_output)
} else {
self.niri.layout.active_output().cloned()
};
let Some(output) = output else {
warn!("no output for new layer surface, closing");
surface.send_close();
return;
};
let mut map = layer_map_for_output(&output);
map.map_layer(&LayerSurface::new(surface, namespace))
.unwrap();
+1 -1
View File
@@ -288,7 +288,7 @@ impl SessionLockHandler for State {
fn new_surface(&mut self, surface: LockSurface, output: WlOutput) {
let Some(output) = Output::from_resource(&output) else {
error!("no Output matching WlOutput");
warn!("no Output matching WlOutput");
return;
};
+14 -2
View File
@@ -94,7 +94,13 @@ where
overlay_cursor,
output,
} => {
let output = Output::from_resource(&output).unwrap();
let Some(output) = Output::from_resource(&output) else {
trace!("screencopy client requested non-existent output");
let frame = data_init.init(frame, ScreencopyFrameState::Failed);
frame.failed();
return;
};
let buffer_size = output.current_mode().unwrap().size;
let region_loc = Point::from((0, 0));
@@ -116,7 +122,13 @@ where
return;
}
let output = Output::from_resource(&output).unwrap();
let Some(output) = Output::from_resource(&output) else {
trace!("screencopy client requested non-existent output");
let frame = data_init.init(frame, ScreencopyFrameState::Failed);
frame.failed();
return;
};
let output_transform = output.current_transform();
let output_physical_size =
output_transform.transform_size(output.current_mode().unwrap().size);