]> git.eshelyaron.com Git - emacs.git/commitdiff
Work around premature dismissals of submenus under Android
authorPo Lu <luangruo@yahoo.com>
Wed, 21 Feb 2024 03:49:47 +0000 (11:49 +0800)
committerEshel Yaron <me@eshelyaron.com>
Wed, 28 Feb 2024 17:37:25 +0000 (18:37 +0100)
* java/org/gnu/emacs/EmacsContextMenu.java (display): If between
HONEYCOMB and N, set wasSubmenuSelected.

(cherry picked from commit 7b0d75018885d8d34ff7c4427a83a21a4808282c)

java/org/gnu/emacs/EmacsContextMenu.java

index 17e6033377d40b65a23a81e89c5c4a556ea21a34..f1d70f05a25982230f28ae4ec880ca4db08b49a4 100644 (file)
@@ -361,8 +361,24 @@ public final class EmacsContextMenu
        public Boolean
        call ()
        {
+         boolean rc;
+
          lastMenuEventSerial = serial;
-         return display1 (window, xPosition, yPosition);
+         rc = display1 (window, xPosition, yPosition);
+
+         /* Android 3.0 to Android 7.0 perform duplicate calls to
+            onContextMenuClosed after a context menu is dismissed for
+            the second or third time.  Since the second call after such
+            a dismissal is otherwise liable to prematurely cancel any
+            context menu displayed immediately afterwards, ignore calls
+            received within 300 milliseconds of this menu's being
+            displayed.  */
+
+         if (rc && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB
+             && Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
+           wasSubmenuSelected = System.currentTimeMillis ();
+
+         return rc;
        }
       });