]> source.dussan.org Git - tigervnc.git/commitdiff
More carefully release mouse buttons on close
authorPierre Ossman <ossman@cendio.se>
Tue, 24 Sep 2024 07:03:53 +0000 (09:03 +0200)
committerPierre Ossman <ossman@cendio.se>
Tue, 24 Sep 2024 07:03:53 +0000 (09:03 +0200)
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
common/rfb/VNCServerST.cxx

index 88deff8cc8e96ef36576ecbd78ea46fb8a01e0ee..7dc2a0b8c233eba26bf5e6fa5858562768ab0a4c 100644 (file)
@@ -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;
index 114ff347752548cad9cf97d2ed484055c8f48dec..66b05fae5b0e21e1f1857b0ed239edec388d7016 100644 (file)
@@ -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);