diff options
| author | Po Lu | 2023-03-11 11:35:59 +0800 |
|---|---|---|
| committer | Po Lu | 2023-03-11 11:35:59 +0800 |
| commit | 4a328b857812625ec82b31d8efd928f8580d9561 (patch) | |
| tree | 97e942800fb9710bd19c3bfc8902782db93563ec /java | |
| parent | 98c7825f5d4e53499a47956c311847525a9deec0 (diff) | |
| download | emacs-4a328b857812625ec82b31d8efd928f8580d9561.tar.gz emacs-4a328b857812625ec82b31d8efd928f8580d9561.zip | |
Fix problems with the menu bar on large screen Android devices
* java/org/gnu/emacs/EmacsActivity.java (onContextMenuClosed):
Process submenu closing normally if it happens more than 300 ms
after a submenu item was selected.
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu)
(onMenuItemClick, display1): Give `wasSubmenuSelected' different
values depending on how the submenu was selected.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsActivity.java | 8 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsContextMenu.java | 20 |
2 files changed, 20 insertions, 8 deletions
diff --git a/java/org/gnu/emacs/EmacsActivity.java b/java/org/gnu/emacs/EmacsActivity.java index 735a464be8e..b480fc40b2e 100644 --- a/java/org/gnu/emacs/EmacsActivity.java +++ b/java/org/gnu/emacs/EmacsActivity.java | |||
| @@ -321,10 +321,14 @@ public class EmacsActivity extends Activity | |||
| 321 | 321 | ||
| 322 | /* See the comment inside onMenuItemClick. */ | 322 | /* See the comment inside onMenuItemClick. */ |
| 323 | 323 | ||
| 324 | if (EmacsContextMenu.wasSubmenuSelected | 324 | if (((EmacsContextMenu.wasSubmenuSelected == -2) |
| 325 | || (EmacsContextMenu.wasSubmenuSelected >= 0 | ||
| 326 | && ((System.currentTimeMillis () | ||
| 327 | - EmacsContextMenu.wasSubmenuSelected) | ||
| 328 | <= 300))) | ||
| 325 | || menu == lastClosedMenu) | 329 | || menu == lastClosedMenu) |
| 326 | { | 330 | { |
| 327 | EmacsContextMenu.wasSubmenuSelected = false; | 331 | EmacsContextMenu.wasSubmenuSelected = -1; |
| 328 | lastClosedMenu = menu; | 332 | lastClosedMenu = menu; |
| 329 | return; | 333 | return; |
| 330 | } | 334 | } |
diff --git a/java/org/gnu/emacs/EmacsContextMenu.java b/java/org/gnu/emacs/EmacsContextMenu.java index abc1869ac6a..d780641ba70 100644 --- a/java/org/gnu/emacs/EmacsContextMenu.java +++ b/java/org/gnu/emacs/EmacsContextMenu.java | |||
| @@ -46,8 +46,11 @@ public final class EmacsContextMenu | |||
| 46 | /* Whether or not an item was selected. */ | 46 | /* Whether or not an item was selected. */ |
| 47 | public static boolean itemAlreadySelected; | 47 | public static boolean itemAlreadySelected; |
| 48 | 48 | ||
| 49 | /* Whether or not a submenu was selected. */ | 49 | /* Whether or not a submenu was selected. |
| 50 | public static boolean wasSubmenuSelected; | 50 | Value is -1 if no; value is -2 if yes, and a context menu |
| 51 | close event will definitely be sent. Any other value is | ||
| 52 | the timestamp when the submenu was selected. */ | ||
| 53 | public static long wasSubmenuSelected; | ||
| 51 | 54 | ||
| 52 | /* The serial ID of the last context menu to be displayed. */ | 55 | /* The serial ID of the last context menu to be displayed. */ |
| 53 | public static int lastMenuEventSerial; | 56 | public static int lastMenuEventSerial; |
| @@ -78,7 +81,7 @@ public final class EmacsContextMenu | |||
| 78 | /* Still set wasSubmenuSelected -- if not set, the | 81 | /* Still set wasSubmenuSelected -- if not set, the |
| 79 | dismissal of this context menu will result in a | 82 | dismissal of this context menu will result in a |
| 80 | context menu event being sent. */ | 83 | context menu event being sent. */ |
| 81 | wasSubmenuSelected = true; | 84 | wasSubmenuSelected = -2; |
| 82 | 85 | ||
| 83 | /* Running a popup menu from inside a click handler | 86 | /* Running a popup menu from inside a click handler |
| 84 | doesn't work, so make sure it is displayed | 87 | doesn't work, so make sure it is displayed |
| @@ -103,8 +106,13 @@ public final class EmacsContextMenu | |||
| 103 | 106 | ||
| 104 | Setting this flag makes EmacsActivity to only handle | 107 | Setting this flag makes EmacsActivity to only handle |
| 105 | SubMenuBuilder being closed, which always means the menu | 108 | SubMenuBuilder being closed, which always means the menu |
| 106 | has actually been dismissed. */ | 109 | has actually been dismissed. |
| 107 | wasSubmenuSelected = true; | 110 | |
| 111 | However, these extraneous events aren't sent on devices | ||
| 112 | where submenus display without dismissing their parents. | ||
| 113 | Thus, only ignore the close event if it happens within | ||
| 114 | 300 milliseconds of the submenu being selected. */ | ||
| 115 | wasSubmenuSelected = System.currentTimeMillis (); | ||
| 108 | return false; | 116 | return false; |
| 109 | } | 117 | } |
| 110 | 118 | ||
| @@ -291,7 +299,7 @@ public final class EmacsContextMenu | |||
| 291 | itemAlreadySelected = false; | 299 | itemAlreadySelected = false; |
| 292 | 300 | ||
| 293 | /* No submenu has been selected yet. */ | 301 | /* No submenu has been selected yet. */ |
| 294 | wasSubmenuSelected = false; | 302 | wasSubmenuSelected = -1; |
| 295 | 303 | ||
| 296 | return window.view.popupMenu (this, xPosition, yPosition, | 304 | return window.view.popupMenu (this, xPosition, yPosition, |
| 297 | false); | 305 | false); |