Skip to content

Commit 16be721

Browse files
Fixes foregrounding of OBS when launched from browser.
1 parent 1d63872 commit 16be721

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

loader/main.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ DWORD GetProcessIdFromExe(const std::wstring& exeName) {
6666
return 0; // Not found
6767
}
6868

69+
6970
// Callback function to find the window associated with a given process ID
7071
BOOL CALLBACK WindowToForeground(HWND hwnd, LPARAM lParam) {
7172
DWORD processId;
@@ -77,8 +78,14 @@ BOOL CALLBACK WindowToForeground(HWND hwnd, LPARAM lParam) {
7778
std::wstring title = windowTitle;
7879
// Bring the window to the foreground
7980
if (title.rfind(L"OBS ", 0) == 0) { // the main OBS window title starts with 'OBS '
81+
bool maximized = IsZoomed(hwnd);
82+
bool minimized = IsIconic(hwnd);
83+
if (!minimized) {
84+
ShowWindow(hwnd, maximized ? SW_SHOWMAXIMIZED : SW_SHOW);
85+
} else {
86+
ShowWindow(hwnd, SW_RESTORE);
87+
}
8088
SetForegroundWindow(hwnd);
81-
ShowWindow(hwnd, SW_SHOW);
8289
return FALSE; // Stop enumerating windows (we found the window)
8390
}
8491
}

0 commit comments

Comments
 (0)