From 44c084f33ffc72835f1b7f43b4903758d15fc2af Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 4 Apr 2021 09:05:36 +0100 Subject: [PATCH] Windows Pageant: add --keylist option. This causes the main key list window to open when Pageant starts up, instead of waiting until you select 'View Keys' from the systray menu. My main motivation for adding this option is for development: if I'm _working_ on some detail of the key list window, it cuts down keystrokes in my edit-compile-retry cycle if I can have it automatically pop up in every new test run of Pageant. Normally I'd solve that by hacking an extra couple of lines temporarily into the code while I was doing that piece of development. But it suddenly struck me that there's no reason _not_ to add an option like this permanently (the space of word-length command-line flags is huge, and that particular one is unlikely to be needed for a different meaning), and who knows, it _might_ come in useful to someone in normal use. And at the very least it'll save me doing another temporary hack the next time I'm doing development work on the Pageant GUI. So I'll leave it in. --- windows/winpgnt.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/windows/winpgnt.c b/windows/winpgnt.c index cb74a917..b042ade9 100644 --- a/windows/winpgnt.c +++ b/windows/winpgnt.c @@ -1055,6 +1055,15 @@ static char *answer_filemapping_message(const char *mapname) return err; } +static void create_keylist_window(void) +{ + if (keylist) + return; + + keylist = CreateDialog(hinst, MAKEINTRESOURCE(211), NULL, KeyListProc); + ShowWindow(keylist, SW_SHOWNORMAL); +} + static LRESULT CALLBACK TrayWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -1122,11 +1131,7 @@ static LRESULT CALLBACK TrayWndProc(HWND hwnd, UINT message, SendMessage(hwnd, WM_CLOSE, 0, 0); break; case IDM_VIEWKEYS: - if (!keylist) { - keylist = CreateDialog(hinst, MAKEINTRESOURCE(211), - NULL, KeyListProc); - ShowWindow(keylist, SW_SHOWNORMAL); - } + create_keylist_window(); /* * Sometimes the window comes up minimised / hidden for * no obvious reason. Prevent this. This also brings it @@ -1303,6 +1308,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) MSG msg; const char *command = NULL; bool added_keys = false; + bool show_keylist_on_startup = false; int argc, i; char **argv, **argstart; @@ -1404,6 +1410,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) !strcmp(p, "--encrypted") || !strcmp(p, "-encrypted")) { add_keys_encrypted = true; + } else if (!strcmp(p, "-keylist") || !strcmp(p, "--keylist")) { + show_keylist_on_startup = true; } else if (!strcmp(p, "-c")) { /* * If we see `-c', then the rest of the @@ -1564,6 +1572,9 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) &inst, 0, &wm_copydata_threadid); handle_add_foreign_event(wmct.ev_msg_ready, wm_copydata_got_msg, NULL); + if (show_keylist_on_startup) + create_keylist_window(); + /* * Main message loop. */