diff options
author | Pierre Ossman <ossman@cendio.se> | 2015-02-20 17:34:49 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2015-02-20 17:35:56 +0100 |
commit | 52a18150a7a8f2802000136c35005bc83b5b0855 (patch) | |
tree | 6ea42c474c120d938c2c9bb47a70aed9b40b5ce4 | |
parent | c134168be95552aa97415b8acbdeff00bf400eda (diff) | |
download | tigervnc-52a18150a7a8f2802000136c35005bc83b5b0855.tar.gz tigervnc-52a18150a7a8f2802000136c35005bc83b5b0855.zip |
Disable entries instead of shuffling memory around
Less risk for bugs this way.
-rw-r--r-- | vncviewer/Viewport.cxx | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index 918730e6..463523f5 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -1109,31 +1109,20 @@ void Viewport::initContextMenu() if (menuAltKey) items[i].flags |= FL_MENU_VALUE; break; + case ID_MENUKEY: + // The menu key needs to have its fields updated, or the entries hidden + if (!menuKeySym) + items[i].flags |= FL_MENU_INACTIVE | FL_MENU_INVISIBLE; + else if (!(items[i].flags & FL_MENU_INVISIBLE)) { + char sendMenuKey[64]; + snprintf(sendMenuKey, 64, _("Send %s"), (const char *)menuKey); + free((void*)items[i].text); + items[i].text = strdup(sendMenuKey); + } + break; } } - // The menu key needs to have its fields updated, or the entries removed - for (i = 0;i < sizeof(items)/sizeof(items[0]);i++) { - char sendMenuKey[64]; - - if ((intptr_t)items[i].user_data_ != ID_MENUKEY) - continue; - - if (!menuKeySym) { - memmove(items + i, items + i + 1, - sizeof(items) - (sizeof(items[0]) * (i+1))); - i--; - continue; - } - - if (items[i].flags & FL_MENU_INVISIBLE) - continue; - - snprintf(sendMenuKey, 64, _("Send %s"), (const char *)menuKey); - free((void*)items[i].text); - items[i].text = strdup(sendMenuKey); - } - contextMenu->copy(items); } |