Skip to content

Use XRandR and Xinerama to get display info #1

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

randomnine
Copy link
Owner

Fixes fullscreen behaviour on multiple-monitor systems under Linux.

On Linux, default X11 behaviour seems to describe multiple monitors as a single virtual display (stretched across all physical monitors), so for example it might describe a pair of 1920x1080 monitors as a single 3840x1080 display. Full-screen SDL windows will therefore attempt to cover that 3840x1080 area and stretch across all displays instead of expanding to a single physical screen as they do on Windows and OS X.

SDL_x11modes.c appears to rely on XRandR (or possibly Xinerama) to get information on distinct screens within that virtual display. After enabling both here, fullscreen windows in Linux correctly take full screen on a single monitor.

Compiling with this change requires packages libxrandr-dev, libxinerama-dev and a clean build (when built as part of Lime, at least).

Linux specific. Solves a problem with fullscreen behaviour on multiple-monitor systems.

On Linux, default X11 behaviour seems to describe multiple monitors as a single virtual display (stretched across all physical monitors), so for example it might describe a pair of 1920x1080 monitors as a single 3840x1080 display. Full-screen SDL windows will therefore attempt to cover that 3840x1080 area and stretch across all displays instead of expanding to a single physical screen as they do on Windows and OS X.

SDL_x11modes.c appears to rely on XRandR (or possibly Xinerama) to get information on distinct screens within that virtual display. After enabling both here, fullscreen windows in Linux correctly take full screen on a single monitor.

Compiling requires additional packages libxrandr-dev, libxinerama-dev and a -clean build.
@ruby0x1
Copy link

ruby0x1 commented Nov 28, 2015

can you shield these against a NATIVE_TOOLKIT_SDL_X11_XRANDR define (possibly one for each specific change added) - breaking the default build by third party dependency is not ideal

@randomnine
Copy link
Owner Author

As in, off by default, and requiring a define to enable? Or on by default, but configurable?

For what it's worth, my experience of this was that fullscreen modes would silently break on some Linux systems in my OpenFL game (showing only half the window) and there was no reasonable way to detect when it would break or work around it. It took me several hours to track it back to this, and I'd like to help others get fullscreen that works by default instead of having the same trouble.

@ruby0x1
Copy link

ruby0x1 commented Nov 28, 2015

OpenFL (or whichever framework is including this library) must configure the build against their required dependencies and defines.

The point of native-toolkit libraries is to keep the libraries central, having the defines be on by default adds build dependencies, so they must not be enabled by default.

To be more clear: off by default.
The flag is enabled by the define, set in the xml file of the user (read as:openfl),
before it includes the native-toolkit files.xml dependency.

This is how it works with the native-toolkit libraries.

(To add: having the flag and having the ability to configure it to just work is a great thing! Merging the PR will just require it conform to the patterns defined by native-toolkit libs)

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

Successfully merging this pull request may close these issues.

2 participants