SDL2 and Multiple Screens in Linux |
errissa
|
I finally had some time to look through SDL to see if I could figure why specifying the display doesn't work.
The problem appears to be that the display number doesn't propagate past SDL_CreateWindow (SDL_video.c:1185) so when X11_CreateWindow (SDL_x11window.c:330) calls SDL_GetDisplayForWindow to get the SDL_DisplayData it always gets back the DisplayData for Display 0. I'm using testwm2 to test this. When I run testwm2 --display 1 this is what happens... 1) In SDL_CreateWindow window->x and window->y initially gets set to the x,y position with the display number embedded. 2) SDL_GetDisplayWindow returns the SDL_VideoDisplay structure for Display 1 as expected since window->x and window->y have the display number embedded. 3) window->x and window->y now get set so that the window will be centered on the display. In my case, that's x=640, y=360. 4) When X11_CreateWindow gets called window now has x and y set to 640,360, i.e., there's no display number embedded anymore. 5) X11_CreateWindow calls SDL_GetDisplayForWindow to get the SDL_DisplayData from which it gets the screen number. 6) In SDL_GetDisplayForWindowIndex the checks for the embedded display number fail, of course, then the display is chosen by which display encloses the center point of the window. This check succeeds for display 0 and immediately returns. On my setup I have two graphics cards connected to two separate displays and the X server is configured for two separate X screens. So as far as SDL is concerned I have two displays with bounds of 0,0-2560,1440 and 0,0-1920,1200. The check in step 6 will always select that first 2560x1440 display (assuming positive value of x,y). My guess is that the way code is setup now works fine for TwinView or Xinerama but it seems to me to be broken for separate X screens. |
|||||||||||
|