aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2024-09-24 09:03:53 +0200
committerLinn Mattsson <linma@cendio.se>2024-10-22 12:41:34 +0200
commit8d2393c666b0c069c2e367c63f3d9fee981f3efe (patch)
treee0569cbbba9cb65c47f7081f8cad9d9c703ba8c1
parentc6c22d00ad0eba438506eeb2a73ebab9feac6b9d (diff)
downloadtigervnc-8d2393c666b0c069c2e367c63f3d9fee981f3efe.tar.gz
tigervnc-8d2393c666b0c069c2e367c63f3d9fee981f3efe.zip
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. (cherry picked from commit 704f9724d8af58314c4fafc8930666bb2be46722)
-rw-r--r--common/rfb/VNCSConnectionST.cxx3
-rw-r--r--common/rfb/VNCServerST.cxx5
2 files changed, 4 insertions, 4 deletions
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index 50a968d1..0a533e67 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 38318120..35a83845 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 = NULL;
+ }
if (clipboardClient == *ci)
handleClipboardAnnounce(*ci, false);
clipboardRequestors.remove(*ci);