SDL_SetWindowPosition(3)
π SDL_SetWindowPosition(3) π
okay bestie, this one lives in the SDL3 FUNCTIONS section of the SDL3 manual, and it's literally just "hey can u move this window pls" but make it a syscall. πͺβ¨
πΈ NAME πΈ
SDL_SetWindowPosition β ask politely for the window's position to be set. that's it, that's the whole vibe. π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_video.h>
bool SDL_SetWindowPosition(SDL_Window *window, int x, int y);
π¦ DESCRIPTION π¦
so, if the window is in an exclusive fullscreen or maximized state? yeah no, this request just has no effect. the window is booked and busy, it's not taking requests rn. π
but here's the tea: you can use this to reposition fullscreen-desktop windows onto a different display. however (and this is important, bestie, don't skip it), exclusive fullscreen windows are locked to a specific display, so the only way to move those programmatically is through SDL_SetWindowFullscreenMode(). that's the one (and only) door. πͺ
now, on some windowing systems this request is asynchronous, meaning the new coordinates may not have been applied immediately upon the return of this function. like, the function said "k done" but the window is still mid-makeover. if you need the change to be immediate, call SDL_SyncWindow() to block until the changes have actually taken effect. blocking = waiting = patience, iykyk. π«Ά
when the window position changes, an SDL_EVENT_WINDOW_MOVED event gets emitted with the window's new coordinates. but β and this is the plot twist β those new coordinates may not match the exact coordinates you requested, because some windowing systems can restrict the position of the window in certain scenarios (like, say, constraining the position so the window is always within desktop bounds). also, since this is literally just a request, the windowing system can flat-out deny it. not me asking nicely and getting left on read. π
π FUNCTION PARAMETERS π
windowβ the window you wanna reposition. the main character of this operation. πxβ the x coordinate of the window, orSDL_WINDOWPOS_CENTEREDorSDL_WINDOWPOS_UNDEFINED.yβ the y coordinate of the window, orSDL_WINDOWPOS_CENTEREDorSDL_WINDOWPOS_UNDEFINED.
β RETURN VALUE β
returns true on success or false on failure. and if it fails? call SDL_GetError() for more information, bestie, it'll tell you what went wrong. π
π THREAD SAFETY π
this function should only be called on the main thread. no side quests, no background threads, no sneaky little calls from somewhere else. main thread only, periodt. π
π₯ AVAILABILITY π₯
this function is available since SDL 3.2.0. so if you're on something older, no window-moving for you, sorry babe. π
π SEE ALSO π
and that's the whole page, bestie!! πβ¨ written by Simple Directmedia Layer, brought to you by SDL 3.4.18 β go move some windows, you got this, slay. ππ¦
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms