From 8fcd5e40d47f8d0cbf0a7c4852e0f6ea5ead4302 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 21 Apr 2022 11:41:57 +0530 Subject: [PATCH] Proper fix for reporting button in drag events to children --- kitty/mouse.c | 10 +++++++--- kitty/state.h | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kitty/mouse.c b/kitty/mouse.c index 0190c49f1..f30151ebc 100644 --- a/kitty/mouse.c +++ b/kitty/mouse.c @@ -120,9 +120,13 @@ encode_mouse_button(Window *w, int button, MouseAction action, int mods) { if (button == GLFW_MOUSE_BUTTON_LEFT) { switch(action) { case PRESS: - global_state.tracked_drag_in_window = w->id; break; + global_state.tracked_drag_in_window = w->id; + global_state.tracked_drag_button = button; + break; case RELEASE: - global_state.tracked_drag_in_window = 0; break; + global_state.tracked_drag_in_window = 0; + global_state.tracked_drag_button = -1; + break; default: break; } @@ -769,7 +773,7 @@ mouse_event(const int button, int modifiers, int action) { clamp_to_window = true; Tab *t = global_state.callback_os_window->tabs + global_state.callback_os_window->active_tab; for (window_idx = 0; window_idx < t->num_windows && t->windows[window_idx].id != w->id; window_idx++); - handle_move_event(w, button, modifiers, window_idx); + handle_move_event(w, global_state.tracked_drag_button, modifiers, window_idx); clamp_to_window = false; debug("sent to child as drag move\n"); return; diff --git a/kitty/state.h b/kitty/state.h index 15c5ac66c..8f17dcec0 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -233,7 +233,7 @@ typedef struct { bool check_for_active_animated_images; struct { double x, y; } default_dpi; id_type active_drag_in_window, tracked_drag_in_window; - int active_drag_button; + int active_drag_button, tracked_drag_button; CloseRequest quit_request; bool redirect_mouse_handling; WindowLogoTable *all_window_logos;