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);