windows: Track the window display ID locally

Track the current window display ID locally so as not to depend on specific behavior of the video layer, which may change the value at times when it isn't expected.
main
Frank Praznik 2023-02-22 12:02:25 -05:00 committed by Sam Lantinga
parent 9f1a7bb94c
commit e8fd7f74bd
3 changed files with 7 additions and 2 deletions

View File

@ -1241,7 +1241,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
RECT rect;
int x, y;
int w, h;
SDL_DisplayID displayID = SDL_GetDisplayForWindow(data->window);
const SDL_DisplayID original_displayID = data->last_displayID;
if (data->initializing || data->in_border_change) {
break;
@ -1294,7 +1294,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
/* Forces a WM_PAINT event */
InvalidateRect(hwnd, NULL, FALSE);
if (data->window->last_displayID != displayID) {
/* Update the window display position */
data->last_displayID = SDL_GetDisplayForWindow(data->window);
if (data->last_displayID != original_displayID) {
/* Display changed, check ICC profile */
WIN_UpdateWindowICCProfile(data->window, SDL_TRUE);
}

View File

@ -309,6 +309,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, HWND hwnd, HWND parent, SD
data->last_pointer_update = (LPARAM)-1;
data->videodata = videodata;
data->initializing = SDL_TRUE;
data->last_displayID = window->last_displayID;
data->scaling_dpi = WIN_GetScalingDPIForHWND(videodata, hwnd);
#ifdef HIGHDPI_DEBUG

View File

@ -62,6 +62,7 @@ struct SDL_WindowData
RECT cursor_clipped_rect;
SDL_Point last_raw_mouse_position;
SDL_bool mouse_tracked;
SDL_DisplayID last_displayID;
WCHAR *ICMFileName;
struct SDL_VideoData *videodata;
#if SDL_VIDEO_OPENGL_EGL