Handle LED state sync entirely in Viewport
Apply workaround for FLTK's bad focus handling so that we can let
Viewport handle LED synchronisation without help from DesktopWindow.
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index 851405c..be38b92 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -604,6 +604,16 @@
case FL_FOCUS:
Fl::disable_im();
+
+ try {
+ // We may have gotten our lock keys out of sync with the server
+ // whilst we didn't have focus. Try to sort this out.
+ pushLEDState();
+ } catch (rdr::Exception& e) {
+ vlog.error("%s", e.str());
+ exit_vncviewer(e.str());
+ }
+
// Yes, we would like some focus please!
return 1;
@@ -1167,8 +1177,13 @@
if (Fl::belowmouse() == this)
window()->cursor(FL_CURSOR_DEFAULT);
+ // FLTK also doesn't switch focus properly for menus
+ handle(FL_UNFOCUS);
+
m = contextMenu->popup();
+ handle(FL_FOCUS);
+
// Back to our proper mouse pointer.
if ((Fl::belowmouse() == this) && cursor)
window()->cursor(cursor, cursorHotspot.x, cursorHotspot.y);