Merge branch 'gitignore' of https://github.com/clbr/tigervnc
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index 4e23dc8..ff27f7b 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -624,16 +624,17 @@
   case FL_FOCUS:
     Fl::disable_im();
 
-    try {
-      flushPendingClipboard();
+    flushPendingClipboard();
 
-      // 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());
-    }
+    // 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();
+
+    // Resend Ctrl/Alt if needed
+    if (menuCtrlKey)
+      handleKeyPress(0x1d, XK_Control_L);
+    if (menuAltKey)
+      handleKeyPress(0x38, XK_Alt_L);
 
     // Yes, we would like some focus please!
     return 1;
@@ -753,7 +754,12 @@
   if (pendingClientCutText) {
     size_t len = strlen(pendingClientCutText);
     vlog.debug("Sending pending clipboard data (%d bytes)", (int)len);
-    cc->writer()->writeClientCutText(pendingClientCutText, len);
+    try {
+      cc->writer()->writeClientCutText(pendingClientCutText, len);
+    } catch (rdr::Exception& e) {
+      vlog.error("%s", e.str());
+      exit_vncviewer(e.str());
+    }
   }
 
   clearPendingClipboard();