Open several SDL windows on multihead X

Hej guys !

I am currently working on a multihead machine, and therefore I was
wondering:
Is it somehow possible to decide which X head SDL should put its window on
?
I know that it is possible to do that by setting the environment variables
before starting the program, but since I can’t change them in the
program (or can I ?), I won’t be able to affect where SDL opens its window
as soon as I am inside the C code …

Thanks for any help ! :slight_smile:

Servus,
Gernot

/-----------------------------W-E-L-C-O-M-E------------------------------
T The Austria <=> Sweden connection… T
| E-Mail: @Gernot_Ziegler H
O Homepage: http://www.lysator.liu.se/~gz E
------------------------------F-U-T-U-R-E-------------------------------/

Is it somehow possible to decide which X head SDL should put its window on
?
I know that it is possible to do that by setting the environment variables
before starting the program, but since I can’t change them in the
program (or can I ?)

you can only select a screen (by setting $DISPLAY) before you call
SDL_Init(), but you can do so from within the program (putenv)

Gernot Ziegler wrote:

I know that it is possible to do that by setting the environment variables
before starting the program, but since I can’t change them in the
program (or can I ?)

putenv might do the trick…
putenv(“DISPLAY=:1”);
would set the display to the :1 display (which is usually the second head…)

you might also consider that if SDL fails to open on the new display that you should revert back to the old one, and then reopen your SDL window/screen and tell the user that it failed…to get the current value of the display there’s of course, getenv(“DISPLAY”) which returns the value of DISPLAY (or NULL if it isn’t set, fancy that).

Cheers,

Jon Atkins (LIM the Long Island Man)