aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-06 16:25:18 +0200
committerSven Gothel <[email protected]>2011-09-06 16:25:18 +0200
commit3766fc329ec27c09f7e71bbf705defc44a8bedac (patch)
tree51593bad661a96b9cac5218deff569a4ad21a9a8 /src/newt/classes/jogamp
parent667d3f6a08ba5c4574df0d4f3fd27a47dc1c228d (diff)
NEWT/ScreenMode: setCurrentScreenMode() shall only act if new mode differs; On X11 use Thread.sleep(), more cooperative.
In case newMode == currentMode, this caused an error, since X11 would never receive mode change events. Thread.sleep() is nicer for the X11/WM .. cooperative multitasking :)
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/ScreenImpl.java30
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/X11Screen.java2
2 files changed, 23 insertions, 9 deletions
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index ec955ead6..65ac9623b 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -318,7 +318,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
}
sms.lock();
try {
- smU = (ScreenMode) sms.getScreenModes().getOrAdd(sm0); // unified instance, maybe new
+ smU = sms.getScreenModes().getOrAdd(sm0); // unified instance, maybe new
// if mode has changed somehow, update it ..
if( sms.getCurrentScreenMode().hashCode() != smU.hashCode() ) {
@@ -333,34 +333,48 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
}
public boolean setCurrentScreenMode(ScreenMode screenMode) {
- ScreenMode smU = (ScreenMode) getScreenModesOrig().get(screenMode); // unify via value hash
+ final ScreenMode smC = getCurrentScreenMode();
+ 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);
+ Thread.dumpStack();
+ }
+ return true;
+ }
ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName());
if(null!=sms) {
sms.lock();
try {
+ long t0=0, t1=0;
if(DEBUG) {
System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): 0.0 "+screenMode);
- }
+ t0 = System.currentTimeMillis();
+ }
sms.fireScreenModeChangeNotify(smU);
if(DEBUG) {
System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): 0.1 "+screenMode);
+ t1 = System.currentTimeMillis();
}
- boolean success = setCurrentScreenModeImpl(smU);
+ boolean success = setCurrentScreenModeImpl(smU);
if(success) {
setScreenSize(screenMode.getRotatedWidth(), screenMode.getRotatedHeight());
}
-
+
if(DEBUG) {
+ t1 = System.currentTimeMillis() - t1;
System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): X.0 "+screenMode+", success: "+success);
}
sms.fireScreenModeChanged(smU, success);
-
+
if(DEBUG) {
- System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): X.X "+screenMode+", success: "+success);
+ t0 = System.currentTimeMillis() - t0;
+ System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): X.X "+screenMode+", success: "+success+
+ " - dt0 "+t0+"ms, dt1 "+t1+"ms");
}
return success;
@@ -477,7 +491,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
if(screenModes.size()>0) {
ScreenMode originalScreenMode = ( DEBUG_TEST_SCREENMODE_DISABLED ) ? null : getCurrentScreenModeImpl();
if(null != originalScreenMode) {
- ScreenMode originalScreenMode0 = (ScreenMode) screenModes.get(originalScreenMode); // unify via value hash
+ ScreenMode originalScreenMode0 = screenModes.get(originalScreenMode); // unify via value hash
if(null == originalScreenMode0) {
throw new RuntimeException(originalScreenMode+" could not be hashed from ScreenMode list");
}
diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
index db24cd088..8dd5bba83 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
@@ -227,7 +227,7 @@ public class X11Screen extends ScreenImpl {
while(!done && System.currentTimeMillis()-t0 < SCREEN_MODE_CHANGE_TIMEOUT) {
done = setCurrentScreenModePollEnd0(dpy, screen_idx, resIdx, f, r);
if(!done) {
- Thread.yield();
+ try { Thread.sleep(10); } catch (InterruptedException e) { }
}
}
}