Better to check the actual list of supported encodings directly.
Makes parts more readable, and no risk of getting out of sync.
ClientParams::ClientParams()
: majorVersion(0), minorVersion(0),
- useCopyRect(false),
- supportsLocalCursor(false), supportsLocalXCursor(false),
- supportsLocalCursorWithAlpha(false),
- supportsDesktopResize(false), supportsExtendedDesktopSize(false),
- supportsDesktopRename(false), supportsLastRect(false),
- supportsLEDState(false), supportsQEMUKeyEvent(false),
- supportsSetDesktopSize(false), supportsFence(false),
- supportsContinuousUpdates(false),
compressLevel(2), qualityLevel(-1), fineQualityLevel(-1),
subsampling(subsampleUndefined),
width_(0), height_(0), name_(0),
void ClientParams::setEncodings(int nEncodings, const rdr::S32* encodings)
{
- useCopyRect = false;
- supportsLocalCursor = false;
- supportsLocalCursorWithAlpha = false;
- supportsDesktopResize = false;
- supportsExtendedDesktopSize = false;
- supportsLocalXCursor = false;
- supportsLastRect = false;
- supportsQEMUKeyEvent = false;
compressLevel = -1;
qualityLevel = -1;
fineQualityLevel = -1;
for (int i = nEncodings-1; i >= 0; i--) {
switch (encodings[i]) {
- case encodingCopyRect:
- useCopyRect = true;
- break;
- case pseudoEncodingCursor:
- supportsLocalCursor = true;
- break;
- case pseudoEncodingXCursor:
- supportsLocalXCursor = true;
- break;
- case pseudoEncodingCursorWithAlpha:
- supportsLocalCursorWithAlpha = true;
- break;
- case pseudoEncodingDesktopSize:
- supportsDesktopResize = true;
- break;
- case pseudoEncodingExtendedDesktopSize:
- supportsExtendedDesktopSize = true;
- break;
- case pseudoEncodingDesktopName:
- supportsDesktopRename = true;
- break;
- case pseudoEncodingLastRect:
- supportsLastRect = true;
- break;
- case pseudoEncodingLEDState:
- supportsLEDState = true;
- break;
- case pseudoEncodingQEMUKeyEvent:
- supportsQEMUKeyEvent = true;
- break;
- case pseudoEncodingFence:
- supportsFence = true;
- break;
- case pseudoEncodingContinuousUpdates:
- supportsContinuousUpdates = true;
- break;
case pseudoEncodingSubsamp1X:
subsampling = subsampleNone;
break;
encodings[i] <= pseudoEncodingFineQualityLevel100)
fineQualityLevel = encodings[i] - pseudoEncodingFineQualityLevel0;
- if (encodings[i] > 0)
- encodings_.insert(encodings[i]);
+ encodings_.insert(encodings[i]);
}
}
{
ledState_ = state;
}
+
+bool ClientParams::supportsLocalCursor() const
+{
+ if (supportsEncoding(pseudoEncodingCursorWithAlpha))
+ return true;
+ if (supportsEncoding(pseudoEncodingCursor))
+ return true;
+ if (supportsEncoding(pseudoEncodingXCursor))
+ return true;
+ return false;
+}
+
+bool ClientParams::supportsLEDState() const
+{
+ if (supportsEncoding(pseudoEncodingLEDState))
+ return true;
+ return false;
+}
+
+bool ClientParams::supportsFence() const
+{
+ if (supportsEncoding(pseudoEncodingFence))
+ return true;
+ return false;
+}
+
+bool ClientParams::supportsContinuousUpdates() const
+{
+ if (supportsEncoding(pseudoEncodingContinuousUpdates))
+ return true;
+ return false;
+}
unsigned int ledState() { return ledState_; }
void setLEDState(unsigned int state);
- bool useCopyRect;
-
- bool supportsLocalCursor;
- bool supportsLocalXCursor;
- bool supportsLocalCursorWithAlpha;
- bool supportsDesktopResize;
- bool supportsExtendedDesktopSize;
- bool supportsDesktopRename;
- bool supportsLastRect;
- bool supportsLEDState;
- bool supportsQEMUKeyEvent;
-
- bool supportsSetDesktopSize;
- bool supportsFence;
- bool supportsContinuousUpdates;
+ // Wrappers to check for functionality rather than specific
+ // encodings
+ bool supportsLocalCursor() const;
+ bool supportsLEDState() const;
+ bool supportsFence() const;
+ bool supportsContinuousUpdates() const;
int compressLevel;
int qualityLevel;
changed = changed_;
- if (!conn->client.useCopyRect)
+ if (!conn->client.supportsEncoding(encodingCopyRect))
changed.assign_union(copied);
/*
changed.assign_subtract(renderedCursor->getEffectiveRect());
}
- if (conn->client.supportsLastRect)
+ if (conn->client.supportsEncoding(pseudoEncodingLastRect))
nRects = 0xFFFF;
else {
nRects = copied.numRects();
conn->writer()->writeFramebufferUpdateStart(nRects);
- if (conn->client.useCopyRect)
+ if (conn->client.supportsEncoding(encodingCopyRect))
writeCopyRects(copied, copyDelta);
/*
* We start by searching for solid rects, which are then removed
* from the changed region.
*/
- if (conn->client.supportsLastRect)
+ if (conn->client.supportsEncoding(pseudoEncodingLastRect))
writeSolidRects(&changed, pb);
writeRects(changed, pb);
#include <rfb/Exception.h>
#include <rfb/SMsgHandler.h>
#include <rfb/ScreenSet.h>
+#include <rfb/encodings.h>
using namespace rfb;
bool firstFence, firstContinuousUpdates, firstLEDState,
firstQEMUKeyEvent;
- firstFence = !client.supportsFence;
- firstContinuousUpdates = !client.supportsContinuousUpdates;
- firstLEDState = !client.supportsLEDState;
- firstQEMUKeyEvent = !client.supportsQEMUKeyEvent;
+ firstFence = !client.supportsFence();
+ firstContinuousUpdates = !client.supportsContinuousUpdates();
+ firstLEDState = !client.supportsLEDState();
+ firstQEMUKeyEvent = !client.supportsEncoding(pseudoEncodingQEMUKeyEvent);
client.setEncodings(nEncodings, encodings);
supportsLocalCursor();
- if (client.supportsFence && firstFence)
+ if (client.supportsFence() && firstFence)
supportsFence();
- if (client.supportsContinuousUpdates && firstContinuousUpdates)
+ if (client.supportsContinuousUpdates() && firstContinuousUpdates)
supportsContinuousUpdates();
- if (client.supportsLEDState && firstLEDState)
+ if (client.supportsLEDState() && firstLEDState)
supportsLEDState();
- if (client.supportsQEMUKeyEvent && firstQEMUKeyEvent)
+ if (client.supportsEncoding(pseudoEncodingQEMUKeyEvent) && firstQEMUKeyEvent)
supportsQEMUKeyEvent();
}
void SMsgWriter::writeFence(rdr::U32 flags, unsigned len, const char data[])
{
- if (!client->supportsFence)
+ if (!client->supportsEncoding(pseudoEncodingFence))
throw Exception("Client does not support fences");
if (len > 64)
throw Exception("Too large fence payload");
void SMsgWriter::writeEndOfContinuousUpdates()
{
- if (!client->supportsContinuousUpdates)
+ if (!client->supportsEncoding(pseudoEncodingContinuousUpdates))
throw Exception("Client does not support continuous updates");
startMsg(msgTypeEndOfContinuousUpdates);
}
bool SMsgWriter::writeSetDesktopSize() {
- if (!client->supportsDesktopResize)
+ if (!client->supportsEncoding(pseudoEncodingDesktopSize))
return false;
needSetDesktopSize = true;
}
bool SMsgWriter::writeExtendedDesktopSize() {
- if (!client->supportsExtendedDesktopSize)
+ if (!client->supportsEncoding(pseudoEncodingExtendedDesktopSize))
return false;
needExtendedDesktopSize = true;
const ScreenSet& layout) {
ExtendedDesktopSizeMsg msg;
- if (!client->supportsExtendedDesktopSize)
+ if (!client->supportsEncoding(pseudoEncodingExtendedDesktopSize))
return false;
msg.reason = reason;
}
bool SMsgWriter::writeSetDesktopName() {
- if (!client->supportsDesktopRename)
+ if (!client->supportsEncoding(pseudoEncodingDesktopName))
return false;
needSetDesktopName = true;
bool SMsgWriter::writeSetCursor()
{
- if (!client->supportsLocalCursor)
+ if (!client->supportsEncoding(pseudoEncodingCursor))
return false;
needSetCursor = true;
bool SMsgWriter::writeSetXCursor()
{
- if (!client->supportsLocalXCursor)
+ if (!client->supportsEncoding(pseudoEncodingXCursor))
return false;
needSetXCursor = true;
bool SMsgWriter::writeSetCursorWithAlpha()
{
- if (!client->supportsLocalCursorWithAlpha)
+ if (!client->supportsEncoding(pseudoEncodingCursorWithAlpha))
return false;
needSetCursorWithAlpha = true;
bool SMsgWriter::writeLEDState()
{
- if (!client->supportsLEDState)
+ if (!client->supportsEncoding(pseudoEncodingLEDState))
return false;
if (client->ledState() == ledUnknown)
return false;
bool SMsgWriter::writeQEMUKeyEvent()
{
- if (!client->supportsQEMUKeyEvent)
+ if (!client->supportsEncoding(pseudoEncodingQEMUKeyEvent))
return false;
needQEMUKeyEvent = true;
void SMsgWriter::writeSetDesktopSizeRect(int width, int height)
{
- if (!client->supportsDesktopResize)
+ if (!client->supportsEncoding(pseudoEncodingDesktopSize))
throw Exception("Client does not support desktop resize");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeSetDesktopSizeRect: nRects out of sync");
{
ScreenSet::const_iterator si;
- if (!client->supportsExtendedDesktopSize)
+ if (!client->supportsEncoding(pseudoEncodingExtendedDesktopSize))
throw Exception("Client does not support extended desktop resize");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeExtendedDesktopSizeRect: nRects out of sync");
void SMsgWriter::writeSetDesktopNameRect(const char *name)
{
- if (!client->supportsDesktopRename)
+ if (!client->supportsEncoding(pseudoEncodingDesktopName))
throw Exception("Client does not support desktop rename");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeSetDesktopNameRect: nRects out of sync");
int hotspotX, int hotspotY,
const void* data, const void* mask)
{
- if (!client->supportsLocalCursor)
+ if (!client->supportsEncoding(pseudoEncodingCursor))
throw Exception("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeSetCursorRect: nRects out of sync");
int hotspotX, int hotspotY,
const void* data, const void* mask)
{
- if (!client->supportsLocalXCursor)
+ if (!client->supportsEncoding(pseudoEncodingXCursor))
throw Exception("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeSetXCursorRect: nRects out of sync");
int hotspotX, int hotspotY,
const rdr::U8* data)
{
- if (!client->supportsLocalCursorWithAlpha)
+ if (!client->supportsEncoding(pseudoEncodingCursorWithAlpha))
throw Exception("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeSetCursorWithAlphaRect: nRects out of sync");
void SMsgWriter::writeLEDStateRect(rdr::U8 state)
{
- if (!client->supportsLEDState)
+ if (!client->supportsEncoding(pseudoEncodingLEDState))
throw Exception("Client does not support LED state updates");
if (client->ledState() == ledUnknown)
throw Exception("Server does not support LED state updates");
void SMsgWriter::writeQEMUKeyEventRect()
{
- if (!client->supportsQEMUKeyEvent)
+ if (!client->supportsEncoding(pseudoEncodingQEMUKeyEvent))
throw Exception("Client does not support QEMU extended key events");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeQEMUKeyEventRect: nRects out of sync");
if (state() != RFBSTATE_NORMAL)
return false;
- if (!client.supportsLocalCursorWithAlpha &&
- !client.supportsLocalCursor && !client.supportsLocalXCursor)
+ if (!client.supportsLocalCursor())
return true;
if (!server->cursorPos.equals(pointerEventPos) &&
(time(0) - pointerEventTime) > 0)
// Lock key heuristics
// (only for clients that do not support the LED state extension)
- if (!client.supportsLEDState) {
+ if (!client.supportsLEDState()) {
// Always ignore ScrollLock as we don't have a heuristic
// for that
if (keysym == XK_Scroll_Lock) {
{
Rect rect;
- if (!client.supportsFence || !client.supportsContinuousUpdates)
+ if (!client.supportsFence() || !client.supportsContinuousUpdates())
throw Exception("Client tried to enable continuous updates when not allowed");
continuousUpdates = enable;
}
// supportsLocalCursor() is called whenever the status of
-// client.supportsLocalCursor has changed. If the client does now support local
+// client.supportsLocalCursor() has changed. If the client does now support local
// cursor, we make sure that the old server-side rendered cursor is cleaned up
// and the cursor is sent to the client.
{
// We refuse to use continuous updates if we cannot monitor the buffer
// usage using fences.
- if (!client.supportsFence)
+ if (!client.supportsFence())
return;
writer()->writeEndOfContinuousUpdates();
{
char type;
- if (!client.supportsFence)
+ if (!client.supportsFence())
return;
congestion.updatePosition(sock->outStream().length());
if (sock->outStream().bufferUsage() > 0)
return true;
- if (!client.supportsFence)
+ if (!client.supportsFence())
return false;
congestion.updatePosition(sock->outStream().length());