with raw X11, so do what the Windows client did and restrict the available keys to just the function keys. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4444 3789f03b-4d11-0410-bbf8-ca57d06f2519tags/v1.1.90
@@ -253,11 +253,22 @@ void OptionsDialog::loadOptions(void) | |||
#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 @@ void OptionsDialog::storeOptions(void) | |||
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 @@ void OptionsDialog::createInputPage(int tx, int ty, int tw, int th) | |||
_("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(); | |||
} | |||
@@ -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 @@ protected: | |||
Fl_Check_Button *acceptClipboardCheckbox; | |||
Fl_Check_Button *sendClipboardCheckbox; | |||
Fl_Check_Button *sendPrimaryCheckbox; | |||
Fl_Choice *menuKeyChoice; | |||
/* Misc. */ | |||
Fl_Check_Button *sharedCheckbox; |
@@ -79,6 +79,10 @@ Viewport::Viewport(int w, int h, const rfb::PixelFormat& serverPF, CConn* cc_) | |||
contextMenu = new Fl_Menu_Button(0, 0, 0, 0); | |||
initContextMenu(); | |||
setMenuKey(); | |||
OptionsDialog::addCallback(handleOptions, this); | |||
} | |||
@@ -94,6 +98,8 @@ Viewport::~Viewport() | |||
Fl::remove_clipboard_notify(handleClipboardChange); | |||
#endif | |||
OptionsDialog::removeCallback(handleOptions); | |||
delete frameBuffer; | |||
if (pixelTrans) | |||
@@ -249,7 +255,7 @@ int Viewport::handle(int event) | |||
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 @@ int Viewport::handle(int event) | |||
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::handleKeyEvent(int keyCode, int origKeyCode, const char *keyText, | |||
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 @@ void Viewport::popupContextMenu() | |||
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 @@ void Viewport::popupContextMenu() | |||
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(); | |||
} |
@@ -104,6 +104,10 @@ private: | |||
void initContextMenu(); | |||
void popupContextMenu(); | |||
void setMenuKey(); | |||
static void handleOptions(void *data); | |||
private: | |||
CConn* cc; | |||
@@ -120,6 +124,7 @@ private: | |||
typedef std::map<int, rdr::U32> DownMap; | |||
DownMap downKeySym; | |||
int menuKeyCode; | |||
Fl_Menu_Button *contextMenu; | |||
}; | |||
@@ -99,6 +99,10 @@ static inline int fltk_escape(const char *in, char *out, size_t maxlen) | |||
#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 |