Add client support for LED state sync
diff --git a/common/rfb/CMsgHandler.cxx b/common/rfb/CMsgHandler.cxx
index 11c979a..74c7bf9 100644
--- a/common/rfb/CMsgHandler.cxx
+++ b/common/rfb/CMsgHandler.cxx
@@ -82,3 +82,8 @@
void CMsgHandler::framebufferUpdateEnd()
{
}
+
+void CMsgHandler::setLEDState(unsigned int state)
+{
+ cp.setLEDState(state);
+}
diff --git a/common/rfb/CMsgHandler.h b/common/rfb/CMsgHandler.h
index 993276e..ef2cda2 100644
--- a/common/rfb/CMsgHandler.h
+++ b/common/rfb/CMsgHandler.h
@@ -69,6 +69,8 @@
virtual void bell() = 0;
virtual void serverCutText(const char* str, rdr::U32 len) = 0;
+ virtual void setLEDState(unsigned int state);
+
ConnParams cp;
};
}
diff --git a/common/rfb/CMsgReader.cxx b/common/rfb/CMsgReader.cxx
index 9abe3f2..0aaf71f 100644
--- a/common/rfb/CMsgReader.cxx
+++ b/common/rfb/CMsgReader.cxx
@@ -109,6 +109,9 @@
case pseudoEncodingExtendedDesktopSize:
readExtendedDesktopSize(x, y, w, h);
break;
+ case pseudoEncodingLEDState:
+ readLEDState();
+ break;
default:
readRect(Rect(x, y, x+w, y+h), encoding);
break;
@@ -382,3 +385,12 @@
handler->setExtendedDesktopSize(x, y, w, h, layout);
}
+
+void CMsgReader::readLEDState()
+{
+ rdr::U8 state;
+
+ state = is->readU8();
+
+ handler->setLEDState(state);
+}
diff --git a/common/rfb/CMsgReader.h b/common/rfb/CMsgReader.h
index 7b52033..9963827 100644
--- a/common/rfb/CMsgReader.h
+++ b/common/rfb/CMsgReader.h
@@ -65,6 +65,7 @@
void readSetCursorWithAlpha(int width, int height, const Point& hotspot);
void readSetDesktopName(int x, int y, int w, int h);
void readExtendedDesktopSize(int x, int y, int w, int h);
+ void readLEDState();
CMsgHandler* handler;
rdr::InStream* is;
diff --git a/common/rfb/CMsgWriter.cxx b/common/rfb/CMsgWriter.cxx
index fa78404..7a89a93 100644
--- a/common/rfb/CMsgWriter.cxx
+++ b/common/rfb/CMsgWriter.cxx
@@ -82,6 +82,8 @@
encodings[nEncodings++] = pseudoEncodingExtendedDesktopSize;
if (cp->supportsDesktopRename)
encodings[nEncodings++] = pseudoEncodingDesktopName;
+ if (cp->supportsLEDState)
+ encodings[nEncodings++] = pseudoEncodingLEDState;
encodings[nEncodings++] = pseudoEncodingLastRect;
encodings[nEncodings++] = pseudoEncodingContinuousUpdates;
diff --git a/common/rfb/ConnParams.cxx b/common/rfb/ConnParams.cxx
index 9ee1d9c..f0b6932 100644
--- a/common/rfb/ConnParams.cxx
+++ b/common/rfb/ConnParams.cxx
@@ -22,6 +22,7 @@
#include <rdr/OutStream.h>
#include <rfb/Exception.h>
#include <rfb/encodings.h>
+#include <rfb/ledStates.h>
#include <rfb/ConnParams.h>
#include <rfb/util.h>
@@ -34,10 +35,11 @@
supportsLocalCursorWithAlpha(false),
supportsDesktopResize(false), supportsExtendedDesktopSize(false),
supportsDesktopRename(false), supportsLastRect(false),
- supportsSetDesktopSize(false), supportsFence(false),
- supportsContinuousUpdates(false),
+ supportsLEDState(false), supportsSetDesktopSize(false),
+ supportsFence(false), supportsContinuousUpdates(false),
compressLevel(2), qualityLevel(-1), fineQualityLevel(-1),
- subsampling(subsampleUndefined), name_(0), verStrPos(0)
+ subsampling(subsampleUndefined), name_(0), verStrPos(0),
+ ledState_(ledUnknown)
{
setName("");
cursor_ = new Cursor(0, 0, Point(), NULL);
@@ -141,6 +143,9 @@
case pseudoEncodingLastRect:
supportsLastRect = true;
break;
+ case pseudoEncodingLEDState:
+ supportsLEDState = true;
+ break;
case pseudoEncodingFence:
supportsFence = true;
break;
@@ -183,3 +188,8 @@
encodings_.insert(encodings[i]);
}
}
+
+void ConnParams::setLEDState(unsigned int state)
+{
+ ledState_ = state;
+}
diff --git a/common/rfb/ConnParams.h b/common/rfb/ConnParams.h
index 5e53893..d99d142 100644
--- a/common/rfb/ConnParams.h
+++ b/common/rfb/ConnParams.h
@@ -84,6 +84,9 @@
void setEncodings(int nEncodings, const rdr::S32* encodings);
+ unsigned int ledState() { return ledState_; }
+ void setLEDState(unsigned int state);
+
bool useCopyRect;
bool supportsLocalCursor;
@@ -93,6 +96,7 @@
bool supportsExtendedDesktopSize;
bool supportsDesktopRename;
bool supportsLastRect;
+ bool supportsLEDState;
bool supportsSetDesktopSize;
bool supportsFence;
@@ -111,6 +115,7 @@
std::set<rdr::S32> encodings_;
char verStr[13];
int verStrPos;
+ unsigned int ledState_;
};
}
#endif
diff --git a/common/rfb/encodings.h b/common/rfb/encodings.h
index a65d863..adeecaa 100644
--- a/common/rfb/encodings.h
+++ b/common/rfb/encodings.h
@@ -34,6 +34,7 @@
const int pseudoEncodingXCursor = -240;
const int pseudoEncodingCursor = -239;
const int pseudoEncodingDesktopSize = -223;
+ const int pseudoEncodingLEDState = -261;
const int pseudoEncodingExtendedDesktopSize = -308;
const int pseudoEncodingDesktopName = -307;
const int pseudoEncodingFence = -312;
diff --git a/common/rfb/ledStates.h b/common/rfb/ledStates.h
new file mode 100644
index 0000000..ef14682
--- /dev/null
+++ b/common/rfb/ledStates.h
@@ -0,0 +1,30 @@
+/* Copyright 2016 Pierre Ossman for Cendio AB
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+#ifndef __RFB_LEDSTATES_H__
+#define __RFB_LEDSTATES_H__
+
+namespace rfb {
+
+ const unsigned int ledScrollLock = 1 << 0;
+ const unsigned int ledNumLock = 1 << 1;
+ const unsigned int ledCapsLock = 1 << 2;
+
+ const unsigned int ledUnknown = (unsigned int)-1;
+}
+
+#endif