| 1882 | } |
| 1883 | |
| 1884 | void |
| 1885 | SDL_SetWindowPosition(SDL_Window * window, int x, int y) |
| 1886 | { |
| 1887 | CHECK_WINDOW_MAGIC(window,); |
| 1888 | |
| 1889 | if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) { |
| 1890 | int displayIndex = (x & 0xFFFF); |
| 1891 | SDL_Rect bounds; |
| 1892 | if (displayIndex >= _this->num_displays) { |
| 1893 | displayIndex = 0; |
| 1894 | } |
| 1895 | |
| 1896 | SDL_zero(bounds); |
| 1897 | |
| 1898 | SDL_GetDisplayBounds(displayIndex, &bounds); |
| 1899 | if (SDL_WINDOWPOS_ISCENTERED(x)) { |
| 1900 | x = bounds.x + (bounds.w - window->w) / 2; |
| 1901 | } |
| 1902 | if (SDL_WINDOWPOS_ISCENTERED(y)) { |
| 1903 | y = bounds.y + (bounds.h - window->h) / 2; |
| 1904 | } |
| 1905 | } |
| 1906 | |
| 1907 | if ((window->flags & SDL_WINDOW_FULLSCREEN)) { |
| 1908 | if (!SDL_WINDOWPOS_ISUNDEFINED(x)) { |
| 1909 | window->windowed.x = x; |
| 1910 | } |
| 1911 | if (!SDL_WINDOWPOS_ISUNDEFINED(y)) { |
| 1912 | window->windowed.y = y; |
| 1913 | } |
| 1914 | } else { |
| 1915 | if (!SDL_WINDOWPOS_ISUNDEFINED(x)) { |
| 1916 | window->x = x; |
| 1917 | } |
| 1918 | if (!SDL_WINDOWPOS_ISUNDEFINED(y)) { |
| 1919 | window->y = y; |
| 1920 | } |
| 1921 | |
| 1922 | if (_this->SetWindowPosition) { |
| 1923 | _this->SetWindowPosition(_this, window); |
| 1924 | } |
| 1925 | } |
| 1926 | } |
| 1927 | |
| 1928 | void |
| 1929 | SDL_GetWindowPosition(SDL_Window * window, int *x, int *y) |