mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Fix spurious drag start on initial click
This commit is contained in:
@@ -193,7 +193,7 @@ set_currently_hovered_window(id_type window_id, int modifiers) {
|
|||||||
if (sz > 0) {
|
if (sz > 0) {
|
||||||
mouse_event_buf[sz] = 0;
|
mouse_event_buf[sz] = 0;
|
||||||
write_escape_code_to_child(left_window->render_data.screen, ESC_CSI, mouse_event_buf);
|
write_escape_code_to_child(left_window->render_data.screen, ESC_CSI, mouse_event_buf);
|
||||||
debug("Sent mouse leave event to window: %llu\n", left_window->id);
|
debug("Sent mouse leave event to window: %llu currently hovering: %llu\n", left_window->id, window_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (window_id && OPT(focus_follows_mouse).on_cross && global_state.callback_os_window && global_state.callback_os_window->num_tabs) {
|
if (window_id && OPT(focus_follows_mouse).on_cross && global_state.callback_os_window && global_state.callback_os_window->num_tabs) {
|
||||||
@@ -867,7 +867,10 @@ HANDLER(handle_button_event) {
|
|||||||
|
|
||||||
if (button == GLFW_MOUSE_BUTTON_LEFT && osw->suppress_left_mouse_release) {
|
if (button == GLFW_MOUSE_BUTTON_LEFT && osw->suppress_left_mouse_release) {
|
||||||
osw->suppress_left_mouse_release = false;
|
osw->suppress_left_mouse_release = false;
|
||||||
if (is_release) return;
|
if (is_release) {
|
||||||
|
zero_at_ptr(&w->drag_source.initial_left_press);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handle_scrollbar_mouse(w, button, is_release ? RELEASE : PRESS, modifiers)) return;
|
if (handle_scrollbar_mouse(w, button, is_release ? RELEASE : PRESS, modifiers)) return;
|
||||||
@@ -895,7 +898,7 @@ HANDLER(handle_button_event) {
|
|||||||
zero_at_ptr(&w->drag_source.initial_left_press);
|
zero_at_ptr(&w->drag_source.initial_left_press);
|
||||||
} else {
|
} else {
|
||||||
w->drag_source.initial_left_press.x = w->mouse_pos.global_x;
|
w->drag_source.initial_left_press.x = w->mouse_pos.global_x;
|
||||||
w->drag_source.initial_left_press.y = w->mouse_pos.global_x;
|
w->drag_source.initial_left_press.y = w->mouse_pos.global_y;
|
||||||
w->drag_source.initial_left_press.at = monotonic();
|
w->drag_source.initial_left_press.at = monotonic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -958,8 +961,10 @@ handle_tab_bar_mouse(int button, int modifiers, int action) {
|
|||||||
static bool
|
static bool
|
||||||
mouse_in_region(Region *r) {
|
mouse_in_region(Region *r) {
|
||||||
if (r->left == r->right) return false;
|
if (r->left == r->right) return false;
|
||||||
if (global_state.callback_os_window->mouse_y < r->top || global_state.callback_os_window->mouse_y >= r->bottom) return false;
|
OSWindow *w = global_state.callback_os_window;
|
||||||
if (global_state.callback_os_window->mouse_x < r->left || global_state.callback_os_window->mouse_x >= r->right) return false;
|
if (!w) return false;
|
||||||
|
if (w->mouse_y < r->top || w->mouse_y >= r->bottom) return false;
|
||||||
|
if (w->mouse_x < r->left || w->mouse_x >= r->right) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1319,15 +1324,18 @@ mouse_event(const int button, int modifiers, int action) {
|
|||||||
}
|
}
|
||||||
} else if (action == GLFW_RELEASE && button == GLFW_MOUSE_BUTTON_LEFT) {
|
} else if (action == GLFW_RELEASE && button == GLFW_MOUSE_BUTTON_LEFT) {
|
||||||
w = window_for_id(global_state.tracked_drag_in_window);
|
w = window_for_id(global_state.tracked_drag_in_window);
|
||||||
if (w && w->render_data.screen->modes.mouse_tracking_mode >= BUTTON_MODE && w->render_data.screen->modes.mouse_tracking_protocol >= SGR_PROTOCOL) {
|
if (w) {
|
||||||
global_state.tracked_drag_in_window = 0;
|
zero_at_ptr(&w->drag_source.initial_left_press);
|
||||||
clamp_to_window = true;
|
if (w->render_data.screen->modes.mouse_tracking_mode >= BUTTON_MODE && w->render_data.screen->modes.mouse_tracking_protocol >= SGR_PROTOCOL) {
|
||||||
Tab *t = osw->tabs + osw->active_tab;
|
global_state.tracked_drag_in_window = 0;
|
||||||
for (window_idx = 0; window_idx < t->num_windows && t->windows[window_idx].id != w->id; window_idx++);
|
clamp_to_window = true;
|
||||||
debug("sent to child as drag end\n");
|
Tab *t = osw->tabs + osw->active_tab;
|
||||||
handle_button_event(w, button, modifiers, window_idx);
|
for (window_idx = 0; window_idx < t->num_windows && t->windows[window_idx].id != w->id; window_idx++);
|
||||||
clamp_to_window = false;
|
debug("sent to child as drag end\n");
|
||||||
return;
|
handle_button_event(w, button, modifiers, window_idx);
|
||||||
|
clamp_to_window = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user