summaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/MonitorModeProps.java2
-rw-r--r--src/newt/classes/jogamp/newt/ScreenImpl.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java25
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/RandR.java23
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/RandR11.java104
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/RandR13.java71
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java37
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java6
8 files changed, 174 insertions, 96 deletions
diff --git a/src/newt/classes/jogamp/newt/MonitorModeProps.java b/src/newt/classes/jogamp/newt/MonitorModeProps.java
index 073a9a355..4e2806118 100644
--- a/src/newt/classes/jogamp/newt/MonitorModeProps.java
+++ b/src/newt/classes/jogamp/newt/MonitorModeProps.java
@@ -272,7 +272,7 @@ public class MonitorModeProps {
* @param cache hash arrays of unique {@link MonitorMode} components and {@link MonitorDevice}s, allowing to avoid duplicates
* @param screen the associated {@link ScreenImpl}
* @param pixelScale pre-fetched current pixel-scale, maybe {@code null} for {@link ScalableSurface#IDENTITY_PIXELSCALE}.
- * @param monitorProperties the input data minus supported modes!
+ * @param monitorProperties the input data inclusive supported modes.
* @param offset the offset to the input data
* @param monitor_idx if not null, returns the index of resulting {@link MonitorDevice} within {@link Cache#monitorDevices}.
* @return {@link MonitorDevice} of the identical (old or new) element in {@link Cache#monitorDevices},
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index c96a2e06e..347ea650e 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -440,7 +440,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
monitor.getMutuableViewportPU(),
monitor.getMutuableViewportWU());
if( DEBUG ) {
- System.err.println("Screen.updateMonitorViewport["+i+"] @ "+Thread.currentThread().getName()+": updated: "+viewportUpdated+
+ System.err.println("Screen.updateMonitorViewport["+Display.toHexString(monitor.getId())+"] @ "+Thread.currentThread().getName()+": updated: "+viewportUpdated+
", PU "+monitor.getViewport()+", WU "+monitor.getViewportInWindowUnits()+
", pixelScale ["+pixelScale[0]+", "+pixelScale[1]+"]");
}
diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java
index 3276f3ed1..81ccdbfcd 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java
@@ -40,7 +40,6 @@ import java.nio.ByteBuffer;
import com.jogamp.nativewindow.AbstractGraphicsDevice;
import com.jogamp.nativewindow.NativeWindowException;
import com.jogamp.nativewindow.util.PixelFormat;
-
import com.jogamp.common.nio.Buffers;
import com.jogamp.nativewindow.x11.X11GraphicsDevice;
@@ -110,7 +109,8 @@ public class DisplayDriver extends DisplayImpl {
try {
final long handle = _aDevice.getHandle();
if(0 != handle) {
- DispatchMessages0(handle, javaObjectAtom, windowDeleteAtom /*, kbdHandle */); // XKB disabled for now
+ DispatchMessages0(handle, javaObjectAtom, windowDeleteAtom /*, kbdHandle */, // XKB disabled for now
+ randr_event_base, randr_error_base);
}
} finally {
_aDevice.unlock();
@@ -120,6 +120,8 @@ public class DisplayDriver extends DisplayImpl {
protected long getJavaObjectAtom() { return javaObjectAtom; }
protected long getWindowDeleteAtom() { return windowDeleteAtom; }
// protected long getKbdHandle() { return kbdHandle; } // XKB disabled for now
+ protected int getRandREventBase() { return randr_event_base; }
+ protected int getRandRErrorBase() { return randr_error_base; }
/** Returns <code>null</code> if !{@link #isNativeValid()}, otherwise the Boolean value of {@link X11GraphicsDevice#isXineramaEnabled()}. */
protected Boolean isXineramaEnabled() { return isNativeValid() ? Boolean.valueOf(((X11GraphicsDevice)aDevice).isXineramaEnabled()) : null; }
@@ -142,14 +144,26 @@ public class DisplayDriver extends DisplayImpl {
private native void CompleteDisplay0(long handle);
- private void displayCompleted(final long javaObjectAtom, final long windowDeleteAtom /*, long kbdHandle */) {
+ private void displayCompleted(final long javaObjectAtom, final long windowDeleteAtom /*, long kbdHandle */,
+ final int randr_event_base, final int randr_error_base) {
this.javaObjectAtom=javaObjectAtom;
this.windowDeleteAtom=windowDeleteAtom;
// this.kbdHandle = kbdHandle; // XKB disabled for now
+ this.randr_event_base = randr_event_base;
+ this.randr_error_base = randr_error_base;
+ }
+ private void sendRRScreenChangeNotify(final long event) {
+ if( null != rAndR ) {
+ rAndR.sendRRScreenChangeNotify(getHandle(), event);
+ }
+ }
+ void registerRandR(final RandR rAndR) {
+ this.rAndR = rAndR;
}
private native void DisplayRelease0(long handle, long javaObjectAtom, long windowDeleteAtom /*, long kbdHandle */); // XKB disabled for now
- private native void DispatchMessages0(long display, long javaObjectAtom, long windowDeleteAtom /* , long kbdHandle */); // XKB disabled for now
+ private native void DispatchMessages0(long display, long javaObjectAtom, long windowDeleteAtom /* , long kbdHandle */, // XKB disabled for now
+ final int randr_event_base, final int randr_error_base);
private static long createPointerIcon(final long display, final Buffer pixels, final int width, final int height, final int hotX, final int hotY) {
final boolean pixels_is_direct = Buffers.isDirect(pixels);
@@ -171,5 +185,8 @@ public class DisplayDriver extends DisplayImpl {
/** X11 Keyboard handle used on EDT */
// private long kbdHandle; // XKB disabled for now
+ private int randr_event_base, randr_error_base;
+
+ private RandR rAndR;
}
diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR.java b/src/newt/classes/jogamp/newt/driver/x11/RandR.java
index 14c9c0856..f45762173 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/RandR.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/RandR.java
@@ -43,6 +43,8 @@ public interface RandR {
public static final VersionNumber version140 = new VersionNumber(1, 4, 0);
VersionNumber getVersion();
+ @Override
+ String toString();
void dumpInfo(final long dpy, final int screen_idx);
@@ -50,7 +52,7 @@ public interface RandR {
* Encapsulate initial device query allowing caching of internal data structures.
* Methods covered:
* <ul>
- * <li>{@link #getMonitorDeviceCount(long, ScreenDriver)}</li>
+ * <li>{@link #getMonitorDeviceIds(long, ScreenDriver)}</li>
* <li>{@link #getAvailableRotations(long, ScreenDriver, int)}</li>
* <li>{@link #getMonitorModeProps(long, ScreenDriver, int)}</li>
* <li>{@link #getCurrentMonitorModeProps(long, ScreenDriver, int)</li>
@@ -67,8 +69,8 @@ public interface RandR {
boolean beginInitialQuery(long dpy, ScreenDriver screen);
void endInitialQuery(long dpy, ScreenDriver screen);
- int getMonitorDeviceCount(final long dpy, final ScreenDriver screen);
- int[] getAvailableRotations(final long dpy, final ScreenDriver screen, final int crt_idx);
+ int[] getMonitorDeviceIds(final long dpy, final ScreenDriver screen);
+ int[] getAvailableRotations(final long dpy, final ScreenDriver screen, final int crt_id);
/**
*
* @param dpy
@@ -77,10 +79,15 @@ public interface RandR {
* @return props w/o actual rotation
*/
int[] getMonitorModeProps(final long dpy, final ScreenDriver screen, final int mode_idx);
- int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, MonitorModeProps.Cache cache, final int crt_idx);
- int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_idx);
- int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_idx);
- boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode);
+ int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, MonitorModeProps.Cache cache, final int crt_id);
+ int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_id);
+ int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_id);
+ /** The device shall be locked, blocking message handling. */
+ boolean setCurrentMonitorModeStart(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode);
+ /** The device must not be locked, allowing message handling. */
+ boolean setCurrentMonitorModeWait(final ScreenDriver screen);
+ /** Invoked from Display's EDT thread for message handling. */
+ void sendRRScreenChangeNotify(final long dpy, final long event);
- public void updateScreenViewport(final long dpy, final ScreenDriver screen, RectangleImmutable viewport);
+ void updateScreenViewport(final long dpy, final ScreenDriver screen, RectangleImmutable viewport);
}
diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java
index e9cb95548..8fd03320a 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java
@@ -40,12 +40,19 @@ import com.jogamp.newt.Screen;
class RandR11 implements RandR {
private static final boolean DEBUG = ScreenDriver.DEBUG;
- RandR11() {
+ private static final int SINGLE_CRT_ID = 0x01;
+
+ private final VersionNumber version;
+
+ RandR11(final VersionNumber version) {
+ this.version = version;
}
@Override
- public final VersionNumber getVersion() {
- return version110;
+ public final VersionNumber getVersion() { return version; }
+ @Override
+ public String toString() {
+ return "RandR11[version "+version+"]";
}
@Override
@@ -104,13 +111,14 @@ class RandR11 implements RandR {
}
@Override
- public int getMonitorDeviceCount(final long dpy, final ScreenDriver screen) {
- return 1;
+ public int[] getMonitorDeviceIds(final long dpy, final ScreenDriver screen) {
+ // RandR11 only supports 1 CRT
+ return new int[] { SINGLE_CRT_ID };
}
@Override
- public int[] getAvailableRotations(final long dpy, final ScreenDriver screen, final int crt_idx) {
- if( 0 < crt_idx ) {
+ public int[] getAvailableRotations(final long dpy, final ScreenDriver screen, final int crt_id) {
+ if( SINGLE_CRT_ID != crt_id ) {
// RandR11 only supports 1 CRT
return null;
}
@@ -171,12 +179,12 @@ class RandR11 implements RandR {
}
@Override
- public int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, final MonitorModeProps.Cache cache, final int crt_idx) {
- if( 0 < crt_idx ) {
+ public int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, final MonitorModeProps.Cache cache, final int crt_id) {
+ if( SINGLE_CRT_ID != crt_id ) {
// RandR11 only supports 1 CRT
return null;
}
- final int[] currentModeProps = getCurrentMonitorModeProps(dpy, screen, crt_idx);
+ final int[] currentModeProps = getCurrentMonitorModeProps(dpy, screen, crt_id);
if( null == currentModeProps) { // disabled
return null;
}
@@ -185,9 +193,9 @@ class RandR11 implements RandR {
final int[] props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES - 1 + allModesCount];
int i = 0;
props[i++] = props.length;
- props[i++] = crt_idx;
+ props[i++] = SINGLE_CRT_ID;
props[i++] = 0; // is-clone
- props[i++] = 0 == crt_idx ? 1 : 0; // is-primary
+ props[i++] = 0 == crt_id ? 1 : 0; // is-primary
props[i++] = widthMM;
props[i++] = heightMM;
props[i++] = 0; // rotated viewport x pixel-units
@@ -207,8 +215,8 @@ class RandR11 implements RandR {
}
@Override
- public int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_idx) {
- if( 0 < crt_idx ) {
+ public int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_id) {
+ if( SINGLE_CRT_ID != crt_id ) {
// RandR11 only supports 1 CRT
return null;
}
@@ -252,8 +260,8 @@ class RandR11 implements RandR {
}
@Override
- public int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_idx) {
- if( 0 < crt_idx ) {
+ public int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_id) {
+ if( SINGLE_CRT_ID != crt_id ) {
// RandR11 only supports 1 CRT
return null;
}
@@ -313,35 +321,63 @@ class RandR11 implements RandR {
}
@Override
- public boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, final MonitorDevice monitor, final MonitorMode mode) {
- final long t0 = System.currentTimeMillis();
- boolean done = false;
+ public boolean setCurrentMonitorModeStart(final long dpy, final ScreenDriver screen, final MonitorDevice monitor, final MonitorMode mode) {
final int screen_idx = screen.getIndex();
final long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx);
if(0 == screenConfigHandle) {
- return Boolean.valueOf(done);
+ return false;
}
+ boolean res = false;
try {
- final int resId = mode.getId();
- if(0>resId || resId>=resolutionCount) {
- throw new RuntimeException("Invalid resolution index: ! 0 < "+resId+" < "+resolutionCount+", "+monitor+", "+mode);
+ final int mode_idx = mode.getId();
+ if(0>mode_idx || mode_idx>=resolutionCount) {
+ throw new RuntimeException("Invalid resolution index: ! 0 < "+mode_idx+" < "+resolutionCount+", "+monitor+", "+mode);
}
- final int f = (int)mode.getRefreshRate(); // simply cut-off, orig is int
- final int r = mode.getRotation();
-
- if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resId, f, r) ) {
- while(!done && System.currentTimeMillis()-t0 < Screen.SCREEN_MODE_CHANGE_TIMEOUT) {
- done = setCurrentScreenModePollEnd0(dpy, screen_idx, resId, f, r);
- if(!done) {
- try { Thread.sleep(10); } catch (final InterruptedException e) { }
- }
- }
+ final int freq = (int)mode.getRefreshRate(); // simply cut-off, orig is int
+ final int rot = mode.getRotation();
+ set_screen_idx = screen_idx;
+ set_mode_idx = mode_idx;
+ set_freq = freq;
+ set_rot = rot;
+ set_done = false;
+ res = setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, mode_idx, freq, rot);
+ if( !res ) {
+ clearSetModeState();
}
} finally {
freeScreenConfiguration0(screenConfigHandle);
}
+ return res;
+ }
+ @Override
+ public boolean setCurrentMonitorModeWait(final ScreenDriver screen) {
+ final long t0 = System.currentTimeMillis();
+ boolean done = false;
+ while(!done && System.currentTimeMillis()-t0 < Screen.SCREEN_MODE_CHANGE_TIMEOUT) {
+ done = set_done;
+ if(!done) {
+ try { Thread.sleep(10); } catch (final InterruptedException e) { }
+ }
+ }
+ clearSetModeState();
return done;
}
+ volatile int set_screen_idx;
+ volatile int set_mode_idx;
+ volatile int set_freq;
+ volatile int set_rot;
+ volatile boolean set_done;
+ @Override
+ public void sendRRScreenChangeNotify(final long dpy, final long event) {
+ set_done = sendRRScreenChangeNotify0(dpy, set_screen_idx, event, set_mode_idx, set_freq, set_rot);
+ }
+ private void clearSetModeState() {
+ set_screen_idx = -1;
+ set_mode_idx = -1;
+ set_freq = 0;
+ set_rot = 0;
+ set_done = false;
+ }
@Override
public final void updateScreenViewport(final long dpy, final ScreenDriver screen, final RectangleImmutable viewport) {
@@ -367,6 +403,6 @@ class RandR11 implements RandR {
/** needs own Display connection for XRANDR event handling */
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);
+ private static native boolean sendRRScreenChangeNotify0(long display, int screen_index, final long event, int mode_index, int freq, int rot);
}
diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java
index 2f7110b5c..95bff0118 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java
@@ -47,13 +47,17 @@ import com.jogamp.newt.MonitorMode;
*/
class RandR13 implements RandR {
private static final boolean DEBUG = ScreenDriver.DEBUG;
+ private final VersionNumber version;
- RandR13() {
+ RandR13(final VersionNumber version) {
+ this.version = version;
}
@Override
- public final VersionNumber getVersion() {
- return version130;
+ public final VersionNumber getVersion() { return version; }
+ @Override
+ public String toString() {
+ return "RandR13[version "+version+"]";
}
@Override
@@ -113,16 +117,16 @@ class RandR13 implements RandR {
}
}
- private final long getMonitorInfoHandle(final long dpy, final int screen_idx, final long screenResources, final int monitor_idx) {
+ private final long getMonitorInfoHandle(final long dpy, final int screen_idx, final long screenResources, final int crt_id) {
if( null != crtInfoHandleMap ) {
- long h = crtInfoHandleMap.get(monitor_idx);
+ long h = crtInfoHandleMap.get(crt_id);
if( 0 == h ) {
- h = getMonitorInfoHandle0(dpy, screen_idx, screenResources, monitor_idx);
- crtInfoHandleMap.put(monitor_idx, h);
+ h = getMonitorInfoHandle0(dpy, screen_idx, screenResources, crt_id);
+ crtInfoHandleMap.put(crt_id, h);
}
return h;
} else {
- return getMonitorInfoHandle0(dpy, screen_idx, screenResources, monitor_idx);
+ return getMonitorInfoHandle0(dpy, screen_idx, screenResources, crt_id);
}
}
private final void releaseMonitorInfoHandle(final long monitorInfoHandle) {
@@ -132,22 +136,22 @@ class RandR13 implements RandR {
}
@Override
- public int getMonitorDeviceCount(final long dpy, final ScreenDriver screen) {
+ public int[] getMonitorDeviceIds(final long dpy, final ScreenDriver screen) {
final int screen_idx = screen.getIndex();
final long screenResources = getScreenResourceHandle(dpy, screen_idx);
try {
- return getMonitorDeviceCount0(screenResources);
+ return getMonitorDeviceIds0(screenResources);
} finally {
releaseScreenResourceHandle(screenResources);
}
}
@Override
- public int[] getAvailableRotations(final long dpy, final ScreenDriver screen, final int crt_idx) {
+ public int[] getAvailableRotations(final long dpy, final ScreenDriver screen, final int crt_id) {
final int screen_idx = screen.getIndex();
final long screenResources = getScreenResourceHandle(dpy, screen_idx);
try {
- final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_idx);
+ final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_id);
try {
final int[] availRotations = getAvailableRotations0(monitorInfo);
if(null==availRotations || 0==availRotations.length) {
@@ -174,13 +178,13 @@ class RandR13 implements RandR {
}
@Override
- public int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, final MonitorModeProps.Cache cache, final int crt_idx) {
+ public int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, final MonitorModeProps.Cache cache, final int crt_id) {
final int screen_idx = screen.getIndex();
final long screenResources = getScreenResourceHandle(dpy, screen_idx);
try {
- final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_idx);
+ final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_id);
try {
- return getMonitorDevice0(dpy, screenResources, monitorInfo, crt_idx);
+ return getMonitorDevice0(dpy, screenResources, monitorInfo, crt_id);
} finally {
releaseMonitorInfoHandle(monitorInfo);
}
@@ -190,11 +194,11 @@ class RandR13 implements RandR {
}
@Override
- public int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_idx) {
+ public int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_id) {
final int screen_idx = screen.getIndex();
final long screenResources = getScreenResourceHandle(dpy, screen_idx);
try {
- final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_idx);
+ final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_id);
try {
return getMonitorViewport0(monitorInfo);
} finally {
@@ -206,11 +210,11 @@ class RandR13 implements RandR {
}
@Override
- public int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_idx) {
+ public int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_id) {
final int screen_idx = screen.getIndex();
final long screenResources = getScreenResourceHandle(dpy, screen_idx);
try {
- final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_idx);
+ final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_id);
try {
return getMonitorCurrentMode0(screenResources, monitorInfo);
} finally {
@@ -222,15 +226,15 @@ class RandR13 implements RandR {
}
@Override
- public boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, final MonitorDevice monitor, final MonitorMode mode) {
+ public boolean setCurrentMonitorModeStart(final long dpy, final ScreenDriver screen, final MonitorDevice monitor, final MonitorMode mode) {
final int screen_idx = screen.getIndex();
final long screenResources = getScreenResourceHandle(dpy, screen_idx);
final boolean res;
try {
final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, monitor.getId());
try {
- res = setMonitorMode0(dpy, screenResources, monitorInfo, monitor.getId(), mode.getId(), mode.getRotation(),
- -1, -1); // no fixed position!
+ res = setMonitorMode0(dpy, screen_idx, screenResources, monitorInfo, monitor.getId(),
+ mode.getId(), mode.getRotation(), -1, -1); // no fixed position!
} finally {
releaseMonitorInfoHandle(monitorInfo);
}
@@ -239,6 +243,15 @@ class RandR13 implements RandR {
}
return res;
}
+ @Override
+ public void sendRRScreenChangeNotify(final long dpy, final long event) {
+ sendRRScreenChangeNotify0(dpy, event);
+ }
+ @Override
+ public boolean setCurrentMonitorModeWait(final ScreenDriver screen) {
+ // RandR13 set command waits until done ..
+ return true;
+ }
@Override
public final void updateScreenViewport(final long dpy, final ScreenDriver screen, final RectangleImmutable viewport) {
@@ -255,9 +268,9 @@ class RandR13 implements RandR {
private static native void freeScreenResources0(long screenResources);
private static native void dumpInfo0(long display, int screen_index, long screenResources);
- private static native int getMonitorDeviceCount0(long screenResources);
+ private static native int[] getMonitorDeviceIds0(long screenResources);
- private static native long getMonitorInfoHandle0(long display, int screen_index, long screenResources, int monitor_index);
+ private static native long getMonitorInfoHandle0(long display, int screen_index, long screenResources, int crtc_id);
private static native void freeMonitorInfoHandle0(long monitorInfoHandle);
private static native int[] getAvailableRotations0(long monitorInfo);
@@ -266,8 +279,12 @@ class RandR13 implements RandR {
private static native int[] getMonitorMode0(long screenResources, int mode_index);
private static native int[] getMonitorCurrentMode0(long screenResources, long monitorInfo);
- private static native int[] getMonitorDevice0(long display, long screenResources, long monitorInfo, int monitor_idx);
+ private static native int[] getMonitorDevice0(long display, long screenResources, long monitorInfo, int crtc_id);
- private static native boolean setMonitorMode0(long display, long screenResources, long monitorInfo, int monitor_idx, int mode_id, int rotation, int x, int y);
- private static native boolean setScreenViewport0(long display, int screen_index, long screenResources, int x, int y, int width, int height);
+ private static native boolean setMonitorMode0(long display, int screen_index, long screenResources,
+ long monitorInfo, int crtc_id,
+ int mode_id, int rotation, int x, int y);
+ private static native boolean setScreenViewport0(long display, int screen_index, long screenResources,
+ int x, int y, int width, int height);
+ private static native void sendRRScreenChangeNotify0(long display, final long event);
}
diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java
index 993ff58f9..2dc416063 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java
@@ -91,15 +91,16 @@ public class ScreenDriver extends ScreenImpl {
}
{
if( !DEBUG_TEST_RANDR13_DISABLED && randrVersion.compareTo(RandR.version130) >= 0 ) {
- rAndR = new RandR13();
+ rAndR = new RandR13(randrVersion);
} else if( randrVersion.compareTo(RandR.version110) >= 0 ) {
- rAndR = new RandR11();
+ rAndR = new RandR11(randrVersion);
} else {
rAndR = null;
}
}
+ ((DisplayDriver)display).registerRandR(rAndR);
if( DEBUG ) {
- System.err.println("RandR "+randrVersion+", "+rAndR);
+ System.err.println("Using "+rAndR);
rAndR.dumpInfo(dpy, screen_idx);
}
}
@@ -119,12 +120,13 @@ public class ScreenDriver extends ScreenImpl {
try {
if( rAndR.beginInitialQuery(device.getHandle(), this) ) {
try {
- final int crtCount = rAndR.getMonitorDeviceCount(device.getHandle(), this);
+ final int[] crt_ids = rAndR.getMonitorDeviceIds(device.getHandle(), this);
+ final int crtCount = crt_ids.length;
// Gather all available rotations
final ArrayHashSet<Integer> availableRotations = new ArrayHashSet<Integer>();
for(int i = 0; i < crtCount; i++) {
- final int[] rotations = rAndR.getAvailableRotations(device.getHandle(), this, i);
+ final int[] rotations = rAndR.getAvailableRotations(device.getHandle(), this, crt_ids[i]);
if( null != rotations ) {
final List<Integer> rotationList = new ArrayList<Integer>(rotations.length);
for(int j=0; j<rotations.length; j++ ) { rotationList.add(rotations[j]); }
@@ -148,7 +150,7 @@ public class ScreenDriver extends ScreenImpl {
}
if( cache.monitorModes.size() > 0 ) {
for(int i = 0; i < crtCount; i++) {
- final int[] monitorProps = rAndR.getMonitorDeviceProps(device.getHandle(), this, cache, i);
+ final int[] monitorProps = rAndR.getMonitorDeviceProps(device.getHandle(), this, cache, crt_ids[i]);
if( null != monitorProps &&
MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES <= monitorProps[0] && // Enabled ? I.e. contains active modes ?
MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES <= monitorProps.length ) {
@@ -196,16 +198,21 @@ public class ScreenDriver extends ScreenImpl {
if( null == rAndR ) { return false; }
final long t0 = System.currentTimeMillis();
- final boolean done = runWithOptTempDisplayHandle( new DisplayImpl.DisplayRunnable<Boolean>() {
+ final boolean started = runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Boolean>() {
@Override
public Boolean run(final long dpy) {
- return Boolean.valueOf( rAndR.setCurrentMonitorMode(dpy, ScreenDriver.this, monitor, mode) );
+ return Boolean.valueOf( rAndR.setCurrentMonitorModeStart(dpy, ScreenDriver.this, monitor, mode) );
}
}).booleanValue();
-
+ final boolean done;
+ if( started ) {
+ done = rAndR.setCurrentMonitorModeWait(this);
+ } else {
+ done = false;
+ }
if(DEBUG || !done) {
- System.err.println("X11Screen.setCurrentMonitorModeImpl: TO ("+SCREEN_MODE_CHANGE_TIMEOUT+") reached: "+
- (System.currentTimeMillis()-t0)+"ms; "+monitor.getCurrentMode()+" -> "+mode);
+ System.err.println("X11Screen.setCurrentMonitorModeImpl: "+(done?" OK":"NOK")+" (started "+started+"): t/TO "+
+ (System.currentTimeMillis()-t0)+"/"+SCREEN_MODE_CHANGE_TIMEOUT+"ms; "+monitor.getCurrentMode()+" -> "+mode);
}
return done;
}
@@ -276,14 +283,6 @@ public class ScreenDriver extends ScreenImpl {
return res;
}
- private final <T> T runWithOptTempDisplayHandle(final DisplayRunnable<T> action) {
- if( null != rAndR && rAndR.getVersion().compareTo(RandR.version130) >= 0 ) {
- return display.runWithLockedDisplayDevice(action);
- } else {
- return runWithTempDisplayHandle(action);
- }
- }
-
private static native long GetScreen0(long dpy, int scrn_idx);
private static native int getWidth0(long display, int scrn_idx);
diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
index cdeb7d6d0..6cf9727f2 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
@@ -149,7 +149,8 @@ public class WindowDriver extends WindowImpl {
edtDevice.lock();
try {
CloseWindow0(edtDevice.getHandle(), windowHandleClose,
- display.getJavaObjectAtom(), display.getWindowDeleteAtom() /* , display.getKbdHandle() */); // XKB disabled for now
+ display.getJavaObjectAtom(), display.getWindowDeleteAtom() /* , display.getKbdHandle() */, // XKB disabled for now
+ display.getRandREventBase(), display.getRandRErrorBase());
} catch (final Throwable t) {
if(DEBUG_IMPLEMENTATION) {
final Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t);
@@ -451,7 +452,8 @@ public class WindowDriver extends WindowImpl {
int visualID, long javaObjectAtom, long windowDeleteAtom,
int x, int y, int width, int height, boolean autoPosition, int flags,
int pixelDataSize, Object pixels, int pixels_byte_offset, boolean pixels_is_direct);
- private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom, long windowDeleteAtom /*, long kbdHandle*/ ); // XKB disabled for now
+ private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom, long windowDeleteAtom /*, long kbdHandle*/, // XKB disabled for now
+ final int randr_event_base, final int randr_error_base);
private native void reconfigureWindow0(long display, int screen_index, long parentWindowHandle, long windowHandle,
long windowDeleteAtom, int x, int y, int width, int height, int flags);
private native void requestFocus0(long display, long windowHandle, boolean force);