Compare commits

...

2 Commits

Author SHA1 Message Date
Thorsten Ball
1ca3ad4b75 Fix Clippy warning 2024-07-08 15:17:12 +02:00
Thorsten Ball
b37ba27fe1 linux/x11: reset and restore window cursor depending on focus state 2024-07-08 15:08:47 +02:00

View File

@@ -561,14 +561,27 @@ impl X11Client {
Event::FocusIn(event) => {
let window = self.get_window(event.event)?;
window.set_focused(true);
let mut state = self.0.borrow_mut();
state.focused_window = Some(event.event);
let cursor_style = state.cursor_styles.get(&window.x_window).cloned();
drop(state);
// Restore previously set cursor style for the window once it gains focus.
if let Some(cursor_style) = cursor_style {
self.set_cursor_style(cursor_style);
}
self.enable_ime();
}
Event::FocusOut(event) => {
// When we lose focus, we reset the cursor style of the currently focused window.
self.set_cursor_style(CursorStyle::Arrow);
let window = self.get_window(event.event)?;
window.set_focused(false);
let mut state = self.0.borrow_mut();
state.focused_window = None;
if let Some(compose_state) = state.compose_state.as_mut() {