From ded77feffface0c167edacf0d807273f3d4878db Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 19 Feb 2025 20:40:12 +0800 Subject: Fix remaining Android bugs reported over the past months * java/org/gnu/emacs/EmacsActivity.java (attachWindow): Guarantee that child windows promoted to toplevels receive layout parameters that direct them to receive their parents' dimensions. Otherwise, the size of the window as a child is retained on Huawei HarmonyOS 4.2 and possibly other Android distributions. * java/org/gnu/emacs/EmacsService.java (updateCursorAnchorInfo): Run anchor updates on the UI thread, as `InputMethodManager#updateCursorAnchorInfo' is liable to call `View#requestLayout'. * java/org/gnu/emacs/EmacsView.java (onMeasure): Always call `measureChildren', or child frames' onLayout handlers might not be invoked after they request a layout cycle and are duly processed in `onLayout'. (swapBuffers): Delete erroneous commentary. * java/org/gnu/emacs/EmacsWindow.java (viewLayout): If overrideRedirect, don't inadvertently clear rect.left and rect.top by recording the window's WM window-relative position. Fix typos. (reparentTo): Invalidate focus after transferring frame. (translateCoordinates): Account for override-redirect windows. Mostly important for mouse-drag-and-drop-region. --- java/org/gnu/emacs/EmacsActivity.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'java/org/gnu/emacs/EmacsActivity.java') diff --git a/java/org/gnu/emacs/EmacsActivity.java b/java/org/gnu/emacs/EmacsActivity.java index 8a5ccb4625b..9f36561cc02 100644 --- a/java/org/gnu/emacs/EmacsActivity.java +++ b/java/org/gnu/emacs/EmacsActivity.java @@ -179,6 +179,8 @@ public class EmacsActivity extends Activity public final void attachWindow (EmacsWindow child) { + FrameLayout.LayoutParams defaultParams; + if (window != null) throw new IllegalStateException ("trying to attach window when one" + " already exists"); @@ -187,8 +189,15 @@ public class EmacsActivity extends Activity /* Record and attach the view. */ + /* Reset residual LayoutParams that might remain in effect on this + window, or some distributions of Android (e.g. Huawei HarmonyOS + 4.2) will retain the size of this window as a child frame. */ + defaultParams + = new FrameLayout.LayoutParams (FrameLayout.LayoutParams.MATCH_PARENT, + FrameLayout.LayoutParams.MATCH_PARENT); + syncFullscreenWith (child); window = child; - layout.addView (window.view); + layout.addView (window.view, defaultParams); child.setConsumer (this); /* If the window isn't no-focus-on-map, focus its view. */ -- cgit v1.3