Only check to see if the ICC profile changes when the display changes or we gain focus Fixes https://github.com/libsdl-org/SDL/issues/6366
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 20acb8f..e5903fd 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -449,6 +449,7 @@ WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus)
SDL_ToggleModState(KMOD_NUM, (GetKeyState(VK_NUMLOCK) & 0x0001) != 0);
SDL_ToggleModState(KMOD_SCROLL, (GetKeyState(VK_SCROLL) & 0x0001) != 0);
+ WIN_UpdateWindowICCProfile(data->window, SDL_TRUE);
} else {
RECT rect;
@@ -697,7 +698,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
actually being the foreground window, but this appears to get called in all cases where
the global foreground window changes to and from this window. */
WIN_UpdateFocus(data->window, !!wParam);
- WIN_UpdateWindowICCProfile(data->window, SDL_TRUE);
}
break;
@@ -1171,6 +1171,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
RECT rect;
int x, y;
int w, h;
+ int display_index = data->window->display_index;
if (data->initializing || data->in_border_change) {
break;
@@ -1211,7 +1212,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
/* Forces a WM_PAINT event */
InvalidateRect(hwnd, NULL, FALSE);
- WIN_UpdateWindowICCProfile(data->window, SDL_TRUE);
+ if (data->window->display_index != display_index) {
+ /* Display changed, check ICC profile */
+ WIN_UpdateWindowICCProfile(data->window, SDL_TRUE);
+ }
}
break;