diff options
author | Rahul Kale <Rahul.Kale@barco.com> | 2017-07-13 00:36:02 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2017-08-28 13:54:30 +0200 |
commit | c719e4a0c9e1e3e5b7d22aa42cdaedda3cb06803 (patch) | |
tree | d8ea6cc28e04a67826cae98381cfec13c09f72a2 /win | |
parent | 5b7ff372678747d0538cf688f5aac01b5a3b1518 (diff) | |
download | tigervnc-c719e4a0c9e1e3e5b7d22aa42cdaedda3cb06803.tar.gz tigervnc-c719e4a0c9e1e3e5b7d22aa42cdaedda3cb06803.zip |
rfb_win32: Add support for LED state notifications
LED support added using Windows GetKeyState() API call.
The state is polled for change in CapsLock/NumLock/ScrollLock
status in the same code block where chages to Cursor shape is polled.
Signed-off-by: Rahul Kale <Rahul.Kale@barco.com>
Signed-off-by: Peter Korsgaard <peter.korsgaard@barco.com>
Diffstat (limited to 'win')
-rw-r--r-- | win/rfb_win32/SDisplay.cxx | 29 | ||||
-rw-r--r-- | win/rfb_win32/SDisplay.h | 3 |
2 files changed, 31 insertions, 1 deletions
diff --git a/win/rfb_win32/SDisplay.cxx b/win/rfb_win32/SDisplay.cxx index ac64e3ef..2696f5dc 100644 --- a/win/rfb_win32/SDisplay.cxx +++ b/win/rfb_win32/SDisplay.cxx @@ -30,6 +30,7 @@ #include <rfb_win32/SDisplayCoreWMHooks.h> #include <rfb/Exception.h> #include <rfb/LogWriter.h> +#include <rfb/ledStates.h> using namespace rdr; @@ -65,7 +66,7 @@ SDisplay::SDisplay() : server(0), pb(0), device(0), core(0), ptr(0), kbd(0), clipboard(0), inputs(0), monitor(0), cleanDesktop(0), cursor(0), - statusLocation(0) + statusLocation(0), ledState(0) { updateEvent.h = CreateEvent(0, TRUE, FALSE, 0); } @@ -196,6 +197,10 @@ void SDisplay::startCore() { cleanDesktop->disableEffects(); isWallpaperRemoved = removeWallpaper; areEffectsDisabled = disableEffects; + + checkLedState(); + if (server) + server->setLEDState(ledState); } void SDisplay::stopCore() { @@ -283,6 +288,24 @@ void SDisplay::keyEvent(rdr::U32 key, bool down) { kbd->keyEvent(key, down); } +bool SDisplay::checkLedState() { + unsigned state = 0; + + if (GetKeyState(VK_SCROLL) & 0x0001) + state |= ledScrollLock; + if (GetKeyState(VK_NUMLOCK) & 0x0001) + state |= ledNumLock; + if (GetKeyState(VK_CAPITAL) & 0x0001) + state |= ledCapsLock; + + if (ledState != state) { + ledState = state; + return true; + } + + return false; +} + void SDisplay::clientCutText(const char* text, int len) { CharArray clip_sz(len+1); memcpy(clip_sz.buf, text, len); @@ -384,6 +407,10 @@ SDisplay::processEvent(HANDLE event) { // Flush any changes to the server flushChangeTracker(); + + // Forward current LED state to the server + if (checkLedState()) + server->setLEDState(ledState); } return; } diff --git a/win/rfb_win32/SDisplay.h b/win/rfb_win32/SDisplay.h index b0217822..e43e3021 100644 --- a/win/rfb_win32/SDisplay.h +++ b/win/rfb_win32/SDisplay.h @@ -106,6 +106,7 @@ namespace rfb { void restartCore(); void recreatePixelBuffer(bool force=false); bool flushChangeTracker(); // true if flushed, false if empty + bool checkLedState(); VNCServer* server; @@ -151,6 +152,8 @@ namespace rfb { // -=- Where to write the active/inactive indicator to bool* statusLocation; + + unsigned ledState; }; } |