FIX : [Settings] - Can start multiple settings dialogs (#2421)

* Launch new wpf process with same/old ipc names

* updated bring window to front

* reverted change

* removed unused string
This commit is contained in:
Lavius Motileng 2020-05-05 14:02:55 -07:00 committed by GitHub
parent 36559d0264
commit d65e2ab2d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -350,15 +350,27 @@ LExit:
g_settings_process_id = 0; g_settings_process_id = 0;
} }
#define MAX_TITLE_LENGTH 100
void bring_settings_to_front() void bring_settings_to_front()
{ {
auto callback = [](HWND hwnd, LPARAM data) -> BOOL { auto callback = [](HWND hwnd, LPARAM data) -> BOOL {
DWORD processId; DWORD processId;
if (GetWindowThreadProcessId(hwnd, &processId) && processId == g_settings_process_id) if (GetWindowThreadProcessId(hwnd, &processId) && processId == g_settings_process_id)
{ {
ShowWindow(hwnd, SW_NORMAL); std::wstring windowTitle = L"PowerToys Settings";
SetForegroundWindow(hwnd);
return FALSE; WCHAR title[MAX_TITLE_LENGTH];
int len = GetWindowTextW(hwnd, title, MAX_TITLE_LENGTH);
if (len <= 0)
{
return TRUE;
}
if (wcsncmp(title, windowTitle.c_str(), len) == 0)
{
ShowWindow(hwnd, SW_RESTORE);
SetForegroundWindow(hwnd);
return FALSE;
}
} }
return TRUE; return TRUE;