Skip to content

Commit

Permalink
Improve handling of focus behaviour on Android. Patch by Alexey Petru…
Browse files Browse the repository at this point in the history
…chik
  • Loading branch information
gabomdq committed May 10, 2014
1 parent b701175 commit d5a2e55
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion android-project/src/org/libsdl/app/SDLActivity.java
Expand Up @@ -190,7 +190,7 @@ public static void handleResume() {
if (SDLActivity.mIsPaused && SDLActivity.mIsSurfaceReady && SDLActivity.mHasFocus) {
SDLActivity.mIsPaused = false;
SDLActivity.nativeResume();
mSurface.enableSensor(Sensor.TYPE_ACCELEROMETER, true);
mSurface.handleResume();
}
}

Expand Down Expand Up @@ -550,6 +550,15 @@ public SDLSurface(Context context) {
mWidth = 1.0f;
mHeight = 1.0f;
}

public void handleResume() {
setFocusable(true);
setFocusableInTouchMode(true);
requestFocus();
setOnKeyListener(this);
setOnTouchListener(this);
enableSensor(Sensor.TYPE_ACCELEROMETER, true);
}

public Surface getNativeSurface() {
return getHolder().getSurface();
Expand Down

0 comments on commit d5a2e55

Please sign in to comment.