Reset the window icon when returning from fullscreen mode
Fixes https://github.com/libsdl-org/SDL/issues/14522
This commit is contained in:
@@ -582,7 +582,6 @@ static void CleanupWindowData(SDL_VideoDevice *_this, SDL_Window *window)
|
|||||||
SDL_WindowData *data = window->internal;
|
SDL_WindowData *data = window->internal;
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|
||||||
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
|
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
|
||||||
if (data->drop_target) {
|
if (data->drop_target) {
|
||||||
WIN_AcceptDragAndDrop(window, false);
|
WIN_AcceptDragAndDrop(window, false);
|
||||||
@@ -591,6 +590,9 @@ static void CleanupWindowData(SDL_VideoDevice *_this, SDL_Window *window)
|
|||||||
if (data->keyboard_hook) {
|
if (data->keyboard_hook) {
|
||||||
UnhookWindowsHookEx(data->keyboard_hook);
|
UnhookWindowsHookEx(data->keyboard_hook);
|
||||||
}
|
}
|
||||||
|
if (data->hicon) {
|
||||||
|
DestroyIcon(data->hicon);
|
||||||
|
}
|
||||||
ReleaseDC(data->hwnd, data->hdc);
|
ReleaseDC(data->hwnd, data->hdc);
|
||||||
RemoveProp(data->hwnd, TEXT("SDL_WindowData"));
|
RemoveProp(data->hwnd, TEXT("SDL_WindowData"));
|
||||||
#endif
|
#endif
|
||||||
@@ -837,7 +839,8 @@ void WIN_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window)
|
|||||||
bool WIN_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon)
|
bool WIN_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon)
|
||||||
{
|
{
|
||||||
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
|
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
|
||||||
HWND hwnd = window->internal->hwnd;
|
SDL_WindowData *data = window->internal;
|
||||||
|
HWND hwnd = data->hwnd;
|
||||||
HICON hicon = NULL;
|
HICON hicon = NULL;
|
||||||
BYTE *icon_bmp;
|
BYTE *icon_bmp;
|
||||||
int icon_len, mask_len, row_len, y;
|
int icon_len, mask_len, row_len, y;
|
||||||
@@ -888,9 +891,14 @@ bool WIN_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *
|
|||||||
SDL_small_free(icon_bmp, isstack);
|
SDL_small_free(icon_bmp, isstack);
|
||||||
|
|
||||||
if (!hicon) {
|
if (!hicon) {
|
||||||
result = SDL_SetError("SetWindowIcon() failed, error %08X", (unsigned int)GetLastError());
|
return SDL_SetError("SetWindowIcon() failed, error %08X", (unsigned int)GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data->hicon) {
|
||||||
|
DestroyIcon(data->hicon);
|
||||||
|
}
|
||||||
|
data->hicon = hicon;
|
||||||
|
|
||||||
// Set the icon for the window
|
// Set the icon for the window
|
||||||
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hicon);
|
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hicon);
|
||||||
|
|
||||||
@@ -1364,6 +1372,12 @@ SDL_FullscreenResult WIN_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window
|
|||||||
WIN_MaximizeWindow(_this, window);
|
WIN_MaximizeWindow(_this, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!fullscreen && data && data->hicon) {
|
||||||
|
// Reset the icon for the window when returning from fullscreen mode
|
||||||
|
SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0);
|
||||||
|
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)data->hicon);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HIGHDPI_DEBUG
|
#ifdef HIGHDPI_DEBUG
|
||||||
SDL_Log("WIN_SetWindowFullscreen: %d finished. Set window to %d,%d, %dx%d", (int)fullscreen, x, y, w, h);
|
SDL_Log("WIN_SetWindowFullscreen: %d finished. Set window to %d,%d, %dx%d", (int)fullscreen, x, y, w, h);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ struct SDL_WindowData
|
|||||||
HDC mdc;
|
HDC mdc;
|
||||||
HINSTANCE hinstance;
|
HINSTANCE hinstance;
|
||||||
HBITMAP hbm;
|
HBITMAP hbm;
|
||||||
|
HICON hicon;
|
||||||
WNDPROC wndproc;
|
WNDPROC wndproc;
|
||||||
HHOOK keyboard_hook;
|
HHOOK keyboard_hook;
|
||||||
WPARAM mouse_button_flags;
|
WPARAM mouse_button_flags;
|
||||||
|
|||||||
Reference in New Issue
Block a user