Skip to content

Commit

Permalink
Merge pull request #1718 from MikeLooijmans/server-mousebuttonowner-t…
Browse files Browse the repository at this point in the history
…imeout

VNCServerST: Add a timeout to pointer button ownership
  • Loading branch information
LMattsson authored Jan 25, 2024
2 parents fe4b014 + 71c83b4 commit 6050b15
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions common/rfb/VNCServerST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ VNCServerST::VNCServerST(const char* name_, SDesktop* desktop_)
: blHosts(&blacklist), desktop(desktop_), desktopStarted(false),
blockCounter(0), pb(0), ledState(ledUnknown),
name(name_), pointerClient(0), clipboardClient(0),
pointerClientTime(0),
comparer(0), cursor(new Cursor(0, 0, Point(), NULL)),
renderedCursorInvalid(false),
keyRemapper(&KeyRemapper::defInstance),
Expand Down Expand Up @@ -484,14 +485,17 @@ void VNCServerST::keyEvent(uint32_t keysym, uint32_t keycode, bool down)
void VNCServerST::pointerEvent(VNCSConnectionST* client,
const Point& pos, int buttonMask)
{
time_t now = time(0);
if (rfb::Server::maxIdleTime)
idleTimer.start(secsToMillis(rfb::Server::maxIdleTime));

// Let one client own the cursor whilst buttons are pressed in order
// to provide a bit more sane user experience
if ((pointerClient != NULL) && (pointerClient != client))
// to provide a bit more sane user experience. But limit the time to prevent
// locking out all others when e.g. the network is down.
if ((pointerClient != NULL) && (pointerClient != client) && ((now - pointerClientTime) < 3))
return;

pointerClientTime = now;
if (buttonMask)
pointerClient = client;
else
Expand Down
2 changes: 2 additions & 0 deletions common/rfb/VNCServerST.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ namespace rfb {
std::list<VNCSConnectionST*> clipboardRequestors;
std::list<network::Socket*> closingSockets;

time_t pointerClientTime;

ComparingUpdateTracker* comparer;

Point cursorPos;
Expand Down

0 comments on commit 6050b15

Please sign in to comment.