From 2bbf9a4e9bb05048c7e7cc233eff24a1695c91d1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 7 Mar 2023 11:29:57 +0530 Subject: [PATCH] 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 --- docs/changelog.rst | 2 ++ kitty/glfw.c | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 795029a9c..950070aab 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -76,6 +76,8 @@ Detailed list of changes - Fix overlay windows not inheriting the per-window padding and margin settings 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] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/glfw.c b/kitty/glfw.c index 82dc2297e..d104d3071 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -434,8 +434,16 @@ static id_type focus_counter = 0; static void window_focus_callback(GLFWwindow *w, int focused) { - global_state.active_drag_in_window = 0; 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; if (focused) { show_mouse_cursor(w);