aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java14
-rw-r--r--src/newt/classes/jogamp/newt/ScreenImpl.java54
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/X11Screen.java101
-rw-r--r--src/newt/native/X11Screen.c136
5 files changed, 186 insertions, 128 deletions
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index dc2db7f74..c0d79a5d4 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -394,11 +394,12 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
}
public synchronized void setVisibleActionPost(boolean visible, boolean nativeWindowCreated) {
+ long t0;
if(Window.DEBUG_IMPLEMENTATION) {
- String msg = "GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+Thread.currentThread()+", start";
- System.err.println(msg);
- // Exception e1 = new Exception(msg);
- // e1.printStackTrace();
+ t0 = System.nanoTime();
+ System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+Thread.currentThread()+", start");
+ } else {
+ t0 = 0;
}
/* if (nativeWindowCreated && null != context) {
@@ -423,10 +424,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
context.setContextCreationFlags(additionalCtxCreationFlags);
}
if(Window.DEBUG_IMPLEMENTATION) {
- String msg = "GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+Thread.currentThread()+", fin";
- System.err.println(msg);
- //Exception e1 = new Exception(msg);
- //e1.printStackTrace();
+ System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+Thread.currentThread()+", fin: dt "+ (System.nanoTime()-t0)/1e6 +"ms");
}
}
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index a6bd960b7..6c78a9653 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -74,7 +74,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
protected static volatile boolean usrSizeQueried = false;
private static AccessControlContext localACC = AccessController.getContext();
private ArrayList<ScreenModeListener> referencedScreenModeListener = new ArrayList<ScreenModeListener>();
- long t0; // creationTime
+ private long tCreated; // creationTime
static {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@@ -177,21 +177,26 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
public synchronized final void createNative()
throws NativeWindowException
- {
+ {
if(null == aScreen) {
if(DEBUG) {
+ tCreated = System.nanoTime();
System.err.println("Screen.createNative() START ("+DisplayImpl.getThreadName()+", "+this+")");
+ } else {
+ tCreated = 0;
}
- t0 = System.currentTimeMillis();
+
display.addReference();
+
createNativeImpl();
if(null == aScreen) {
throw new NativeWindowException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen");
}
+
initScreenModeStatus();
updateVirtualScreenOriginAndSize();
if(DEBUG) {
- System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+")");
+ System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+"), total "+ (System.nanoTime()-tCreated)/1e6 +"ms");
}
synchronized(screenList) {
screensActive++;
@@ -361,7 +366,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
ScreenMode smU = getScreenModesOrig().get(screenMode); // unify via value hash
if(smU.equals(smC)) {
if(DEBUG) {
- System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): 0.0 is-current (skip) "+smU+" == "+smC);
+ System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tCreated)+"): 0.0 is-current (skip) "+smU+" == "+smC);
}
return true;
}
@@ -372,32 +377,26 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
boolean success;
sms.lock();
try {
- long t0=0, t1=0;
+ final long tStart;
if(DEBUG) {
- System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): 0.0 "+smU);
- t0 = System.currentTimeMillis();
- }
-
+ tStart = System.nanoTime();
+ } else {
+ tStart = 0;
+ }
+
sms.fireScreenModeChangeNotify(smU);
-
if(DEBUG) {
- System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): 0.1 "+smU);
- t1 = System.currentTimeMillis();
+ System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): fireScreenModeChangeNotify() "+smU);
}
- success = setCurrentScreenModeImpl(smU);
-
+ success = setCurrentScreenModeImpl(smU);
if(DEBUG) {
- t1 = System.currentTimeMillis() - t1;
- System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): X.0 "+smU+", success: "+success);
+ System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+smU+", success: "+success);
}
- sms.fireScreenModeChanged(smU, success);
-
+ sms.fireScreenModeChanged(smU, success);
if(DEBUG) {
- t0 = System.currentTimeMillis() - t0;
- System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): X.X "+smU+", success: "+success+
- " - dt0 "+t0+"ms, dt1 "+t1+"ms");
+ System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): X.X "+smU+", success: "+success);
}
} finally {
sms.unlock();
@@ -514,6 +513,14 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
}
private ScreenModeStatus initScreenModeStatus() {
+ long t0;
+ if(DEBUG) {
+ t0 = System.nanoTime();
+ System.err.println("Screen.initScreenModeStatus() START ("+DisplayImpl.getThreadName()+", "+this+")");
+ } else {
+ t0 = 0;
+ }
+
ScreenModeStatus sms;
ScreenModeStatus.lockScreenModeStatus();
try {
@@ -545,6 +552,9 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
} finally {
ScreenModeStatus.unlockScreenModeStatus();
}
+ if(DEBUG) {
+ System.err.println("Screen.initScreenModeStatus() END dt "+ (System.nanoTime()-t0)/1e6 +"ms");
+ }
return sms;
}
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 9d15ae8c7..62e42c185 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -273,9 +273,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
private boolean createNative() {
+ long tStart;
if(DEBUG_IMPLEMENTATION) {
+ tStart = System.nanoTime();
System.err.println("Window.createNative() START ("+getThreadName()+", "+this+")");
- }
+ } else {
+ tStart = 0;
+ }
+
if( null != parentWindow &&
NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindow.lockSurface() ) {
throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow);
@@ -322,7 +327,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
((DisplayImpl) screen.getDisplay()).dispatchMessagesNative(); // status up2date
}
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.createNative() END ("+getThreadName()+", "+this+")");
+ System.err.println("Window.createNative() END ("+getThreadName()+", "+this+") total "+ (System.nanoTime()-tStart)/1e6 +"ms");
}
return isNativeValid() ;
}
diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
index ed5ebc04e..9dbac5d7f 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
@@ -175,31 +175,42 @@ public class X11Screen extends ScreenImpl {
protected ScreenMode getCurrentScreenModeImpl() {
return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<ScreenMode>() {
public ScreenMode run(long dpy) {
- int resNumber = getNumScreenModeResolutions0(dpy, screen_idx);
- if(0==resNumber) {
+ long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx);
+ if(0 == screenConfigHandle) {
return null;
}
- int resIdx = getCurrentScreenResolutionIndex0(dpy, screen_idx);
- if(0>resIdx) {
- return null;
- }
- if(resIdx>=resNumber) {
- throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber);
- }
- int[] res = getScreenModeResolution0(dpy, screen_idx, resIdx);
- if(null==res || 0==res.length) {
- return null;
- }
- if(0>=res[0] || 0>=res[1]) {
- throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber);
- }
- int rate = getCurrentScreenRate0(dpy, screen_idx);
- if(0>rate) {
- return null;
- }
- int rot = getCurrentScreenRotation0(dpy, screen_idx);
- if(0>rot) {
- return null;
+ int[] res;
+ int rate, rot;
+ try {
+ int resNumber = getNumScreenModeResolutions0(dpy, screen_idx);
+ if(0==resNumber) {
+ return null;
+ }
+
+ int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle);
+ if(0>resIdx) {
+ return null;
+ }
+ if(resIdx>=resNumber) {
+ throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber);
+ }
+ res = getScreenModeResolution0(dpy, screen_idx, resIdx);
+ if(null==res || 0==res.length) {
+ return null;
+ }
+ if(0>=res[0] || 0>=res[1]) {
+ throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber);
+ }
+ rate = getCurrentScreenRate0(screenConfigHandle);
+ if(0>rate) {
+ return null;
+ }
+ rot = getCurrentScreenRotation0(screenConfigHandle);
+ if(0>rot) {
+ return null;
+ }
+ } finally {
+ freeScreenConfiguration0(screenConfigHandle);
}
int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL];
int i = 0;
@@ -226,21 +237,30 @@ public class X11Screen extends ScreenImpl {
boolean done = runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<Boolean>() {
public Boolean run(long dpy) {
boolean done = false;
- int resNumber = getNumScreenModeResolutions0(dpy, screen_idx);
- int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx);
- if(0>resIdx || resIdx>=resNumber) {
- throw new RuntimeException("Invalid resolution index: ! 0 < "+resIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode);
+ long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx);
+ if(0 == screenConfigHandle) {
+ return Boolean.valueOf(done);
}
-
- final int f = screenMode.getMonitorMode().getRefreshRate();
- final int r = screenMode.getRotation();
- if( setCurrentScreenModeStart0(dpy, screen_idx, resIdx, f, r) ) {
- while(!done && System.currentTimeMillis()-t0 < SCREEN_MODE_CHANGE_TIMEOUT) {
- done = setCurrentScreenModePollEnd0(dpy, screen_idx, resIdx, f, r);
- if(!done) {
- try { Thread.sleep(10); } catch (InterruptedException e) { }
+ try {
+ int resNumber = getNumScreenModeResolutions0(dpy, screen_idx);
+ int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx);
+ if(0>resIdx || resIdx>=resNumber) {
+ throw new RuntimeException("Invalid resolution index: ! 0 < "+resIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode);
+ }
+
+ final int f = screenMode.getMonitorMode().getRefreshRate();
+ final int r = screenMode.getRotation();
+
+ if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resIdx, f, r) ) {
+ while(!done && System.currentTimeMillis()-t0 < SCREEN_MODE_CHANGE_TIMEOUT) {
+ done = setCurrentScreenModePollEnd0(dpy, screen_idx, resIdx, f, r);
+ if(!done) {
+ try { Thread.sleep(10); } catch (InterruptedException e) { }
+ }
}
}
+ } finally {
+ freeScreenConfiguration0(screenConfigHandle);
}
return Boolean.valueOf(done);
}
@@ -321,11 +341,14 @@ public class X11Screen extends ScreenImpl {
private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index);
- private static native int getCurrentScreenResolutionIndex0(long display, int screen_index);
- private static native int getCurrentScreenRate0(long display, int screen_index);
- private static native int getCurrentScreenRotation0(long display, int screen_index);
+ private static native long getScreenConfiguration0(long display, int screen_index);
+ private static native void freeScreenConfiguration0(long screenConfiguration);
+
+ private static native int getCurrentScreenResolutionIndex0(long screenConfiguration);
+ private static native int getCurrentScreenRate0(long screenConfiguration);
+ private static native int getCurrentScreenRotation0(long screenConfiguration);
/** needs own Display connection for XRANDR event handling */
- private static native boolean setCurrentScreenModeStart0(long display, int screen_index, int mode_index, int freq, int rot);
+ private static native boolean setCurrentScreenModeStart0(long display, int screen_index, long screenConfiguration, int mode_index, int freq, int rot);
private static native boolean setCurrentScreenModePollEnd0(long display, int screen_index, int mode_index, int freq, int rot);
}
diff --git a/src/newt/native/X11Screen.c b/src/newt/native/X11Screen.c
index 4dcb8f6f1..698eed89d 100644
--- a/src/newt/native/X11Screen.c
+++ b/src/newt/native/X11Screen.c
@@ -26,8 +26,15 @@
* or implied, of JogAmp Community.
*/
+// #define VERBOSE_ON 1
+// #define DBG_PERF 1
+
#include "X11Common.h"
+#ifdef DBG_PERF
+ #include "timespec.h"
+#endif
+
/*
* Class: jogamp_newt_driver_x11_X11Screen
* Method: GetScreen
@@ -163,16 +170,31 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getNumScreenModeRes
(JNIEnv *env, jclass clazz, jlong display, jint scrn_idx)
{
Display *dpy = (Display *) (intptr_t) display;
+#ifdef DBG_PERF
+ struct timespec t0, t1, td;
+ long td_ms;
+ timespec_now(&t0);
+#endif
if(False == NewtScreen_hasRANDR(dpy)) {
DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getNumScreenModeResolutions0: RANDR not available\n");
return 0;
}
+#ifdef DBG_PERF
+ timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td);
+ fprintf(stderr, "X11Screen_getNumScreenModeResolution0.1: %ld ms\n", td_ms); fflush(NULL);
+#endif
+
int num_sizes;
XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions
- DBG_PRINT("getNumScreenModeResolutions0: %d\n", num_sizes);
+#ifdef DBG_PERF
+ timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td);
+ fprintf(stderr, "X11Screen_getNumScreenModeResolution0.2 (XRRSizes): %ld ms\n", td_ms); fflush(NULL);
+#endif
+
+ DBG_PRINT("getNumScreenModeResolutions0: %p:%d -> %d\n", dpy, (int)scrn_idx, num_sizes);
return num_sizes;
}
@@ -264,27 +286,61 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenModeR
/*
* Class: jogamp_newt_driver_x11_X11Screen
- * Method: getCurrentScreenRate0
- * Signature: (JI)I
+ * Method: getScreenConfiguration0
+ * Signature: (JI)J
*/
-JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRate0
- (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx)
+JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenConfiguration0
+ (JNIEnv *env, jclass clazz, jlong display, jint screen_idx)
{
Display *dpy = (Display *) (intptr_t) display;
- Window root = RootWindow(dpy, (int)scrn_idx);
-
+ Window root = RootWindow(dpy, (int)screen_idx);
+#ifdef DBG_PERF
+ struct timespec t0, t1, td;
+ long td_ms;
+ timespec_now(&t0);
+#endif
+
if(False == NewtScreen_hasRANDR(dpy)) {
- DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRate0: RANDR not available\n");
- return -1;
+ DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getScreenConfiguration0: RANDR not available\n");
+ return 0;
}
+#ifdef DBG_PERF
+ timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td);
+ fprintf(stderr, "X11Screen_getScreenConfiguration0.1: %ld ms\n", td_ms); fflush(NULL);
+#endif
// get current resolutions and frequencies
XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root);
- short original_rate = XRRConfigCurrentRate(conf);
+#ifdef DBG_PERF
+ timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td);
+ fprintf(stderr, "X11Screen_getScreenConfiguration0.2 (XRRGetScreenInfo): %ld ms\n", td_ms); fflush(NULL);
+#endif
- //free
- XRRFreeScreenConfigInfo(conf);
+ return (jlong) (intptr_t) conf;
+}
+
+/*
+ * Class: jogamp_newt_driver_x11_X11Screen
+ * Method: freeScreenConfiguration0
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Screen_freeScreenConfiguration0
+ (JNIEnv *env, jclass clazz, jlong screenConfiguration)
+{
+ XRRFreeScreenConfigInfo( (XRRScreenConfiguration *) (intptr_t) screenConfiguration );
+}
+
+/*
+ * Class: jogamp_newt_driver_x11_X11Screen
+ * Method: getCurrentScreenRate0
+ * Signature: (J)I
+ */
+JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRate0
+ (JNIEnv *env, jclass clazz, jlong screenConfiguration)
+{
+ XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration;
+ short original_rate = XRRConfigCurrentRate(conf);
DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate);
return (jint) original_rate;
@@ -293,28 +349,16 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRat
/*
* Class: jogamp_newt_driver_x11_X11Screen
* Method: getCurrentScreenRotation0
- * Signature: (JI)I
+ * Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRotation0
- (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx)
+ (JNIEnv *env, jclass clazz, jlong screenConfiguration)
{
- Display *dpy = (Display *) (intptr_t) display;
- Window root = RootWindow(dpy, (int)scrn_idx);
-
- if(False == NewtScreen_hasRANDR(dpy)) {
- DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRotation0: RANDR not available\n");
- return -1;
- }
-
- //get current resolutions and frequencies
- XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root);
-
+ XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration;
Rotation rotation;
+
XRRConfigCurrentConfiguration(conf, &rotation);
- //free
- XRRFreeScreenConfigInfo(conf);
-
return NewtScreen_XRotation2Degree(env, rotation);
}
@@ -322,60 +366,42 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRot
/*
* Class: jogamp_newt_driver_x11_X11Screen
* Method: getCurrentScreenResolutionIndex0
- * Signature: (JI)I
+ * Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenResolutionIndex0
- (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx)
+ (JNIEnv *env, jclass clazz, jlong screenConfiguration)
{
- Display *dpy = (Display *) (intptr_t) display;
- Window root = RootWindow(dpy, (int)scrn_idx);
+ XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration;
- if(False == NewtScreen_hasRANDR(dpy)) {
- DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenResolutionIndex0: RANDR not available\n");
- return -1;
- }
-
- // get current resolutions and frequency configuration
- XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root);
short original_rate = XRRConfigCurrentRate(conf);
Rotation original_rotation;
SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation);
- //free
- XRRFreeScreenConfigInfo(conf);
-
DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id);
- return (jint)original_size_id;
+ return (jint)original_size_id;
}
/*
* Class: jogamp_newt_driver_x11_X11Screen
* Method: setCurrentScreenModeStart0
- * Signature: (JIIII)Z
+ * Signature: (JIJIII)Z
*/
JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Screen_setCurrentScreenModeStart0
- (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation)
+ (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenConfiguration, jint resMode_idx, jint freq, jint rotation)
{
Display *dpy = (Display *) (intptr_t) display;
+ XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration;
Window root = RootWindow(dpy, (int)screen_idx);
- if(False == NewtScreen_hasRANDR(dpy)) {
- DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_setCurrentScreenModeStart0: RANDR not available\n");
- return JNI_FALSE;
- }
-
int num_sizes;
XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions
- XRRScreenConfiguration *conf;
int rot;
if( 0 > resMode_idx || resMode_idx >= num_sizes ) {
NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes);
}
- conf = XRRGetScreenInfo(dpy, root);
-
switch(rotation) {
case 0:
rot = RR_Rotate_0;
@@ -402,10 +428,6 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Screen_setCurrentScree
XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime);
XSync(dpy, False);
- //free
- XRRFreeScreenConfigInfo(conf);
- XSync(dpy, False);
-
return JNI_TRUE;
}