From abd70ceddebe90a8c7fb3d7055eb771ed3a37f2f Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Wed, 14 Sep 2011 06:31:06 +0000 Subject: [PATCH] - Changes behaviour of context menu to be reinitialize before display with intial states. - Fixes for fullscreen contextmenu item to show the current fullscreen state as it was done in the old viewer. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4670 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- vncviewer/Viewport.cxx | 19 +++++++++++-------- vncviewer/Viewport.h | 3 +++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index 052b593b..5fd873cb 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -98,7 +98,6 @@ Viewport::Viewport(int w, int h, const rfb::PixelFormat& serverPF, CConn* cc_) window()->add(contextMenu); setMenuKey(); - initContextMenu(); OptionsDialog::addCallback(handleOptions, this); } @@ -843,11 +842,14 @@ void Viewport::initContextMenu() contextMenu->add(_("Exit viewer"), 0, NULL, (void*)ID_EXIT, FL_MENU_DIVIDER); #ifdef HAVE_FLTK_FULLSCREEN - contextMenu->add(_("Full screen"), 0, NULL, (void*)ID_FULLSCREEN, FL_MENU_DIVIDER); + contextMenu->add(_("Full screen"), 0, NULL, (void*)ID_FULLSCREEN, + FL_MENU_TOGGLE | (window()->fullscreen_active()?FL_MENU_VALUE:0)); #endif - contextMenu->add(_("Ctrl"), 0, NULL, (void*)ID_CTRL, FL_MENU_TOGGLE); - contextMenu->add(_("Alt"), 0, NULL, (void*)ID_ALT, FL_MENU_TOGGLE); + contextMenu->add(_("Ctrl"), 0, NULL, (void*)ID_CTRL, + FL_MENU_TOGGLE | (menuCtrlKey?FL_MENU_VALUE:0)); + contextMenu->add(_("Alt"), 0, NULL, (void*)ID_ALT, + FL_MENU_TOGGLE | (menuAltKey?FL_MENU_VALUE:0)); if (menuKeyCode) { char sendMenuKey[64]; @@ -877,6 +879,9 @@ void Viewport::popupContextMenu() // it will start up highlighting the previously selected entry. contextMenu->value(-1); + // initialize context menu before display + initContextMenu(); + m = contextMenu->popup(); if (m == NULL) return; @@ -898,9 +903,11 @@ void Viewport::popupContextMenu() #endif case ID_CTRL: handleKeyEvent(FL_Control_L, FL_Control_L, "", m->value()); + menuCtrlKey = !menuCtrlKey; break; case ID_ALT: handleKeyEvent(FL_Alt_L, FL_Alt_L, "", m->value()); + menuAltKey = !menuAltKey; break; case ID_MENUKEY: handleKeyEvent(menuKeyCode, menuKeyCode, "", true); @@ -940,10 +947,6 @@ void Viewport::popupContextMenu() void Viewport::setMenuKey() { menuKeyCode = getMenuKeyCode(); - - // Need to repopulate the context menu as it contains references to - // the menu key - initContextMenu(); } diff --git a/vncviewer/Viewport.h b/vncviewer/Viewport.h index c9a3cf3a..144ad420 100644 --- a/vncviewer/Viewport.h +++ b/vncviewer/Viewport.h @@ -155,6 +155,9 @@ private: int menuKeyCode; Fl_Menu_Button *contextMenu; + bool menuCtrlKey; + bool menuAltKey; + Fl_RGB_Image *cursor; rfb::Point cursorHotspot; }; -- 2.39.5