MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / SDL_SetWindowPosition

Function SDL_SetWindowPosition

deps/SDL2/src/video/SDL_video.c:1884–1926  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1882}
1883
1884void
1885SDL_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
1928void
1929SDL_GetWindowPosition(SDL_Window * window, int *x, int *y)

Callers 8

mainFunction · 0.85
FullscreenToFunction · 0.85
SDLTest_CommonEventFunction · 0.85
SDL_SetWindowShapeFunction · 0.85
Win32_ResizeWindowShapeFunction · 0.85
X11_ResizeWindowShapeFunction · 0.85

Calls 1

SDL_GetDisplayBoundsFunction · 0.85

Tested by 4

mainFunction · 0.68
FullscreenToFunction · 0.68
SDLTest_CommonEventFunction · 0.68