mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-25 14:45:36 +00:00
SDL_SetWindowPosition respects display num for SDL_WINDOWPOS_CENTERED_DISPLAY.
This allows for this kind of code in an application: int monitorID = 1; // the second monitor! SDL_SetWindowPosition(sdlWin, SDL_WINDOWPOS_CENTERED_DISPLAY(monitorID), SDL_WINDOWPOS_CENTERED_DISPLAY(monitorID)); Fixes Bugzilla #2849.
This commit is contained in:
parent
aefcd86dea
commit
635a369c9d
|
@ -1607,13 +1607,14 @@ SDL_SetWindowPosition(SDL_Window * window, int x, int y)
|
||||||
CHECK_WINDOW_MAGIC(window,);
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
|
||||||
if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) {
|
if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) {
|
||||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
int displayIndex = (x & 0xFFFF);
|
||||||
int displayIndex;
|
|
||||||
SDL_Rect bounds;
|
SDL_Rect bounds;
|
||||||
|
if (displayIndex > _this->num_displays) {
|
||||||
|
displayIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_zero(bounds);
|
SDL_zero(bounds);
|
||||||
|
|
||||||
displayIndex = SDL_GetIndexOfDisplay(display);
|
|
||||||
SDL_GetDisplayBounds(displayIndex, &bounds);
|
SDL_GetDisplayBounds(displayIndex, &bounds);
|
||||||
if (SDL_WINDOWPOS_ISCENTERED(x)) {
|
if (SDL_WINDOWPOS_ISCENTERED(x)) {
|
||||||
x = bounds.x + (bounds.w - window->w) / 2;
|
x = bounds.x + (bounds.w - window->w) / 2;
|
||||||
|
|
Loading…
Reference in a new issue