aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-09-28 18:52:31 +0200
committerSven Gothel <[email protected]>2012-09-28 18:52:31 +0200
commite4176f4e76f519b3599ad557210def3d35266e7b (patch)
tree1cb39ae2532b17ff5e1fd90a43198ce986878f26 /src/nativewindow
parent54f79e402ddb87de9caa3297228cbd16c452cfb4 (diff)
NativeWindow/X11 + NEWT/X11: Cache 'isXineramaEnabled()' to reduce X11 server roundtrips.
Diffstat (limited to 'src/nativewindow')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java9
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java10
2 files changed, 10 insertions, 9 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java
index 2e4099c1b..142bb99e3 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java
@@ -46,6 +46,7 @@ import javax.media.nativewindow.ToolkitLock;
public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneable {
final boolean handleOwner;
+ final boolean isXineramaEnabled;
/** Constructs a new X11GraphicsDevice corresponding to the given connection and default
* {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#getDefaultToolkitLock(String)}.<br>
@@ -56,6 +57,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl
public X11GraphicsDevice(String connection, int unitID) {
super(NativeWindowFactory.TYPE_X11, connection, unitID);
handleOwner = false;
+ isXineramaEnabled = false;
}
/** Constructs a new X11GraphicsDevice corresponding to the given native display handle and default
@@ -69,6 +71,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl
throw new NativeWindowException("null display");
}
handleOwner = owner;
+ isXineramaEnabled = X11Util.XineramaIsEnabled(this);
}
/**
@@ -82,7 +85,9 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl
throw new NativeWindowException("null display");
}
handleOwner = owner;
+ isXineramaEnabled = X11Util.XineramaIsEnabled(this);
}
+
private static int getDefaultScreenImpl(long dpy) {
return X11Lib.DefaultScreen(dpy);
@@ -114,6 +119,10 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl
return X11Lib.DefaultVisualID(display, getDefaultScreenImpl(display));
}
+ public final boolean isXineramaEnabled() {
+ return isXineramaEnabled;
+ }
+
@Override
public Object clone() {
return super.clone();
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java
index 7ab5bd6aa..fa57124fb 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java
@@ -48,7 +48,7 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl
/** Constructs a new X11GraphicsScreen corresponding to the given native screen index. */
public X11GraphicsScreen(X11GraphicsDevice device, int screen) {
- super(device, fetchScreen(device, screen));
+ super(device, device.isXineramaEnabled() ? 0 : screen);
}
public static AbstractGraphicsScreen createScreenDevice(long display, int screenIdx, boolean owner) {
@@ -61,14 +61,6 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl
return X11Lib.DefaultVisualID(getDevice().getHandle(), getIndex());
}
- private static int fetchScreen(X11GraphicsDevice device, int screen) {
- // It still could be an AWT hold handle ..
- if(X11Util.XineramaIsEnabled(device)) {
- screen = 0; // Xinerama -> 1 screen
- }
- return screen;
- }
-
public Object clone() {
return super.clone();
}