aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/VNCServerST.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2018-10-05 17:30:52 +0200
committerPierre Ossman <ossman@cendio.se>2018-10-10 13:07:59 +0200
commitb68434129bc7be45718940b999e0c93f773d1883 (patch)
treef695fcd9f9c4f887472434e41167bb1b83377ada /common/rfb/VNCServerST.cxx
parent6094ced7978358335438310aca84484fbfcdb1fa (diff)
downloadtigervnc-b68434129bc7be45718940b999e0c93f773d1883.tar.gz
tigervnc-b68434129bc7be45718940b999e0c93f773d1883.zip
Encapsulate event handling in VNCServerST
There is some client coordination needed which is better encapsulated inside VNCServerST. This also helps hiding the desktop from the individual clients.
Diffstat (limited to 'common/rfb/VNCServerST.cxx')
-rw-r--r--common/rfb/VNCServerST.cxx46
1 files changed, 46 insertions, 0 deletions
diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx
index 7e36876c..6affe928 100644
--- a/common/rfb/VNCServerST.cxx
+++ b/common/rfb/VNCServerST.cxx
@@ -147,6 +147,10 @@ void VNCServerST::removeSocket(network::Socket* sock) {
std::list<VNCSConnectionST*>::iterator ci;
for (ci = clients.begin(); ci != clients.end(); ci++) {
if ((*ci)->getSock() == sock) {
+ // - Release the cursor if this client owns it
+ if (pointerClient == *ci)
+ pointerClient = NULL;
+
// - Delete the per-Socket resources
delete *ci;
@@ -467,6 +471,48 @@ void VNCServerST::setLEDState(unsigned int state)
}
}
+// Event handlers
+
+void VNCServerST::keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down)
+{
+ lastUserInputTime = time(0);
+
+ // Remap the key if required
+ if (keyRemapper) {
+ rdr::U32 newkey;
+ newkey = keyRemapper->remapKey(keysym);
+ if (newkey != keysym) {
+ slog.debug("Key remapped to 0x%x", newkey);
+ keysym = newkey;
+ }
+ }
+
+ desktop->keyEvent(keysym, keycode, down);
+}
+
+void VNCServerST::pointerEvent(VNCSConnectionST* client,
+ const Point& pos, int buttonMask)
+{
+ lastUserInputTime = time(0);
+
+ // 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))
+ return;
+
+ if (buttonMask)
+ pointerClient = client;
+ else
+ pointerClient = NULL;
+
+ desktop->pointerEvent(pos, buttonMask);
+}
+
+void VNCServerST::clientCutText(const char* str, int len)
+{
+ desktop->clientCutText(str, len);
+}
+
// Other public methods
void VNCServerST::approveConnection(network::Socket* sock, bool accept,