From: Po Lu Date: Sun, 7 Apr 2024 06:39:42 +0000 (+0800) Subject: Resolve disagreements in accounting of tooltip positions on Android X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9ff932c984c9816af38384649c180c2e830b6327;p=emacs.git 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. (cherry picked from commit 8ee1dc8f1f9aa47260f8151c9eea30fb1ccf878a) --- 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 @@ public final class EmacsService extends Service 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 b0957bcab44..6d44cace9a2 100644 --- a/java/org/gnu/emacs/EmacsWindow.java +++ b/java/org/gnu/emacs/EmacsWindow.java @@ -1551,10 +1551,11 @@ public final class EmacsWindow extends EmacsHandleObject { 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. */