Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(tao): guard CursorIgnoreEvents against unrealized GDK window on Linux

Richie McIlroy6b0965090be0
diff --git a/vendor/tao/src/platform_impl/linux/event_loop.rs b/vendor/tao/src/platform_impl/linux/event_loop.rs
index 7409eea7b..94863a5a3 100644
--- a/vendor/tao/src/platform_impl/linux/event_loop.rs
+++ b/vendor/tao/src/platform_impl/linux/event_loop.rs
@@ -443,11 +443,12 @@ impl<T: 'static> EventLoop<T> {
}
WindowRequest::CursorIgnoreEvents(ignore) => {
if ignore {
- let empty_region = Region::create_rectangle(&RectangleInt::new(0, 0, 1, 1));
- window
- .window()
- .unwrap()
- .input_shape_combine_region(&empty_region, 0, 0);
+ // `window()` is `None` until the GDK window is realized; calling
+ // `set_ignore_cursor_events` before then must not abort the app.
+ if let Some(gdk_window) = window.window() {
+ let empty_region = Region::create_rectangle(&RectangleInt::new(0, 0, 1, 1));
+ gdk_window.input_shape_combine_region(&empty_region, 0, 0);
+ }
} else {
window.input_shape_combine_region(None)
};