Send synthetic left button release after drag ends to fix stale mouse state
Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com> Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/e3cf07a9-b3c0-4786-b264-a83b85f098ac
This commit is contained in:
parent
215bbf68de
commit
efe319f755
1 changed files with 10 additions and 0 deletions
10
glfw/input.c
vendored
10
glfw/input.c
vendored
|
|
@ -1160,6 +1160,7 @@ GLFWAPI GLFWdragsourcefun glfwSetDragSourceCallback(GLFWwindow* handle, GLFWdrag
|
|||
|
||||
void
|
||||
_glfwFreeDragSourceData(void) {
|
||||
GLFWid drag_window_id = _glfw.drag.window_id;
|
||||
_glfwPlatformFreeDragSourceData();
|
||||
if (_glfw.drag.items) {
|
||||
for (size_t i = 0; i < _glfw.drag.item_count; i++) {
|
||||
|
|
@ -1171,6 +1172,15 @@ _glfwFreeDragSourceData(void) {
|
|||
GLFWid iid = _glfw.drag.instance_id;
|
||||
memset(&_glfw.drag, 0, sizeof(_glfw.drag));
|
||||
_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
|
||||
|
|
|
|||
Loading…
Reference in a new issue