Skip to content

Commit 5dc5a2a

Browse files
committed
enqueue mouse events first
1 parent e5e4ae7 commit 5dc5a2a

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

core/src/processing/core/PApplet.java

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -501,24 +501,29 @@ public void initSurface(LayoutInflater inflater, ViewGroup container,
501501

502502
private void setFullScreenVisibility() {
503503
if (fullScreen) {
504-
int visibility;
505-
if (SDK < 19) {
506-
// Pre-4.4
507-
visibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
508-
} else {
509-
// 4.4 and higher. Integer instead of constants defined in View so it can
510-
// build with SDK < 4.4
511-
visibility = 256 | // View.SYSTEM_UI_FLAG_LAYOUT_STABLE
512-
512 | // View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
513-
1024 | // View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
514-
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
515-
4 | // View.SYSTEM_UI_FLAG_FULLSCREEN
516-
4096; // View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
517-
// However, this visibility does not fix a bug where the navigation area
518-
// turns black after resuming the app:
519-
// https://code.google.com/p/android/issues/detail?id=170752
520-
}
521-
surface.setSystemUiVisibility(visibility);
504+
runOnUiThread(new Runnable() {
505+
@Override
506+
public void run() {
507+
int visibility;
508+
if (SDK < 19) {
509+
// Pre-4.4
510+
visibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
511+
} else {
512+
// 4.4 and higher. Integer instead of constants defined in View so it can
513+
// build with SDK < 4.4
514+
visibility = 256 | // View.SYSTEM_UI_FLAG_LAYOUT_STABLE
515+
512 | // View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
516+
1024 | // View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
517+
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
518+
4 | // View.SYSTEM_UI_FLAG_FULLSCREEN
519+
4096; // View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
520+
// However, this visibility does not fix a bug where the navigation area
521+
// turns black after resuming the app:
522+
// https://code.google.com/p/android/issues/detail?id=170752
523+
}
524+
surface.setSystemUiVisibility(visibility);
525+
}
526+
});
522527
}
523528
}
524529

@@ -557,6 +562,9 @@ public void onResume() {
557562
public void onPause() {
558563
surface.pauseThread();
559564

565+
// Make sure that the keyboard is not left open after leaving the app
566+
closeKeyboard();
567+
560568
// TODO need to save all application state here!
561569
// At least we save the current style (once we had at least drawn one
562570
// frame, otherwise we might be saving a "null" style with all zeroes).
@@ -2156,8 +2164,8 @@ protected void nativeMotionEvent(MotionEvent motionEvent) {
21562164
button = state;
21572165
}
21582166

2159-
enqueueTouchEvents(motionEvent, button, modifiers);
21602167
enqueueMouseEvents(motionEvent, button, modifiers);
2168+
enqueueTouchEvents(motionEvent, button, modifiers);
21612169
}
21622170

21632171

@@ -2504,6 +2512,9 @@ public void closeKeyboard() {
25042512
Context context = surface.getContext();
25052513
InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
25062514
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
2515+
if (parentLayout == -1) {
2516+
setFullScreenVisibility();
2517+
}
25072518
}
25082519

25092520

0 commit comments

Comments
 (0)