VNC-14 refactor: move force-game-mode notification into SMsgHandler supports* pattern

This commit is contained in:
Matt McClaskey 2026-05-26 10:03:38 +00:00
parent a34b523b56
commit cb72f051f1
No known key found for this signature in database
4 changed files with 20 additions and 12 deletions

View file

@ -43,12 +43,13 @@ void SMsgHandler::setPixelFormat(const PixelFormat& pf)
void SMsgHandler::setEncodings(int nEncodings, const rdr::S32* encodings)
{
bool firstFence, firstContinuousUpdates, firstLEDState,
firstQEMUKeyEvent;
firstQEMUKeyEvent, firstDirectMouse;
firstFence = !cp.supportsFence;
firstContinuousUpdates = !cp.supportsContinuousUpdates;
firstLEDState = !cp.supportsLEDState;
firstQEMUKeyEvent = !cp.supportsQEMUKeyEvent;
firstDirectMouse = !cp.supportsDirectMouse;
cp.setEncodings(nEncodings, encodings);
@ -62,6 +63,12 @@ void SMsgHandler::setEncodings(int nEncodings, const rdr::S32* encodings)
supportsLEDState();
if (cp.supportsQEMUKeyEvent && firstQEMUKeyEvent)
supportsQEMUKeyEvent();
if (cp.supportsDirectMouse && firstDirectMouse)
supportsDirectMouse();
}
void SMsgHandler::supportsDirectMouse()
{
}
void SMsgHandler::handleClipboardAnnounceBinary(const unsigned, const char mimes[][32])

View file

@ -99,6 +99,10 @@ namespace rfb {
// handler will send a pseudo-rect back, signalling server support.
virtual void supportsQEMUKeyEvent();
// supportsDirectMouse() is called the first time we detect that the
// client supports the direct mouse extension
virtual void supportsDirectMouse();
virtual void udpUpgrade(const char *resp) = 0;
virtual void udpDowngrade(const bool) = 0;

View file

@ -71,7 +71,7 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s, con
needsPermCheck(false), pointerEventTime(0),
clientHasCursor(false),
accessRights(AccessDefault), startTime(time(nullptr)), frameTracking(false),
udpFramesSinceFull(0), complainedAboutNoViewRights(false), gameModeNotified(false),
udpFramesSinceFull(0), complainedAboutNoViewRights(false),
clientUsername("username_unavailable")
{
setStreams(&sock->inStream(), &sock->outStream());
@ -1005,15 +1005,6 @@ void VNCSConnectionST::framebufferUpdateRequest(const Rect& r,bool incremental)
if (!(accessRights & AccessView)) return;
// On the first full update request the client is fully connected and has
// sent SetEncodings. If the server is configured to force game mode and the
// client supports direct mouse, send the notification exactly once.
if (!incremental && !gameModeNotified && rfb::Server::forceGameMode &&
cp.supportsDirectMouse) {
writer()->writeForceGameMode();
gameModeNotified = true;
}
SConnection::framebufferUpdateRequest(r, incremental);
// Check that the client isn't sending crappy requests
@ -1209,6 +1200,12 @@ void VNCSConnectionST::supportsLEDState()
writer()->writeLEDState();
}
void VNCSConnectionST::supportsDirectMouse()
{
if (rfb::Server::forceGameMode)
writer()->writeForceGameMode();
}
bool VNCSConnectionST::handleTimeout(Timer* t)
{

View file

@ -265,6 +265,7 @@ namespace rfb {
virtual void supportsFence();
virtual void supportsContinuousUpdates();
virtual void supportsLEDState();
void supportsDirectMouse() override;
bool canChangeKasmSettings() const override {
return (accessRights & (AccessPtrEvents | AccessKeyEvents)) ==
@ -366,7 +367,6 @@ namespace rfb {
char unixRelaySubscriptions[MAX_UNIX_RELAYS][MAX_UNIX_RELAY_NAME_LEN] = {};
bool complainedAboutNoViewRights;
bool gameModeNotified;
std::string clientUsername;
bool pendingClientRefresh{false};
};