Maybe I miss something, but I think the behaviour of SDL2, at least on
linux, it’s not coehrent with multiple displays.
With 2 monitor attached on an ubuntu 12.04 box, with the following xrandr
output:
Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 8192 x 8192
VGA1 disconnected (normal left inverted right x axis y axis)
HDMI1 connected 1920x1080+0+0 (normal left inverted right x axis y axis)
510mm x 290mm
1920x1080 60.0*+
1680x1050 60.0
1400x1050 60.0
1600x900 60.0
1280x1024 60.0
1440x900 59.9
1280x800 59.8
1152x864 60.0
1280x720 60.0
1024x768 60.0
800x600 60.3
640x480 60.0
HDMI2 connected 1920x1080+1920+0 (normal left inverted right x axis y axis)
510mm x 290mm
1920x1080 60.0*+
1680x1050 60.0
1400x1050 60.0
1600x900 60.0
1280x1024 75.0 60.0
1440x900 59.9
1280x800 59.8
1152x864 75.0
1280x720 60.0
1024x768 75.1 60.0
832x624 74.6
800x600 75.0 60.3 56.2
640x480 75.0 60.0
720x400 70.1
SDL_GetNumVideoDisplays();
Returns 1
SDL_GetDisplayBounds(0, rect);
Returns (0,0) (3840, 1080)
And this can BE ok, matches with the xrandr idea of “desktop”,
but a call to SDL_CreateWindow with SDL_WINDOW_FULLSCREEN_DESKTOP opens a
full screen window that spawn only one of the two monitors.
Also the behaviour of SDL_CreateWindow can be ok, if SDL provides a way to
"find" the screen that compose a particular part of the desktop, and a way
to go fullscreen in one or the other “monitor”.
At the moment I’ve not found a way also to open a fullscreen_desktop window
on the “left” part of this display…
It always go to the right part of the desktop (the secondary monitor) when
it goes fullscreen. I can position a window everywhere only in "windowed"
mode.
I’ve tried also with a few hints (permuations of
SDL_HINT_VIDEO_X11_XINERAMA, SDL_HINT_VIDEO_X11_XRANDR) to see if I could
change the SDL_GetDisplayBounds() or the SDL_CreateWindow behaviour but
without luck.
Also the macros SDL_WINDOWPOS_UNDEFINED_DISPLAY(X),
SDL_WINDOWPOS_CENTERED_DISPLAY(X) do not work since the display is only one
for the system.
GTK for instance provides this information using a two steps monitor
configuration, and if you move a window inside a particular monitor
(changing his x, y coordinates) and do gdk_window_fullscreen() the window
goes fullscreen on that particular desktop (and this is consistent both on
win32/macosx/linux):
GdkDisplay *display = gdk_display_get_default ();
int num_screen = gdk_display_get_n_screens (display);
std::cerr << "Default Display: " << (void*)display << ", available
screens: " << num_screen;
for (int i = 0; i < num_screen; ++i) {
if (GdkScreen *screen = gdk_display_get_screen(display, i)) {
int mons = gdk_screen_get_n_monitors(screen), j;
std::cerr << "Number of monitors for screen " << (void*)screen
<< ": " << mons;
for (int j = 0; j < mons; ++j) {
GdkRectangle dest;
gdk_screen_get_monitor_geometry(screen, j, &dest);
std::cerr << "Monitor " << (j + 1) << ": " << dest.x <<
’,’ << dest.y << ‘,’ << dest.width << ‘,’ << dest.height;
[…]–
Bye,
Gabry