Imagine having two screens:
Screen1 (1920x1200) and next to it Screen2 (also 1920x1200)
(the resolutions don’t matter to the problem, they’re just for the example)
When I have a window on Screen2 SDL_GetWindowPosition() returns
something like: (2151, 276) - as I would aspect (the screen starts at
(1920, 0) after all).
However, if the window in Screen2 is fullscreened,
SDL_GetWindowPosition() returns (0, 0) - not (1920, 0) as expected…
Looking at the implementation of SDL_GetWindowPosition() it’s quite
obvious why this happens:
/* Fullscreen windows are always at their display’s origin */
if (window->flags & SDL_WINDOW_FULLSCREEN) {
if (x) {
*x = 0;
}
if (y) {
*y = 0;
}
}
(see [1])
When I last checked, SDL_Window.x and .y even contained the expected
values (not accessible from the outside, as SDL_Window’s details are not
exposed to the user), so at least on Linux/X11 it would work to just
remove that special case for SDL_WINDOW_FULLSCREEN.
I don’t know why this behavior was introduced initially - maybe a SDL1.2
leftover when there only was one screen, maybe other (non-X11) platforms
make it hard to get the actual window position in fullscreen, but it
would be nice if this could get fixed.
There is a bugreport for this btw, see [2].
One use case is that SDL_SetGamma() is broken on X11 with Xorg servers
= 1.7 (from 2010), so one has to workaround using xrandr or something
for the whole screen… and without the actual window coordinates it’s
hard to tell which screen that is.
See [3] for the gamma issue (and yeah, this workaround could be done by
SDL…) and [4] for the underlying Xorg bug
bump (now that Steam Dev Days are over ;-))Am 15.01.2014 21:59, schrieb Daniel Gibson:
Imagine having two screens:
Screen1 (1920x1200) and next to it Screen2 (also 1920x1200)
(the resolutions don’t matter to the problem, they’re just for the example)
When I have a window on Screen2 SDL_GetWindowPosition() returns
something like: (2151, 276) - as I would aspect (the screen starts at
(1920, 0) after all).
However, if the window in Screen2 is fullscreened,
SDL_GetWindowPosition() returns (0, 0) - not (1920, 0) as expected…
Looking at the implementation of SDL_GetWindowPosition() it’s quite
obvious why this happens:
/* Fullscreen windows are always at their display’s origin */
if (window->flags & SDL_WINDOW_FULLSCREEN) {
if (x) {
*x = 0;
}
if (y) {
*y = 0;
}
}
(see [1])
When I last checked, SDL_Window.x and .y even contained the expected
values (not accessible from the outside, as SDL_Window’s details are not
exposed to the user), so at least on Linux/X11 it would work to just
remove that special case for SDL_WINDOW_FULLSCREEN.
I don’t know why this behavior was introduced initially - maybe a SDL1.2
leftover when there only was one screen, maybe other (non-X11) platforms
make it hard to get the actual window position in fullscreen, but it
would be nice if this could get fixed.
There is a bugreport for this btw, see [2].
One use case is that SDL_SetGamma() is broken on X11 with Xorg servers
= 1.7 (from 2010), so one has to workaround using xrandr or something
for the whole screen… and without the actual window coordinates it’s
hard to tell which screen that is.
See [3] for the gamma issue (and yeah, this workaround could be done by
SDL…) and [4] for the underlying Xorg bug