Revision: 4444
          http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4444&view=rev
Author:   ossman_
Date:     2011-05-24 12:47:12 +0000 (Tue, 24 May 2011)

Log Message:
-----------
Handling a full range of keys for the menu key is not as trivial in FLTK as
with raw X11, so do what the Windows client did and restrict the available
keys to just the function keys.

Modified Paths:
--------------
    trunk/vncviewer/OptionsDialog.cxx
    trunk/vncviewer/OptionsDialog.h
    trunk/vncviewer/Viewport.cxx
    trunk/vncviewer/Viewport.h
    trunk/vncviewer/fltk_layout.h

Modified: trunk/vncviewer/OptionsDialog.cxx
===================================================================
--- trunk/vncviewer/OptionsDialog.cxx   2011-05-24 11:33:43 UTC (rev 4443)
+++ trunk/vncviewer/OptionsDialog.cxx   2011-05-24 12:47:12 UTC (rev 4444)
@@ -253,11 +253,22 @@
 #endif
 
   /* Input */
+  const char *menuKeyBuf;
+
   viewOnlyCheckbox->value(viewOnly);
   acceptClipboardCheckbox->value(acceptClipboard);
   sendClipboardCheckbox->value(sendClipboard);
   sendPrimaryCheckbox->value(sendPrimary);
 
+  menuKeyChoice->value(0);
+
+  menuKeyBuf = menuKey;
+  if (menuKeyBuf[0] == 'F') {
+    int num = atoi(menuKeyBuf+1);
+    if ((num >= 1) && (num <= 12))
+      menuKeyChoice->value(num);
+  }
+
   /* Misc. */
   sharedCheckbox->value(shared);
   fullScreenCheckbox->value(fullScreen);
@@ -342,6 +353,14 @@
   sendClipboard.setParam(sendClipboardCheckbox->value());
   sendPrimary.setParam(sendPrimaryCheckbox->value());
 
+  if (menuKeyChoice->value() == 0)
+    menuKey.setParam("");
+  else {
+    char buf[16];
+    sprintf(buf, "F%d", menuKeyChoice->value());
+    menuKey.setParam(buf);
+  }
+
   /* Misc. */
   shared.setParam(sharedCheckbox->value());
   fullScreen.setParam(fullScreenCheckbox->value());
@@ -664,6 +683,17 @@
                                                      _("Send primary selection 
and cut buffer as clipboard")));
   ty += CHECK_HEIGHT + TIGHT_MARGIN;
 
+  menuKeyChoice = new Fl_Choice(LBLLEFT(tx, ty, 150, CHOICE_HEIGHT, _("Menu 
key")));
+
+  menuKeyChoice->add(_("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER);
+  for (int i = 1;i <= 12;i++) {
+    char buf[16];
+    sprintf(buf, "F%d", i);
+    menuKeyChoice->add(buf, 0, NULL, (void*)i, 0);
+  }
+
+  ty += CHOICE_HEIGHT + TIGHT_MARGIN;
+
   group->end();
 }
 

Modified: trunk/vncviewer/OptionsDialog.h
===================================================================
--- trunk/vncviewer/OptionsDialog.h     2011-05-24 11:33:43 UTC (rev 4443)
+++ trunk/vncviewer/OptionsDialog.h     2011-05-24 12:47:12 UTC (rev 4444)
@@ -26,6 +26,7 @@
 #include <FL/Fl_Check_Button.H>
 #include <FL/Fl_Round_Button.H>
 #include <FL/Fl_Int_Input.H>
+#include <FL/Fl_Choice.H>
 
 typedef void (OptionsCallback)(void*);
 
@@ -104,6 +105,7 @@
   Fl_Check_Button *acceptClipboardCheckbox;
   Fl_Check_Button *sendClipboardCheckbox;
   Fl_Check_Button *sendPrimaryCheckbox;
+  Fl_Choice *menuKeyChoice;
 
   /* Misc. */
   Fl_Check_Button *sharedCheckbox;

Modified: trunk/vncviewer/Viewport.cxx
===================================================================
--- trunk/vncviewer/Viewport.cxx        2011-05-24 11:33:43 UTC (rev 4443)
+++ trunk/vncviewer/Viewport.cxx        2011-05-24 12:47:12 UTC (rev 4444)
@@ -79,6 +79,10 @@
 
   contextMenu = new Fl_Menu_Button(0, 0, 0, 0);
   initContextMenu();
+
+  setMenuKey();
+
+  OptionsDialog::addCallback(handleOptions, this);
 }
 
 
@@ -94,6 +98,8 @@
   Fl::remove_clipboard_notify(handleClipboardChange);
 #endif
 
+  OptionsDialog::removeCallback(handleOptions);
+
   delete frameBuffer;
 
   if (pixelTrans)
@@ -249,7 +255,7 @@
     return 1;
 
   case FL_KEYDOWN:
-    if (Fl::event_key() == (FL_F + 8)) {
+    if (menuKeyCode && (Fl::event_key() == menuKeyCode)) {
       popupContextMenu();
       return 1;
     }
@@ -259,6 +265,9 @@
     return 1;
 
   case FL_KEYUP:
+    if (menuKeyCode && (Fl::event_key() == menuKeyCode))
+      return 1;
+
     handleKeyEvent(Fl::event_key(), Fl::event_original_key(),
                    Fl::event_text(), false);
     return 1;
@@ -557,15 +566,20 @@
 
 void Viewport::initContextMenu()
 {
+  contextMenu->clear();
+
   contextMenu->add(_("Exit viewer"), 0, NULL, (void*)ID_EXIT, FL_MENU_DIVIDER);
 
   contextMenu->add(_("Ctrl"), 0, NULL, (void*)ID_CTRL, FL_MENU_TOGGLE);
   contextMenu->add(_("Alt"), 0, NULL, (void*)ID_ALT, FL_MENU_TOGGLE);
-  CharArray menuKeyStr(menuKey.getData());
-  CharArray sendMenuKey(64);
-  snprintf(sendMenuKey.buf, 64, _("Send %s"), "F8"); // FIXME
-  contextMenu->add(sendMenuKey.buf, 0, NULL, (void*)ID_MENUKEY, 0);
-  contextMenu->add("Secret shortcut menu key", FL_F + 8, NULL, 
(void*)ID_MENUKEY, FL_MENU_INVISIBLE);
+
+  if (menuKeyCode) {
+    char sendMenuKey[64];
+    snprintf(sendMenuKey, 64, _("Send %s"), (const char *)menuKey);
+    contextMenu->add(sendMenuKey, 0, NULL, (void*)ID_MENUKEY, 0);
+    contextMenu->add("Secret shortcut menu key", menuKeyCode, NULL, 
(void*)ID_MENUKEY, FL_MENU_INVISIBLE);
+  }
+
   contextMenu->add(_("Send Ctrl-Alt-Del"), 0, NULL, (void*)ID_CTRLALTDEL, 
FL_MENU_DIVIDER);
 
   contextMenu->add(_("Refresh screen"), 0, NULL, (void*)ID_REFRESH, 
FL_MENU_DIVIDER);
@@ -603,9 +617,8 @@
     break;
   case ID_MENUKEY:
     if (!viewOnly) {
-      // FIXME
-      cc->writer()->keyEvent(XK_F8, true);
-      cc->writer()->keyEvent(XK_F8, false);
+      handleKeyEvent(menuKeyCode, menuKeyCode, "", true);
+      handleKeyEvent(menuKeyCode, menuKeyCode, "", false);
     }
     break;
   case ID_CTRLALTDEL:
@@ -638,3 +651,30 @@
     break;
   }
 }
+
+
+void Viewport::setMenuKey()
+{
+  const char *menuKeyStr;
+
+  menuKeyCode = 0;
+
+  menuKeyStr = menuKey;
+  if (menuKeyStr[0] == 'F') {
+    int num = atoi(menuKeyStr + 1);
+    if ((num >= 1) && (num <= 12))
+      menuKeyCode = FL_F + num;
+  }
+
+  // Need to repopulate the context menu as it contains references to
+  // the menu key
+  initContextMenu();
+}
+
+
+void Viewport::handleOptions(void *data)
+{
+  Viewport *self = (Viewport*)data;
+
+  self->setMenuKey();
+}

Modified: trunk/vncviewer/Viewport.h
===================================================================
--- trunk/vncviewer/Viewport.h  2011-05-24 11:33:43 UTC (rev 4443)
+++ trunk/vncviewer/Viewport.h  2011-05-24 12:47:12 UTC (rev 4444)
@@ -104,6 +104,10 @@
   void initContextMenu();
   void popupContextMenu();
 
+  void setMenuKey();
+
+  static void handleOptions(void *data);
+
 private:
   CConn* cc;
 
@@ -120,6 +124,7 @@
   typedef std::map<int, rdr::U32> DownMap;
   DownMap downKeySym;
 
+  int menuKeyCode;
   Fl_Menu_Button *contextMenu;
 };
 

Modified: trunk/vncviewer/fltk_layout.h
===================================================================
--- trunk/vncviewer/fltk_layout.h       2011-05-24 11:33:43 UTC (rev 4443)
+++ trunk/vncviewer/fltk_layout.h       2011-05-24 12:47:12 UTC (rev 4444)
@@ -99,6 +99,10 @@
 #define CHECK_MIN_WIDTH         RADIO_MIN_WIDTH
 #define CHECK_HEIGHT            RADIO_HEIGHT
 
+/* Fl_Choice */
+
+#define CHOICE_HEIGHT           INPUT_HEIGHT
+
 /* Fl_Group */
 #define GROUP_LABEL_OFFSET      FL_NORMAL_SIZE
 #define GROUP_MARGIN            12


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Tigervnc-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tigervnc-commits

Reply via email to