Multiple Displays Don't Work on Linux?

I just downloaded and built SDL2 on Linux (Ubuntu 12.04). My system has two GPUs, one monitor per GPU, and I have them configured as two separate X screens. Typically to run two instances of the same application on separate displays I would just do:

DISPLAY=:0.0 mygreatapp &
DISPLAY=:0.1 mygreatapp &

That doesn’t work with SDL2 programs. I tested this with the testgl2 program and the window always shows up on XScreen 0 regardless of the DISPLAY environment variable or what screen I run in from (i.e., testgl2 appears on Screen 0 even when I run it from a shell on Screen 1). I tried the --display command line option but that made no difference. It still always appears on Screen 0.

I had encountered this about 6 months ago and mentioned it here but got no responses. At the time, I ended up modifying SDL_window struct to include the screen number and modifying SDL_GetWindowDisplayIndex to return the appropriate display index when the screen number was set in the SDL_window struct.

What is the ‘proper’ way to create SDL2 programs on separate X screens? Or is this problem a bug?

For the sake of sanity, does that work with other programs, ie
$ DISPLAY=:0.0 firefox &
$ DISPLAY=:0.1 xterm &

I had a similar problem a while back, and it ended up being my X
configuration and not SDL itself. Unfortunately, it was for an old job,
and I no longer have access to the machine to get my particular X11 config
files.On Thu, Sep 19, 2013 at 11:37 AM, errissa wrote:

**
I just downloaded and built SDL2 on Linux (Ubuntu 12.04). My system has
two GPUs, one monitor per GPU, and I have them configured as two separate X
screens. Typically to run two instances of the same application on separate
displays I would just do:

DISPLAY=:0.0 mygreatapp &
DISPLAY=:0.1 mygreatapp &

That doesn’t work with SDL2 programs. I tested this with the testgl2
program and the window always shows up on XScreen 0 regardless of the
DISPLAY environment variable or what screen I run in from (i.e., testgl2
appears on Screen 0 even when I run it from a shell on Screen 1). I tried
the --display command line option but that made no difference. It still
always appears on Screen 0.

I had encountered this about 6 months ago and mentioned it here but got no
responses. At the time, I ended up modifying SDL_window struct to include
the screen number and modifying SDL_GetWindowDisplayIndex to return the
appropriate display index when the screen number was set in the SDL_window
struct.

What is the ‘proper’ way to create SDL2 programs on separate X screens? Or
is this problem a bug?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

As far as I know SDL can only work on one X screen (the multimonitor
support available is all within the same screen). I’m not even sure if
it’s possible to have a program access two X screens at the same time.

That said, yeah, it would be useful if SDL could let you choose which
X screen to connect to. Not sure if there’s support for that, but I
haven’t seen any documentation indicating so.

Yes, I have tried that and it worked. It’s only the SDL2 programs I’ve tried – the tests that come with SDL and my own program – that don’t work.

I can see why SDL ends up putting all windows on Screen 0. In SDL_video.c in SDL_CreateWindow around line 1225 it computes the x and y positions of the window which drops the upper bits of the the x and y supplied to SDL_CreateWindow where the display number is stored. So, in X11_CreateWindow at line 347 when it calls SDL_GetDisplayForWindow x and y no longer contain the display number and SDL_GetDisplayForWindow skips the code that would have returned the display specified by the upper bits of x and y. So, GetDisplayForWindow returns screen 0.

What I don’t know is if this is intentional for some reason and if there’s another way to get SDL programs to use multiple X Screens.

MrOzBarry wrote:> For the sake of sanity, does that work with other programs, ie$ DISPLAY=:0.0 firefox &

$ DISPLAY=:0.1 xterm &

I had a similar problem a while back, and it ended up being my X configuration and not SDL itself. ?Unfortunately, it was for an old job, and I no longer have access to the machine to get my particular X11 config files.

I want to run multiple instances of my program, one for each GPU/X Screen I have not necessarily access multiple X Screens from a single program.

The simple DISPLAY=:0.x method worked in SDL 1.2 and for a while in SDL1.3 using the SDL_WINDOWPOS_CENTERED_DISPLAY macros worked to put the program on the desired X screen. But at some point the latter method stopped working.

Sik wrote:> As far as I know SDL can only work on one X screen (the multimonitor

support available is all within the same screen). I’m not even sure if
it’s possible to have a program access two X screens at the same time.

That said, yeah, it would be useful if SDL could let you choose which
X screen to connect to. Not sure if there’s support for that, but I
haven’t seen any documentation indicating so.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

How many displays do you get from SDL_GetNumVideoDisplays() ?

2013/9/20 errissa > **

I want to run multiple instances of my program, one for each GPU/X Screen
I have not necessarily access multiple X Screens from a single program.

The simple DISPLAY=:0.x method worked in SDL 1.2 and for a while in SDL1.3
using the SDL_WINDOWPOS_CENTERED_DISPLAY macros worked to put the program
on the desired X screen. But at some point the latter method stopped
working.

Sik wrote:

As far as I know SDL can only work on one X screen (the multimonitor
support available is all within the same screen). I’m not even sure if
it’s possible to have a program access two X screens at the same time.

That said, yeah, it would be useful if SDL could let you choose which
X screen to connect to. Not sure if there’s support for that, but I
haven’t seen any documentation indicating so.


SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Gabriel.

gabomdq wrote:

How many displays do you get from?SDL_GetNumVideoDisplays() ?


Gabriel.

The number you’d expect: 2 on a 2 GPU machine with two X Screens and 4 on my four GPU machine with 4 X Screens.

gabomdq wrote:

How many displays do you get from?SDL_GetNumVideoDisplays() ?


Gabriel.

The number you’d expect: 2 on a 2 GPU machine with two X Screens and 4 on my four GPU machine with 4 X Screens.

gabomdq wrote:

How many displays do you get from?SDL_GetNumVideoDisplays() ?


Gabriel.

The number you’d expect: 2 on a 2 GPU machine with two X Screens and 4 on my four GPU machine with 4 X Screens.