Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py-sdl2 does not honor the DISPLAY environment variable from X Protocol #182

Open
drpeabody opened this issue May 12, 2021 · 0 comments
Open

Comments

@drpeabody
Copy link

The DISPLAY Environment Variable is used by all the applications that know about the X Protocol to find which X Server to connect to. SDL2 Libraries in other languages use this variable properly and work fine in case of multiple X Servers etc. However PySDL2 does not work if there is a fully functional X Sever on DISPLAY=:1 instead of DISPLAY=:0

To test this, we can run a simple virtual X Server in the background:
$ Xvfb :1 -s '-screen 0 1920x1080x24 +iglx' &

Next we can see that SDL_Init() fails:

$ export DISPLAY=:1
$ python
>>> import sdl2
>>> sdl2.SDL_Init()
-1
>>> sdl2.SDL_GetError(sdl2.SDL_INIT_EVERYTHING)
'No available video device'

In contrast, SDL works when default DISPLAY is used:

$ Xvfb :0 -s '-screen 0 1920x1080x24 +iglx' &

Next we can see that SDL_Init() fails:

$ export DISPLAY=:0
$ python
>>> import sdl2
>>> sdl2.SDL_Init(sdl2.SDL_INIT_EVERYTHING)
0
>>> sdl2.SDL_GetError()
''

This issue was found after building SDL2 from source with various combinations of build flags and after a week of wondering why SDL2 could not find the X server, as the X server logs remained empty all the while. All Applications that use X Servers respect this environment variable as it allows applications to work in scenarios where different X servers configured with different settings need to be run at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant