diff options
author | Sven Gothel <[email protected]> | 2012-09-17 03:30:36 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-09-17 03:30:36 +0200 |
commit | c0cc74a7d525aaa7eb89f60c836589678053d5fb (patch) | |
tree | 1301922809defd7196e4d8e8fc7e9378efb3a541 /src/nativewindow | |
parent | 3704d1553c9eac8b3d9fb1e24b9a513cb362b092 (diff) |
Fixes Bug 615 - X11: Use proper screen index/name for shared resources and device denominated 'mutable' surfaces (dummy, offscreen, ..)
Fix follows findings of Rob Hatcherson, but instead of parsing the display connection ourself
we use the X11 macro 'DefaultScreen(display)'
See <http://tronche.com/gui/x/xlib/display/opening.html#Display>
"The screen number specified in the display_name argument is returned by the DefaultScreen() macro
(or the XDefaultScreen() function)."
Since I currently have no two-head X11 setup here, only xinerama via virtualbox,
pls test / validate.
Note: One Display connection may span multiple screens, i.e.:
display 'lala:0.1' may span from screen 1 - 3 (non xinerama mode)
Discussion:
[1] How to validate whether a screen number belongs to one display connection ?
We can query ScreenCount(display), however it is not clear what the range would be.
[2] With 1 display connection spanning multiple screens, what is/are the proper connection string[s] ?
[3] After all, it seems this ancient configuration really cannot beat a modern setup w/ XRandR
having Xinerama enabled. The latter is the default anyways.
Diffstat (limited to 'src/nativewindow')
-rw-r--r-- | src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java index 5e4d6f41a..152384980 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java @@ -84,11 +84,34 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl handleOwner = owner; } + private static int getDefaultScreenImpl(long dpy) { + return X11Lib.DefaultScreen(dpy); + } + + /** + * Returns the default screen number as referenced by the display connection, i.e. 'somewhere:0.1' -> 1 + * <p> + * Implementation uses the XLib macro <code>DefaultScreen(display)</code>. + * </p> + */ + public int getDefaultScreen() { + final long display = getHandle(); + if(0==display) { + throw new NativeWindowException("null display"); + } + final int ds = getDefaultScreenImpl(display); + if(DEBUG) { + System.err.println(Thread.currentThread().getName() + " - X11GraphicsDevice.getDefaultDisplay() of "+this+": "+ds+", count "+X11Lib.ScreenCount(display)); + } + return ds; + } + public int getDefaultVisualID() { - // It still could be an AWT hold handle .. final long display = getHandle(); - final int scrnIdx = X11Lib.DefaultScreen(display); - return X11Lib.DefaultVisualID(display, scrnIdx); + if(0==display) { + throw new NativeWindowException("null display"); + } + return X11Lib.DefaultVisualID(display, getDefaultScreenImpl(display)); } @Override |