Skip to content

Commit

Permalink
More carefully release mouse buttons on close
Browse files Browse the repository at this point in the history
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 986280b.
  • Loading branch information
CendioOssman committed Sep 24, 2024
1 parent 43ce674 commit 704f972
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 0 additions & 3 deletions common/rfb/VNCSConnectionST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion common/rfb/VNCServerST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 704f972

Please sign in to comment.