Wayland KDE: Fix selecting in un-focused OS window not working correctly

Every day, in every way, I fall deeper and deeper in love with Yayland!

Fixes #6095
This commit is contained in:
Kovid Goyal 2023-03-07 11:29:57 +05:30
parent e043fef257
commit 2bbf9a4e9b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 11 additions and 1 deletions

View File

@ -76,6 +76,8 @@ Detailed list of changes
- Fix overlay windows not inheriting the per-window padding and margin settings - Fix overlay windows not inheriting the per-window padding and margin settings
of their parents (:iss:`6063`) of their parents (:iss:`6063`)
- Wayland KDE: Fix selecting in un-focused OS window not working correctly (:iss:`6095`)
0.27.1 [2023-02-07] 0.27.1 [2023-02-07]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -434,8 +434,16 @@ static id_type focus_counter = 0;
static void static void
window_focus_callback(GLFWwindow *w, int focused) { window_focus_callback(GLFWwindow *w, int focused) {
global_state.active_drag_in_window = 0;
if (!set_callback_window(w)) return; if (!set_callback_window(w)) return;
// There exist some numbnut Wayland compositors, like kwin, that send mouse
// press events before focus gained events. So only clear the active drag
// window if it is not the focused window. See https://github.com/kovidgoyal/kitty/issues/6095
if (
(!focused && global_state.callback_os_window->id == global_state.active_drag_in_window) ||
(focused && global_state.callback_os_window->id != global_state.active_drag_in_window)
) {
global_state.active_drag_in_window = 0;
}
global_state.callback_os_window->is_focused = focused ? true : false; global_state.callback_os_window->is_focused = focused ? true : false;
if (focused) { if (focused) {
show_mouse_cursor(w); show_mouse_cursor(w);