-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDL_CreateWindowAndRenderer
does not center window on creation at first in Debian GNU/Linux
#12060
Comments
SDL passes the position to XCreateWindow when initially creating the window, and will correct the window placement after the window is mapped if the window manager decides to initially position it somewhere else (Gnome on XWayland seems to ignore the initial coordinates and places the window in a default position). If the window manager isn't initially placing the window where it is told to, there is nothing SDL can do about that. |
But then why are they different behaviors? If both are supposed to start centered, why do they behave differently? Something doesn’t add up. |
SDL_CreateWindowAndRenderer creates the window in a hidden state, then creates a renderer, then shows the window. Doing it manually in your example creates the window, shows it, hides and destroys it when creating the renderer, then shows it again. Most likely the quick show->hide->show cycle in the latter case hides the initial repositioning. If you add SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN, true) to the window properties, then call SDL_ShowWindow() after creating the renderer, does the flicker occur? |
Yes, it works that way. But I thought the behavior of |
Hmm, it does seem that we are forcing the window position in a case where we shouldn't be in the X11 driver, as SDL_CreateWindowAndRenderer leaves the window position as "undefined". We request that it should be centered when creating the window in that case, but an undefined position means the window manager can ultimately put it where it wants, so it's being placed elsewhere first then later moved, which results in the flicker. We shouldn't be moving it to the center in that case. In your second example, you explicitly tell it to center the window, so it's initially properly centered, resulting in no flicker. Also, the hint in your first example, |
Description:
When using
SDL_CreateWindowAndRenderer
, the window does not start centered on the screen. Instead, it first appears in a default position and then centers itself shortly after. Additionally, there doesn't seem to be a way to set the initial window position directly through this function. In contrast, usingSDL_CreateWindowWithProperties
correctly centers the window from the moment it is created.Steps to reproduce:
SDL_CreateWindowAndRenderer
.Expected behavior:
The window should be centered on the screen immediately upon creation without any initial positioning offset.
Actual behavior:
The window initially appears at a default position and then moves to the center of the screen shortly after creation.
Code examples:
Issue Scenario (
SDL_CreateWindowAndRenderer
centers after creation):Expected behavior scenario (
SDL_CreateWindowWithProperties
centers immediately):Environment:
Hardware:
Videos:
The text was updated successfully, but these errors were encountered: