diff options
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r-- | src/newt/classes/jogamp/newt/ScreenImpl.java | 43 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/WindowImpl.java | 8 |
2 files changed, 35 insertions, 16 deletions
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 1cc53e80e..56d6f67ff 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -277,7 +277,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { protected void updateVirtualScreenOriginAndSize() { getVirtualScreenOriginAndSize(vOrigin, vSize); if(DEBUG) { - System.err.println("Detected screen origin "+vOrigin+", size "+vSize); + System.err.println("Detected virtual screen origin "+vOrigin+", size "+vSize); } } @@ -321,18 +321,24 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { return null; } + private final ScreenModeStatus getScreenModeStatus(boolean throwException) { + final String key = this.getFQName(); + final ScreenModeStatus res = ScreenModeStatus.getScreenModeStatus(key); + if(null == res & throwException) { + throw new InternalError("ScreenModeStatus.getScreenModeStatus("+key+") == null"); + } + return res; + } + public ScreenMode getOriginalScreenMode() { - ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName()); + final ScreenModeStatus sms = getScreenModeStatus(false); return ( null != sms ) ? sms.getOriginalScreenMode() : null ; } public ScreenMode getCurrentScreenMode() { ScreenMode smU = null; - ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName()); - if(null == sms) { - throw new InternalError("ScreenModeStatus.getScreenModeStatus("+this.getFQName()+") == null"); - } - ScreenMode sm0 = getCurrentScreenModeIntern(); + final ScreenModeStatus sms = getScreenModeStatus(true); + final ScreenMode sm0 = getCurrentScreenModeIntern(); if(null == sm0) { throw new InternalError("getCurrentScreenModeImpl() == null"); } @@ -378,12 +384,23 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): fireScreenModeChangeNotify() "+smU); } - success = setCurrentScreenModeImpl(smU); - if(DEBUG) { - System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+smU+", success: "+success); + success = setCurrentScreenModeImpl(smU); + if(success) { + if(DEBUG) { + System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+smU+", success(1): "+success); + } + } else { + // 2nd attempt validate! + final ScreenMode queriedCurrent = getCurrentScreenMode(); // may fireScreenModeChanged(..) if successful and differs! + final ScreenMode smsCurrent = sms.getCurrentScreenMode(); + success = smsCurrent.hashCode() == smU.hashCode() && queriedCurrent.hashCode() == smU.hashCode() ; + if(DEBUG) { + System.err.println("Screen.setCurrentScreenMode.2: queried "+queriedCurrent); + System.err.println("Screen.setCurrentScreenMode.2: SMS "+smsCurrent); + System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+smU+", success(2): "+success); + } } - - sms.fireScreenModeChanged(smU, success); + sms.fireScreenModeChanged(smU, success); if(DEBUG) { System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): X.X "+smU+", success: "+success); } @@ -482,7 +499,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { res = getCurrentScreenModeImpl(); } if(null == res) { - if( 0==getWidth()*getHeight() ) { + if( 0>=getWidth() || 0>=getHeight() ) { updateVirtualScreenOriginAndSize(); } int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index c94ce286b..8901411a3 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1711,6 +1711,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // set current state WindowImpl.this.fullscreen = fullscreen; + final ScreenMode sm = screen.getCurrentScreenMode(); int x,y,w,h; if(fullscreen) { @@ -1720,8 +1721,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer nfs_height = getHeight(); x = screen.getX(); y = screen.getY(); - w = screen.getWidth(); - h = screen.getHeight(); + w = sm.getRotatedWidth(); + h = sm.getRotatedHeight(); } else { x = nfs_x; y = nfs_y; @@ -1743,7 +1744,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } if(DEBUG_IMPLEMENTATION) { - System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+", "+screen); + System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ + ", virtl-size: "+screen.getWidth()+"x"+screen.getHeight()+", SM "+sm.getRotatedWidth()+"x"+sm.getRotatedHeight()); } DisplayImpl display = (DisplayImpl) screen.getDisplay(); |