Proper fix for reporting button in drag events to children

This commit is contained in:
Kovid Goyal
2022-04-21 11:41:57 +05:30
parent b76319b7e8
commit 8fcd5e40d4
2 changed files with 8 additions and 4 deletions

View File

@@ -120,9 +120,13 @@ encode_mouse_button(Window *w, int button, MouseAction action, int mods) {
if (button == GLFW_MOUSE_BUTTON_LEFT) { if (button == GLFW_MOUSE_BUTTON_LEFT) {
switch(action) { switch(action) {
case PRESS: 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: 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: default:
break; break;
} }
@@ -769,7 +773,7 @@ mouse_event(const int button, int modifiers, int action) {
clamp_to_window = true; clamp_to_window = true;
Tab *t = global_state.callback_os_window->tabs + global_state.callback_os_window->active_tab; 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++); 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; clamp_to_window = false;
debug("sent to child as drag move\n"); debug("sent to child as drag move\n");
return; return;

View File

@@ -233,7 +233,7 @@ typedef struct {
bool check_for_active_animated_images; bool check_for_active_animated_images;
struct { double x, y; } default_dpi; struct { double x, y; } default_dpi;
id_type active_drag_in_window, tracked_drag_in_window; id_type active_drag_in_window, tracked_drag_in_window;
int active_drag_button; int active_drag_button, tracked_drag_button;
CloseRequest quit_request; CloseRequest quit_request;
bool redirect_mouse_handling; bool redirect_mouse_handling;
WindowLogoTable *all_window_logos; WindowLogoTable *all_window_logos;