From 609a9c89e9e0b7869c6537ee882757ca6932efd5 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 7 Jun 2018 09:16:02 +0200 Subject: [PATCH] Properly sync LED state on connect We should start by getting the remote end in sync with the actual keyboard state. This would work randomly before depending on if we got the first LED state message before or after we got focus. --- vncviewer/Viewport.cxx | 10 ++++++++++ vncviewer/Viewport.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index 4a44f401..4e23dc8c 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -118,6 +118,7 @@ Viewport::Viewport(int w, int h, const rfb::PixelFormat& serverPF, CConn* cc_) #ifdef WIN32 altGrArmed(false), #endif + firstLEDState(true), pendingServerCutText(NULL), pendingClientCutText(NULL), menuCtrlKey(false), menuAltKey(false), cursor(NULL) { @@ -321,6 +322,15 @@ void Viewport::setLEDState(unsigned int state) { vlog.debug("Got server LED state: 0x%08x", state); + // The first message is just considered to be the server announcing + // support for this extension, so start by pushing our state to the + // remote end to get things in sync + if (firstLEDState) { + firstLEDState = false; + pushLEDState(); + return; + } + if (!hasFocus()) return; diff --git a/vncviewer/Viewport.h b/vncviewer/Viewport.h index d9d73a8e..be2192b8 100644 --- a/vncviewer/Viewport.h +++ b/vncviewer/Viewport.h @@ -112,6 +112,8 @@ private: unsigned int altGrCtrlTime; #endif + bool firstLEDState; + const char* pendingServerCutText; const char* pendingClientCutText; -- 2.39.5