diff options
| author | Po Lu | 2024-03-26 10:54:39 +0800 |
|---|---|---|
| committer | Po Lu | 2024-03-26 10:54:39 +0800 |
| commit | b7b9a0a5c1afae07b8168e85dcf1fc37d29e98ef (patch) | |
| tree | 0bdab8fad62deebd6d71c8d7df9ebc6ef525a7e0 /java | |
| parent | 728bf2c9e5353e68b16808ae455223549c16efc6 (diff) | |
| download | emacs-b7b9a0a5c1afae07b8168e85dcf1fc37d29e98ef.tar.gz emacs-b7b9a0a5c1afae07b8168e85dcf1fc37d29e98ef.zip | |
Prevent focus "stalemates" on Android
* java/org/gnu/emacs/EmacsActivity.java (invalidateFocus1): New
argument resetWhenChildless.
(invalidateFocus): If a toplevel window has no focus window,
transfer focus to the toplevel itself.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsActivity.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/java/org/gnu/emacs/EmacsActivity.java b/java/org/gnu/emacs/EmacsActivity.java index 06b9c0f005d..6ab6a709bef 100644 --- a/java/org/gnu/emacs/EmacsActivity.java +++ b/java/org/gnu/emacs/EmacsActivity.java | |||
| @@ -84,7 +84,7 @@ public class EmacsActivity extends Activity | |||
| 84 | }; | 84 | }; |
| 85 | 85 | ||
| 86 | public static void | 86 | public static void |
| 87 | invalidateFocus1 (EmacsWindow window) | 87 | invalidateFocus1 (EmacsWindow window, boolean resetWhenChildless) |
| 88 | { | 88 | { |
| 89 | if (window.view.isFocused ()) | 89 | if (window.view.isFocused ()) |
| 90 | focusedWindow = window; | 90 | focusedWindow = window; |
| @@ -92,7 +92,18 @@ public class EmacsActivity extends Activity | |||
| 92 | synchronized (window.children) | 92 | synchronized (window.children) |
| 93 | { | 93 | { |
| 94 | for (EmacsWindow child : window.children) | 94 | for (EmacsWindow child : window.children) |
| 95 | invalidateFocus1 (child); | 95 | invalidateFocus1 (child, false); |
| 96 | |||
| 97 | /* If no focused window was previously detected among WINDOW's | ||
| 98 | children and RESETWHENCHILDLESS is set (implying it is a | ||
| 99 | toplevel window), request that it be focused, to avoid | ||
| 100 | creating a situation where no windows exist focused or can be | ||
| 101 | transferred the input focus by user action. */ | ||
| 102 | if (focusedWindow == null && resetWhenChildless) | ||
| 103 | { | ||
| 104 | window.view.requestFocus (); | ||
| 105 | focusedWindow = window; | ||
| 106 | } | ||
| 96 | } | 107 | } |
| 97 | } | 108 | } |
| 98 | 109 | ||
| @@ -110,7 +121,7 @@ public class EmacsActivity extends Activity | |||
| 110 | for (EmacsActivity activity : focusedActivities) | 121 | for (EmacsActivity activity : focusedActivities) |
| 111 | { | 122 | { |
| 112 | if (activity.window != null) | 123 | if (activity.window != null) |
| 113 | invalidateFocus1 (activity.window); | 124 | invalidateFocus1 (activity.window, focusedWindow == null); |
| 114 | } | 125 | } |
| 115 | 126 | ||
| 116 | /* Send focus in- and out- events to the previous and current | 127 | /* Send focus in- and out- events to the previous and current |