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/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx
index c450ea9..b36f92b 100644
--- a/vncviewer/DesktopWindow.cxx
+++ b/vncviewer/DesktopWindow.cxx
@@ -694,10 +694,6 @@
         if (dw->fullscreen_active())
           dw->grabKeyboard();
       }
-
-      // We may have gotten our lock keys out of sync with the server
-      // whilst we didn't have focus. Try to sort this out.
-      dw->viewport->pushLEDState();
       break;
 
     case FL_UNFOCUS:
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);
diff --git a/vncviewer/Viewport.h b/vncviewer/Viewport.h
index 7acf348..14ef4ab 100644
--- a/vncviewer/Viewport.h
+++ b/vncviewer/Viewport.h
@@ -52,8 +52,6 @@
 
   // Change client LED state
   void setLEDState(unsigned int state);
-  // Change server LED state
-  void pushLEDState();
 
   void draw(Surface* dst);
 
@@ -83,6 +81,8 @@
   static void handleAltGrTimeout(void *data);
 #endif
 
+  void pushLEDState();
+
   void initContextMenu();
   void popupContextMenu();