1495 void |
1495 void |
1496 SDL_SetWindowPosition(SDL_Window * window, int x, int y) |
1496 SDL_SetWindowPosition(SDL_Window * window, int x, int y) |
1497 { |
1497 { |
1498 CHECK_WINDOW_MAGIC(window, ); |
1498 CHECK_WINDOW_MAGIC(window, ); |
1499 |
1499 |
1500 if (!SDL_WINDOWPOS_ISUNDEFINED(x)) { |
|
1501 window->x = x; |
|
1502 } |
|
1503 if (!SDL_WINDOWPOS_ISUNDEFINED(y)) { |
|
1504 window->y = y; |
|
1505 } |
|
1506 if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) { |
1500 if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) { |
1507 SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); |
1501 SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); |
1508 int displayIndex; |
1502 int displayIndex; |
1509 SDL_Rect bounds; |
1503 SDL_Rect bounds; |
1510 |
1504 |
1511 displayIndex = SDL_GetIndexOfDisplay(display); |
1505 displayIndex = SDL_GetIndexOfDisplay(display); |
1512 SDL_GetDisplayBounds(displayIndex, &bounds); |
1506 SDL_GetDisplayBounds(displayIndex, &bounds); |
1513 if (SDL_WINDOWPOS_ISCENTERED(x)) { |
1507 if (SDL_WINDOWPOS_ISCENTERED(x)) { |
1514 window->x = bounds.x + (bounds.w - window->w) / 2; |
1508 x = bounds.x + (bounds.w - window->w) / 2; |
1515 } |
1509 } |
1516 if (SDL_WINDOWPOS_ISCENTERED(y)) { |
1510 if (SDL_WINDOWPOS_ISCENTERED(y)) { |
1517 window->y = bounds.y + (bounds.h - window->h) / 2; |
1511 y = bounds.y + (bounds.h - window->h) / 2; |
1518 } |
1512 } |
1519 } |
1513 } |
|
1514 |
|
1515 if (!SDL_WINDOWPOS_ISUNDEFINED(x)) { |
|
1516 window->x = x; |
|
1517 } |
|
1518 if (!SDL_WINDOWPOS_ISUNDEFINED(y)) { |
|
1519 window->y = y; |
|
1520 } |
|
1521 |
1520 if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { |
1522 if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { |
1521 if (_this->SetWindowPosition) { |
1523 if (_this->SetWindowPosition) { |
1522 _this->SetWindowPosition(_this, window); |
1524 _this->SetWindowPosition(_this, window); |
1523 } |
1525 } |
1524 SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y); |
1526 SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y); |