From 704f9724d8af58314c4fafc8930666bb2be46722 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 24 Sep 2024 09:03:53 +0200 Subject: [PATCH] More carefully release mouse buttons on close Only the client that currently has buttons pressed should actually send a release event as the client might not be currently in control of the pointer state. This is most clearly seen in a client that hasn't event authenticated properly yet. Approximate this from the server by using the last known server cursor position. It should hopefully not differ much from the last client provided position. Follow-up to 986280b382d57ef4f68d2d4afb13b26772e5acb0. --- common/rfb/VNCSConnectionST.cxx | 3 --- common/rfb/VNCServerST.cxx | 5 ++++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx index 88deff8c..7dc2a0b8 100644 --- a/common/rfb/VNCSConnectionST.cxx +++ b/common/rfb/VNCSConnectionST.cxx @@ -83,9 +83,6 @@ VNCSConnectionST::~VNCSConnectionST() vlog.info("closing %s: %s", peerEndpoint.c_str(), closeReason.c_str()); - // Release any mouse buttons - server->pointerEvent(this, server->getCursorPos(), 0); - // Release any keys the client still had pressed while (!pressedKeys.empty()) { uint32_t keysym, keycode; diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx index 114ff347..66b05fae 100644 --- a/common/rfb/VNCServerST.cxx +++ b/common/rfb/VNCServerST.cxx @@ -176,8 +176,11 @@ void VNCServerST::removeSocket(network::Socket* sock) { for (ci = clients.begin(); ci != clients.end(); ci++) { if ((*ci)->getSock() == sock) { // - Remove any references to it - if (pointerClient == *ci) + if (pointerClient == *ci) { + // Release the mouse buttons the client have pressed + desktop->pointerEvent(cursorPos, 0); pointerClient = nullptr; + } if (clipboardClient == *ci) handleClipboardAnnounce(*ci, false); clipboardRequestors.remove(*ci); -- 2.39.5