Skip to content

Commit 7f0c37a

Browse files
Fixed window icon restore behavior on...
...desktop mode refresh, hide & show visual window when on full-screen/borderless mode etc.
1 parent 1fa4773 commit 7f0c37a

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

vis_milk2/Milkdrop2PcmVisualizer.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,36 @@ static unsigned char pcmRightOut[SAMPLE_SIZE];
269269

270270
static HICON icon = nullptr;
271271

272+
void RestoreRenderWindowIcon(HWND hwnd)
273+
{
274+
if (!hwnd)
275+
return;
276+
277+
// Recreate the normal top-level taskbar entry after fullscreen, borderless,
278+
// or Desktop Mode changed the window's parent/style.
279+
LONG_PTR exStyle = GetWindowLongPtrW(hwnd, GWL_EXSTYLE);
280+
exStyle &= ~static_cast<LONG_PTR>(WS_EX_TOOLWINDOW);
281+
exStyle |= WS_EX_APPWINDOW;
282+
SetWindowLongPtrW(hwnd, GWL_EXSTYLE, exStyle);
283+
SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
284+
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE |
285+
SWP_FRAMECHANGED);
286+
287+
if (!icon && module)
288+
icon = LoadIconW(module, MAKEINTRESOURCEW(IDI_PLUGIN_ICON));
289+
290+
if (icon)
291+
{
292+
SendMessageW(hwnd, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(icon));
293+
SendMessageW(hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(icon));
294+
}
295+
296+
// Explorer only adds the taskbar button after a top-level app window is
297+
// shown. This also refreshes the entry after an Explorer/display refresh.
298+
ShowWindow(hwnd, SW_HIDE);
299+
ShowWindow(hwnd, SW_SHOW);
300+
}
301+
272302

273303
// SPOUT
274304
// ===============================================
@@ -429,6 +459,7 @@ void ToggleStretch(HWND hwnd) {
429459
}
430460
}
431461
fullscreen = false;
462+
RestoreRenderWindowIcon(hwnd);
432463
}
433464

434465
void ToggleFullScreen(HWND hwnd) {
@@ -500,6 +531,7 @@ void ToggleFullScreen(HWND hwnd) {
500531
}
501532
}
502533
stretch = false;
534+
RestoreRenderWindowIcon(hwnd);
503535
}
504536

505537
void ToggleBorderlessWindow(HWND hwnd)
@@ -531,6 +563,7 @@ void ToggleBorderlessWindow(HWND hwnd)
531563
else
532564
SetWindowPos(hwnd, HWND_NOTOPMOST, x, y, width, height, SWP_DRAWFRAME | SWP_FRAMECHANGED);
533565
borderless = false;
566+
RestoreRenderWindowIcon(hwnd);
534567
}
535568
}
536569

0 commit comments

Comments
 (0)