From 3ceac1c8a13088409849e84933bb63fb4996f9db Mon Sep 17 00:00:00 2001 From: pelya Date: Sun, 2 Mar 2014 19:03:30 +0200 Subject: [PATCH] Fixed screen orientation not restored in TeeWorlds --- project/java/GLSurfaceView_SDL.java | 36 ++++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/project/java/GLSurfaceView_SDL.java b/project/java/GLSurfaceView_SDL.java index 998bf1c5c..9f132e597 100644 --- a/project/java/GLSurfaceView_SDL.java +++ b/project/java/GLSurfaceView_SDL.java @@ -1055,12 +1055,14 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call if( Globals.NonBlockingSwapBuffers ) return false; } - while (needToWait()) { - //Log.v("SDL", "GLSurfaceView_SDL::run(): paused"); - try { - wait(500); - } catch(Exception e) { } - } + } + while (needToWait()) { + //Log.v("SDL", "GLSurfaceView_SDL::run(): paused"); + try { + wait(500); + } catch(Exception e) { } + } + synchronized (this) { if (mDone) { return false; } @@ -1108,16 +1110,21 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call return true; // We're in lockscreen - sleep until user unlocks the device } - if (mDone) { - return false; - } + synchronized (this) { + if (mDone) { + return false; + } - if (mPaused || (! mHasSurface)) { - return true; - } + if ( Globals.HorizontalOrientation != (mWidth > mHeight) ) + return true; // Wait until screen orientation changes - if ((mWidth > 0) && (mHeight > 0) && (mRequestRender || (mRenderMode == RENDERMODE_CONTINUOUSLY))) { - return false; + if (mPaused || (! mHasSurface)) { + return true; + } + + if ((mWidth > 0) && (mHeight > 0) && (mRequestRender || (mRenderMode == RENDERMODE_CONTINUOUSLY))) { + return false; + } } return true; @@ -1178,6 +1185,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call } public void onWindowResize(int w, int h) { + Log.v("SDL", "GLSurfaceView_SDL::onWindowResize(): " + w + "x" + h); synchronized (this) { mWidth = w; mHeight = h;