From 8ee1dc8f1f9aa47260f8151c9eea30fb1ccf878a Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 7 Apr 2024 14:39:42 +0800 Subject: [PATCH] Resolve disagreements in accounting of tooltip positions on Android * java/org/gnu/emacs/EmacsService.java (getLocationInWindow): New function. * java/org/gnu/emacs/EmacsWindow.java (translateCoordinates): Derive "root window" position from the origin point of the containing activity's window rather than that of the screen, the two of which differ when "freeform mode" is enabled. --- java/org/gnu/emacs/EmacsService.java | 17 +++++++++++++++++ java/org/gnu/emacs/EmacsWindow.java | 7 ++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index 34682feeedb..052793eabaf 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java @@ -387,6 +387,23 @@ invocation of app_process (through android-emacs) can EmacsService.syncRunnable (task); } + public void + getLocationInWindow (final EmacsView view, final int[] coordinates) + { + FutureTask task; + + task = new FutureTask (new Callable () { + public Void + call () + { + view.getLocationInWindow (coordinates); + return null; + } + }); + + EmacsService.syncRunnable (task); + } + public static void diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java index 91e97fa8b61..911e082144e 100644 --- a/java/org/gnu/emacs/EmacsWindow.java +++ b/java/org/gnu/emacs/EmacsWindow.java @@ -1551,10 +1551,11 @@ else if (EmacsWindow.this.isMapped) { int[] array; - /* This is supposed to translate coordinates to the root - window. */ + /* This is supposed to translate coordinates to the root window, + whose origin point, in this context, is that of the toplevel + activity host to this view. */ array = new int[2]; - EmacsService.SERVICE.getLocationOnScreen (view, array); + EmacsService.SERVICE.getLocationInWindow (view, array); /* Now, the coordinates of the view should be in array. Offset X and Y by them. */