mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-02-09 16:36:34 +00:00
Users of Virtual Dimension are reporting that the "Close" menu item and
button tend to get disabled on login. After a suggestion by "Tkil", change the way we handle the specials menu to be robust against the window menu being externally modified. [originally from svn r6546] [this svn revision also touched putty-wishlist]
This commit is contained in:
parent
4da1f2b17e
commit
3cdf5b739f
@ -40,6 +40,7 @@
|
|||||||
#define IDM_COPYALL 0x0170
|
#define IDM_COPYALL 0x0170
|
||||||
#define IDM_FULLSCREEN 0x0180
|
#define IDM_FULLSCREEN 0x0180
|
||||||
#define IDM_PASTE 0x0190
|
#define IDM_PASTE 0x0190
|
||||||
|
#define IDM_SPECIALSEP 0x0200
|
||||||
|
|
||||||
#define IDM_SPECIAL_MIN 0x0400
|
#define IDM_SPECIAL_MIN 0x0400
|
||||||
#define IDM_SPECIAL_MAX 0x0800
|
#define IDM_SPECIAL_MAX 0x0800
|
||||||
@ -111,15 +112,15 @@ static struct unicode_data ucsdata;
|
|||||||
static int session_closed;
|
static int session_closed;
|
||||||
static int reconfiguring = FALSE;
|
static int reconfiguring = FALSE;
|
||||||
|
|
||||||
static const struct telnet_special *specials;
|
static const struct telnet_special *specials = NULL;
|
||||||
static int n_specials;
|
static HMENU specials_menu = NULL;
|
||||||
|
static int n_specials = 0;
|
||||||
|
|
||||||
#define TIMING_TIMER_ID 1234
|
#define TIMING_TIMER_ID 1234
|
||||||
static long timing_next_time;
|
static long timing_next_time;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
HMENU menu;
|
HMENU menu;
|
||||||
int specials_submenu_pos;
|
|
||||||
} popup_menus[2];
|
} popup_menus[2];
|
||||||
enum { SYSMENU, CTXMENU };
|
enum { SYSMENU, CTXMENU };
|
||||||
static HMENU savedsess_menu;
|
static HMENU savedsess_menu;
|
||||||
@ -764,7 +765,6 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
|||||||
m = popup_menus[j].menu;
|
m = popup_menus[j].menu;
|
||||||
|
|
||||||
AppendMenu(m, MF_SEPARATOR, 0, 0);
|
AppendMenu(m, MF_SEPARATOR, 0, 0);
|
||||||
popup_menus[j].specials_submenu_pos = GetMenuItemCount(m);
|
|
||||||
AppendMenu(m, MF_ENABLED, IDM_SHOWLOG, "&Event Log");
|
AppendMenu(m, MF_ENABLED, IDM_SHOWLOG, "&Event Log");
|
||||||
AppendMenu(m, MF_SEPARATOR, 0, 0);
|
AppendMenu(m, MF_SEPARATOR, 0, 0);
|
||||||
AppendMenu(m, MF_ENABLED, IDM_NEWSESS, "Ne&w Session...");
|
AppendMenu(m, MF_ENABLED, IDM_NEWSESS, "Ne&w Session...");
|
||||||
@ -914,8 +914,7 @@ static void update_savedsess_menu(void)
|
|||||||
*/
|
*/
|
||||||
void update_specials_menu(void *frontend)
|
void update_specials_menu(void *frontend)
|
||||||
{
|
{
|
||||||
HMENU p;
|
HMENU new_menu;
|
||||||
int menu_already_exists = (specials != NULL);
|
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
if (back)
|
if (back)
|
||||||
@ -928,30 +927,30 @@ void update_specials_menu(void *frontend)
|
|||||||
* here's a lame "stack" that will do for now. */
|
* here's a lame "stack" that will do for now. */
|
||||||
HMENU saved_menu = NULL;
|
HMENU saved_menu = NULL;
|
||||||
int nesting = 1;
|
int nesting = 1;
|
||||||
p = CreatePopupMenu();
|
new_menu = CreatePopupMenu();
|
||||||
for (i = 0; nesting > 0; i++) {
|
for (i = 0; nesting > 0; i++) {
|
||||||
assert(IDM_SPECIAL_MIN + 0x10 * i < IDM_SPECIAL_MAX);
|
assert(IDM_SPECIAL_MIN + 0x10 * i < IDM_SPECIAL_MAX);
|
||||||
switch (specials[i].code) {
|
switch (specials[i].code) {
|
||||||
case TS_SEP:
|
case TS_SEP:
|
||||||
AppendMenu(p, MF_SEPARATOR, 0, 0);
|
AppendMenu(new_menu, MF_SEPARATOR, 0, 0);
|
||||||
break;
|
break;
|
||||||
case TS_SUBMENU:
|
case TS_SUBMENU:
|
||||||
assert(nesting < 2);
|
assert(nesting < 2);
|
||||||
nesting++;
|
nesting++;
|
||||||
saved_menu = p; /* XXX lame stacking */
|
saved_menu = new_menu; /* XXX lame stacking */
|
||||||
p = CreatePopupMenu();
|
new_menu = CreatePopupMenu();
|
||||||
AppendMenu(saved_menu, MF_POPUP | MF_ENABLED,
|
AppendMenu(saved_menu, MF_POPUP | MF_ENABLED,
|
||||||
(UINT) p, specials[i].name);
|
(UINT) new_menu, specials[i].name);
|
||||||
break;
|
break;
|
||||||
case TS_EXITMENU:
|
case TS_EXITMENU:
|
||||||
nesting--;
|
nesting--;
|
||||||
if (nesting) {
|
if (nesting) {
|
||||||
p = saved_menu; /* XXX lame stacking */
|
new_menu = saved_menu; /* XXX lame stacking */
|
||||||
saved_menu = NULL;
|
saved_menu = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
AppendMenu(p, MF_ENABLED, IDM_SPECIAL_MIN + 0x10 * i,
|
AppendMenu(new_menu, MF_ENABLED, IDM_SPECIAL_MIN + 0x10 * i,
|
||||||
specials[i].name);
|
specials[i].name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -959,29 +958,24 @@ void update_specials_menu(void *frontend)
|
|||||||
/* Squirrel the highest special. */
|
/* Squirrel the highest special. */
|
||||||
n_specials = i - 1;
|
n_specials = i - 1;
|
||||||
} else {
|
} else {
|
||||||
p = NULL;
|
new_menu = NULL;
|
||||||
n_specials = 0;
|
n_specials = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < lenof(popup_menus); j++) {
|
for (j = 0; j < lenof(popup_menus); j++) {
|
||||||
if (menu_already_exists) {
|
if (specials_menu) {
|
||||||
/* XXX does this free up all submenus? */
|
/* XXX does this free up all submenus? */
|
||||||
DeleteMenu(popup_menus[j].menu,
|
DeleteMenu(popup_menus[j].menu, specials_menu, MF_BYCOMMAND);
|
||||||
popup_menus[j].specials_submenu_pos,
|
DeleteMenu(popup_menus[j].menu, IDM_SPECIALSEP, MF_BYCOMMAND);
|
||||||
MF_BYPOSITION);
|
|
||||||
DeleteMenu(popup_menus[j].menu,
|
|
||||||
popup_menus[j].specials_submenu_pos,
|
|
||||||
MF_BYPOSITION);
|
|
||||||
}
|
}
|
||||||
if (specials) {
|
if (specials) {
|
||||||
InsertMenu(popup_menus[j].menu,
|
InsertMenu(popup_menus[j].menu, IDM_SHOWLOG,
|
||||||
popup_menus[j].specials_submenu_pos,
|
MF_BYCOMMAND | MF_POPUP | MF_ENABLED,
|
||||||
MF_BYPOSITION | MF_SEPARATOR, 0, 0);
|
(UINT) new_menu, "S&pecial Command");
|
||||||
InsertMenu(popup_menus[j].menu,
|
InsertMenu(popup_menus[j].menu, IDM_SHOWLOG,
|
||||||
popup_menus[j].specials_submenu_pos,
|
MF_BYCOMMAND | MF_SEPARATOR, IDM_SPECIALSEP, 0);
|
||||||
MF_BYPOSITION | MF_POPUP | MF_ENABLED,
|
|
||||||
(UINT) p, "S&pecial Command");
|
|
||||||
}
|
}
|
||||||
|
specials_menu = new_menu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user