From 2edcd09704c7d4d845f2d2927518caadaa9d7a4b Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Sat, 21 Oct 2023 11:09:53 +0400 Subject: [PATCH] On X11, fix cursor_hittest not reloaded on Resize The cursor hittest was not reloaded on window size changes, only when `Window::request_inner_size` was called leading to regions of the window being not clickable. Also, don't try to apply hittest logic when user never requested a hittest. Links: https://github.com/alacritty/alacritty/pull/7220 --- src/platform_impl/linux/x11/event_processor.rs | 6 ++++++ src/platform_impl/linux/x11/window.rs | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/platform_impl/linux/x11/event_processor.rs b/src/platform_impl/linux/x11/event_processor.rs index 8aaabca5..3e3c0f5e 100644 --- a/src/platform_impl/linux/x11/event_processor.rs +++ b/src/platform_impl/linux/x11/event_processor.rs @@ -484,6 +484,7 @@ impl EventProcessor { } let mut shared_state_lock = window.shared_state_lock(); + let hittest = shared_state_lock.cursor_hittest; // This is a hack to ensure that the DPI adjusted resize is actually applied on all WMs. KWin // doesn't need this, but Xfwm does. The hack should not be run on other WMs, since tiling @@ -501,6 +502,11 @@ impl EventProcessor { // Unlock shared state to prevent deadlock in callback below drop(shared_state_lock); + // Reload hittest. + if hittest.unwrap_or(false) { + let _ = window.set_cursor_hittest(true); + } + if resized { callback(Event::WindowEvent { window_id, diff --git a/src/platform_impl/linux/x11/window.rs b/src/platform_impl/linux/x11/window.rs index 0ceca722..1b08869f 100644 --- a/src/platform_impl/linux/x11/window.rs +++ b/src/platform_impl/linux/x11/window.rs @@ -64,7 +64,8 @@ pub struct SharedState { pub base_size: Option, pub visibility: Visibility, pub has_focus: bool, - pub cursor_hittest: bool, + // Use `Option` to not apply hittest logic when it was never requested. + pub cursor_hittest: Option, } #[derive(Copy, Clone, Debug, Eq, PartialEq)] @@ -105,7 +106,7 @@ impl SharedState { resize_increments: None, base_size: None, has_focus: false, - cursor_hittest: true, + cursor_hittest: None, }) } } @@ -1295,8 +1296,8 @@ impl UnownedWindow { self.xconn .flush_requests() .expect("Failed to call XResizeWindow"); - // cursor_hittest needs to be reapplied after window resize - if self.shared_state_lock().cursor_hittest { + // cursor_hittest needs to be reapplied after each window resize. + if self.shared_state_lock().cursor_hittest.unwrap_or(false) { let _ = self.set_cursor_hittest(true); } } @@ -1627,7 +1628,7 @@ impl UnownedWindow { .xcb_connection() .xfixes_set_window_shape_region(self.xwindow, SK::INPUT, 0, 0, region.region()) .map_err(|_e| ExternalError::Ignored)?; - self.shared_state_lock().cursor_hittest = hittest; + self.shared_state_lock().cursor_hittest = Some(hittest); Ok(()) }