#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);
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());
_("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();
}
contextMenu = new Fl_Menu_Button(0, 0, 0, 0);
initContextMenu();
+
+ setMenuKey();
+
+ OptionsDialog::addCallback(handleOptions, this);
}
Fl::remove_clipboard_notify(handleClipboardChange);
#endif
+ OptionsDialog::removeCallback(handleOptions);
+
delete frameBuffer;
if (pixelTrans)
return 1;
case FL_KEYDOWN:
- if (Fl::event_key() == (FL_F + 8)) {
+ if (menuKeyCode && (Fl::event_key() == menuKeyCode)) {
popupContextMenu();
return 1;
}
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;
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);
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:
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();
+}