diff options
author | Sven Gothel <[email protected]> | 2009-10-11 08:10:21 -0700 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-10-11 08:10:21 -0700 |
commit | 7a2103506ba9e570737da6af4e156c3bf06fe765 (patch) | |
tree | dbaba8962f47d9da206a774ce68d96cbe81fdcd4 /src | |
parent | 8f76db4364f66c36780e762e086a18d5cc315363 (diff) |
NativeWindow X11: Lock/Unlock Display if using it
Diffstat (limited to 'src')
-rw-r--r-- | src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java index 360036563..614d26a61 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java +++ b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java @@ -57,11 +57,13 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl /** Creates a new X11GraphicsScreen using a thread local display connection */ public static AbstractGraphicsScreen createDefault() { NativeWindowFactory.getDefaultFactory().getToolkitLock().lock(); + long display = X11Util.getThreadLocalDefaultDisplay(); try { - long display = X11Util.getThreadLocalDefaultDisplay(); + X11Lib.XLockDisplay(display); int scrnIdx = X11Lib.DefaultScreen(display); return createScreenDevice(display, scrnIdx); } finally { + X11Lib.XUnlockDisplay(display); NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock(); } } @@ -69,11 +71,13 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl public long getDefaultVisualID() { // It still could be an AWT hold handle .. NativeWindowFactory.getDefaultFactory().getToolkitLock().lock(); + long display = getDevice().getHandle(); try { - long display = getDevice().getHandle(); + X11Lib.XLockDisplay(display); int scrnIdx = X11Lib.DefaultScreen(display); return X11Lib.DefaultVisualID(display, scrnIdx); } finally { + X11Lib.XUnlockDisplay(display); NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock(); } } @@ -81,14 +85,17 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl private static int fetchScreen(X11GraphicsDevice device, int screen) { // It still could be an AWT hold handle .. NativeWindowFactory.getDefaultFactory().getToolkitLock().lock(); + long display = device.getHandle(); try { - if(!X11Lib.XineramaEnabled(device.getHandle())) { - return screen; + X11Lib.XLockDisplay(display); + if(X11Lib.XineramaEnabled(display)) { + screen = 0; // Xinerama -> 1 screen } } finally { + X11Lib.XUnlockDisplay(display); NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock(); } - return 0; + return screen; } public Object clone() { |