mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-04 17:06:25 +00:00
Store the current window display ID on the window
This commit is contained in:
@@ -191,11 +191,11 @@ bool SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, int data
|
|||||||
window->flags &= ~SDL_WINDOW_INPUT_FOCUS;
|
window->flags &= ~SDL_WINDOW_INPUT_FOCUS;
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_WINDOW_DISPLAY_CHANGED:
|
case SDL_EVENT_WINDOW_DISPLAY_CHANGED:
|
||||||
if (data1 == 0 || (SDL_DisplayID)data1 == window->last_displayID) {
|
if (data1 == 0 || (SDL_DisplayID)data1 == window->displayID) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
window->update_fullscreen_on_display_changed = true;
|
window->update_fullscreen_on_display_changed = true;
|
||||||
window->last_displayID = (SDL_DisplayID)data1;
|
window->displayID = (SDL_DisplayID)data1;
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_WINDOW_OCCLUDED:
|
case SDL_EVENT_WINDOW_OCCLUDED:
|
||||||
if (window->flags & SDL_WINDOW_OCCLUDED) {
|
if (window->flags & SDL_WINDOW_OCCLUDED) {
|
||||||
|
@@ -60,7 +60,7 @@ struct SDL_Window
|
|||||||
bool external_graphics_context;
|
bool external_graphics_context;
|
||||||
bool fullscreen_exclusive; // The window is currently fullscreen exclusive
|
bool fullscreen_exclusive; // The window is currently fullscreen exclusive
|
||||||
SDL_DisplayID last_fullscreen_exclusive_display; // The last fullscreen_exclusive display
|
SDL_DisplayID last_fullscreen_exclusive_display; // The last fullscreen_exclusive display
|
||||||
SDL_DisplayID last_displayID;
|
SDL_DisplayID displayID;
|
||||||
SDL_DisplayID pending_displayID;
|
SDL_DisplayID pending_displayID;
|
||||||
|
|
||||||
/* Stored position and size for the window in the non-fullscreen state,
|
/* Stored position and size for the window in the non-fullscreen state,
|
||||||
|
@@ -1150,7 +1150,7 @@ void SDL_SetDisplayContentScale(SDL_VideoDisplay *display, float scale)
|
|||||||
|
|
||||||
// Check the windows on this display
|
// Check the windows on this display
|
||||||
for (window = _this->windows; window; window = window->next) {
|
for (window = _this->windows; window; window = window->next) {
|
||||||
if (display->id == window->last_displayID) {
|
if (display->id == window->displayID) {
|
||||||
SDL_CheckWindowDisplayScaleChanged(window);
|
SDL_CheckWindowDisplayScaleChanged(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1800,7 +1800,7 @@ static void SDL_CheckWindowDisplayChanged(SDL_Window *window)
|
|||||||
|
|
||||||
SDL_DisplayID displayID = SDL_GetDisplayForWindowPosition(window);
|
SDL_DisplayID displayID = SDL_GetDisplayForWindowPosition(window);
|
||||||
|
|
||||||
if (displayID != window->last_displayID) {
|
if (displayID != window->displayID) {
|
||||||
int i, display_index;
|
int i, display_index;
|
||||||
|
|
||||||
// Sanity check our fullscreen windows
|
// Sanity check our fullscreen windows
|
||||||
@@ -1862,7 +1862,7 @@ static void SDL_CheckWindowDisplayScaleChanged(SDL_Window *window)
|
|||||||
display_scale = _this->GetWindowContentScale(_this, window);
|
display_scale = _this->GetWindowContentScale(_this, window);
|
||||||
} else {
|
} else {
|
||||||
const float pixel_density = SDL_GetWindowPixelDensity(window);
|
const float pixel_density = SDL_GetWindowPixelDensity(window);
|
||||||
const float content_scale = SDL_GetDisplayContentScale(SDL_GetDisplayForWindowPosition(window));
|
const float content_scale = SDL_GetDisplayContentScale(window->displayID);
|
||||||
|
|
||||||
display_scale = pixel_density * content_scale;
|
display_scale = pixel_density * content_scale;
|
||||||
}
|
}
|
||||||
@@ -2524,7 +2524,7 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props)
|
|||||||
window->opacity = 1.0f;
|
window->opacity = 1.0f;
|
||||||
window->next = _this->windows;
|
window->next = _this->windows;
|
||||||
window->is_destroying = false;
|
window->is_destroying = false;
|
||||||
window->last_displayID = SDL_GetDisplayForWindow(window);
|
window->displayID = SDL_GetDisplayForWindow(window);
|
||||||
window->external_graphics_context = external_graphics_context;
|
window->external_graphics_context = external_graphics_context;
|
||||||
window->constrain_popup = SDL_GetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN, true);
|
window->constrain_popup = SDL_GetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN, true);
|
||||||
|
|
||||||
|
@@ -1715,7 +1715,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|||||||
case WM_WINDOWPOSCHANGED:
|
case WM_WINDOWPOSCHANGED:
|
||||||
{
|
{
|
||||||
SDL_Window *win;
|
SDL_Window *win;
|
||||||
const SDL_DisplayID original_displayID = data->last_displayID;
|
const SDL_DisplayID original_displayID = data->window->displayID;
|
||||||
const WINDOWPOS *windowpos = (WINDOWPOS *)lParam;
|
const WINDOWPOS *windowpos = (WINDOWPOS *)lParam;
|
||||||
bool iconic;
|
bool iconic;
|
||||||
bool zoomed;
|
bool zoomed;
|
||||||
@@ -1790,9 +1790,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|||||||
WIN_UpdateClipCursor(data->window);
|
WIN_UpdateClipCursor(data->window);
|
||||||
|
|
||||||
// Update the window display position
|
// Update the window display position
|
||||||
data->last_displayID = SDL_GetDisplayForWindow(data->window);
|
if (data->window->displayID != original_displayID) {
|
||||||
|
|
||||||
if (data->last_displayID != original_displayID) {
|
|
||||||
// Display changed, check ICC profile
|
// Display changed, check ICC profile
|
||||||
WIN_UpdateWindowICCProfile(data->window, true);
|
WIN_UpdateWindowICCProfile(data->window, true);
|
||||||
}
|
}
|
||||||
|
@@ -391,7 +391,6 @@ static bool SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwn
|
|||||||
data->last_pointer_update = (LPARAM)-1;
|
data->last_pointer_update = (LPARAM)-1;
|
||||||
data->videodata = videodata;
|
data->videodata = videodata;
|
||||||
data->initializing = true;
|
data->initializing = true;
|
||||||
data->last_displayID = window->last_displayID;
|
|
||||||
data->hint_erase_background_mode = GetEraseBackgroundModeHint();
|
data->hint_erase_background_mode = GetEraseBackgroundModeHint();
|
||||||
|
|
||||||
|
|
||||||
|
@@ -91,7 +91,6 @@ struct SDL_WindowData
|
|||||||
RECT cursor_ctrlock_rect; // this is Windows-specific, but probably does not need to be per-window
|
RECT cursor_ctrlock_rect; // this is Windows-specific, but probably does not need to be per-window
|
||||||
bool mouse_tracked;
|
bool mouse_tracked;
|
||||||
bool destroy_parent_with_window;
|
bool destroy_parent_with_window;
|
||||||
SDL_DisplayID last_displayID;
|
|
||||||
WCHAR *ICMFileName;
|
WCHAR *ICMFileName;
|
||||||
SDL_WindowEraseBackgroundMode hint_erase_background_mode;
|
SDL_WindowEraseBackgroundMode hint_erase_background_mode;
|
||||||
bool taskbar_button_created;
|
bool taskbar_button_created;
|
||||||
|
@@ -742,7 +742,7 @@ bool X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properties
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (window->undefined_x && window->undefined_y &&
|
if (window->undefined_x && window->undefined_y &&
|
||||||
window->last_displayID == SDL_GetPrimaryDisplay()) {
|
window->displayID == SDL_GetPrimaryDisplay()) {
|
||||||
undefined_position = true;
|
undefined_position = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user