Merge branch 'copilot/fix-spurious-mouse-release-event' of https://github.com/kovidgoyal/kitty
This commit is contained in:
@@ -186,6 +186,7 @@ Detailed list of changes
|
|||||||
|
|
||||||
- The :opt:`show_hyperlink_targets` option now allows specifying a keyboard modifier so that target URLs are only shown on hover when the modifier is pressed (:pull:`9741`)
|
- The :opt:`show_hyperlink_targets` option now allows specifying a keyboard modifier so that target URLs are only shown on hover when the modifier is pressed (:pull:`9741`)
|
||||||
|
|
||||||
|
- Fix a spurious mouse button release event being sent when dragging out of an OS window causes focus loss
|
||||||
|
|
||||||
0.46.2 [2026-03-21]
|
0.46.2 [2026-03-21]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|||||||
10
glfw/input.c
vendored
10
glfw/input.c
vendored
@@ -1160,6 +1160,7 @@ GLFWAPI GLFWdragsourcefun glfwSetDragSourceCallback(GLFWwindow* handle, GLFWdrag
|
|||||||
|
|
||||||
void
|
void
|
||||||
_glfwFreeDragSourceData(void) {
|
_glfwFreeDragSourceData(void) {
|
||||||
|
GLFWid drag_window_id = _glfw.drag.window_id;
|
||||||
_glfwPlatformFreeDragSourceData();
|
_glfwPlatformFreeDragSourceData();
|
||||||
if (_glfw.drag.items) {
|
if (_glfw.drag.items) {
|
||||||
for (size_t i = 0; i < _glfw.drag.item_count; i++) {
|
for (size_t i = 0; i < _glfw.drag.item_count; i++) {
|
||||||
@@ -1171,6 +1172,15 @@ _glfwFreeDragSourceData(void) {
|
|||||||
GLFWid iid = _glfw.drag.instance_id;
|
GLFWid iid = _glfw.drag.instance_id;
|
||||||
memset(&_glfw.drag, 0, sizeof(_glfw.drag));
|
memset(&_glfw.drag, 0, sizeof(_glfw.drag));
|
||||||
_glfw.drag.instance_id = iid;
|
_glfw.drag.instance_id = iid;
|
||||||
|
// Send a synthetic left button release to the drag source window if the
|
||||||
|
// button is still marked as pressed. The focus-loss release was suppressed
|
||||||
|
// while the drag was in progress, and on some platforms (Wayland, Cocoa)
|
||||||
|
// the OS never sends a natural button release after the drag ends.
|
||||||
|
if (drag_window_id) {
|
||||||
|
_GLFWwindow* drag_window = _glfwWindowForId(drag_window_id);
|
||||||
|
if (drag_window && drag_window->mouseButtons[GLFW_MOUSE_BUTTON_LEFT] == GLFW_PRESS)
|
||||||
|
_glfwInputMouseClick(drag_window, GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI int
|
GLFWAPI int
|
||||||
|
|||||||
8
glfw/window.c
vendored
8
glfw/window.c
vendored
@@ -63,8 +63,14 @@ void _glfwInputWindowFocus(_GLFWwindow* window, bool focused)
|
|||||||
|
|
||||||
for (int button = 0; button <= GLFW_MOUSE_BUTTON_LAST; button++)
|
for (int button = 0; button <= GLFW_MOUSE_BUTTON_LAST; button++)
|
||||||
{
|
{
|
||||||
if (window->mouseButtons[button] == GLFW_PRESS)
|
if (window->mouseButtons[button] == GLFW_PRESS) {
|
||||||
|
// Skip releasing the left mouse button when a drag is in
|
||||||
|
// progress from this window to avoid spurious release events.
|
||||||
|
// The release will be sent after the drag completes.
|
||||||
|
if (button == GLFW_MOUSE_BUTTON_LEFT && _glfw.drag.window_id == window->id)
|
||||||
|
continue;
|
||||||
_glfwInputMouseClick(window, button, GLFW_RELEASE, 0);
|
_glfwInputMouseClick(window, button, GLFW_RELEASE, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
_glfw.focusedWindowId = window->id;
|
_glfw.focusedWindowId = window->id;
|
||||||
|
|||||||
Reference in New Issue
Block a user