Fix selection-handle drags, menu anchoring, and left-edge back-gesture theft
Three user-reported selection bugs, one root cause each:
1. Start handle ungrabbable at line start. Two interacting causes:
a) The 48dp grab box straddles two visual lines; a finger in the
lower half mapped (by y-to-line) to the neighbouring line, whose
byte past the other handle clamped to a zero-length selection ->
cleared on the first drag event. The cleared selection
un-registered the drag op, so the router silently stopped
delivering drag events (the observed 'stream cutoff'). Fix:
handle drags now project the finger's x onto the anchor's own
visual line (visualLineOfByte + textPosOnLineAtX); the anchor
never crosses lines during a handle drag.
b) A horizontal flick from the line-start handle (screen x~26px)
started the system back gesture, which cancelled the touch
stream. Fix: report the handle grab rects as system gesture
exclusion rects (setSystemGestureExclusionRects, API 29+),
marshalled to the UI thread via a PadExcl smali Runnable
(generated identically by build_emu.sh/build_phone.sh).
2. End-handle drag downward made the menu chase the finger and cover
the selection. Fix: the menu anchors to the STABLE end of the
selection (the end not being dragged), so it stays parked by the
selection start, clear of the finger and the highlighted text.
3. Menu above the selection vanished permanently when the selection
was extended onto the top line. Fix: off-window anchors no longer
hide the menu while any part of the selection is visible (keep-last
rect, clamped); hiding happens only for fully off-window selections.
Also: registerDrag simplified (single shared drag path, body before
handles in z-order), debug logging removed, regression tests
(mutation-verified) for line projection and menu anchoring, docs
section 17. Verified on device: start-handle drag shrinks the word
without clearing or triggering back navigation; end-handle vertical
drag leaves menu/highlight/handles undisturbed; menu stays visible
with the selection at the top line.
This commit is contained in:
@@ -260,6 +260,57 @@ listener = '''
|
||||
'''
|
||||
(base / "smali" / "org" / "gioui" / "PadInsetsListener.smali").write_text(listener)
|
||||
|
||||
# 1b. New class: a Runnable that applies system-gesture exclusion rects on
|
||||
# the UI thread. The Go frame loop runs on its OWN thread (not the UI
|
||||
# thread), so View.setSystemGestureExclusionRects must be posted: it is the
|
||||
# relayout that reports the rects to the window manager, which owns the edge
|
||||
# back-gesture zone. Without the post the rects are set on the view but never
|
||||
# reach the window manager, and the back gesture still steals edge drags.
|
||||
padexcl = '''
|
||||
.class public Lorg/gioui/PadExcl;
|
||||
.super Ljava/lang/Object;
|
||||
.source "PadExcl.java"
|
||||
|
||||
# interfaces
|
||||
.implements Ljava/lang/Runnable;
|
||||
|
||||
|
||||
# instance fields
|
||||
.field public final mView:Landroid/view/View;
|
||||
|
||||
.field public final mList:Ljava/util/List;
|
||||
|
||||
|
||||
# direct methods
|
||||
.method public constructor <init>(Landroid/view/View;Ljava/util/List;)V
|
||||
.locals 0
|
||||
|
||||
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
||||
|
||||
iput-object p1, p0, Lorg/gioui/PadExcl;->mView:Landroid/view/View;
|
||||
|
||||
iput-object p2, p0, Lorg/gioui/PadExcl;->mList:Ljava/util/List;
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
|
||||
# virtual methods
|
||||
.method public run()V
|
||||
.locals 2
|
||||
|
||||
iget-object v0, p0, Lorg/gioui/PadExcl;->mView:Landroid/view/View;
|
||||
|
||||
iget-object v1, p0, Lorg/gioui/PadExcl;->mList:Ljava/util/List;
|
||||
|
||||
invoke-virtual {v0, v1}, Landroid/view/View;->setSystemGestureExclusionRects(Ljava/util/List;)V
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
'''
|
||||
(base / "smali" / "org" / "gioui" / "PadExcl.smali").write_text(padexcl)
|
||||
|
||||
# 2. Wire it up in GioActivity.onCreate (and opt out of decor auto-fit).
|
||||
p = base / "smali" / "org" / "gioui" / "GioActivity.smali"
|
||||
t = p.read_text()
|
||||
|
||||
@@ -253,6 +253,57 @@ listener = '''
|
||||
'''
|
||||
(base / "smali" / "org" / "gioui" / "PadInsetsListener.smali").write_text(listener)
|
||||
|
||||
# 1b. New class: a Runnable that applies system-gesture exclusion rects on
|
||||
# the UI thread. The Go frame loop runs on its OWN thread (not the UI
|
||||
# thread), so View.setSystemGestureExclusionRects must be posted: it is the
|
||||
# relayout that reports the rects to the window manager, which owns the edge
|
||||
# back-gesture zone. Without the post the rects are set on the view but never
|
||||
# reach the window manager, and the back gesture still steals edge drags.
|
||||
padexcl = '''
|
||||
.class public Lorg/gioui/PadExcl;
|
||||
.super Ljava/lang/Object;
|
||||
.source "PadExcl.java"
|
||||
|
||||
# interfaces
|
||||
.implements Ljava/lang/Runnable;
|
||||
|
||||
|
||||
# instance fields
|
||||
.field public final mView:Landroid/view/View;
|
||||
|
||||
.field public final mList:Ljava/util/List;
|
||||
|
||||
|
||||
# direct methods
|
||||
.method public constructor <init>(Landroid/view/View;Ljava/util/List;)V
|
||||
.locals 0
|
||||
|
||||
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
||||
|
||||
iput-object p1, p0, Lorg/gioui/PadExcl;->mView:Landroid/view/View;
|
||||
|
||||
iput-object p2, p0, Lorg/gioui/PadExcl;->mList:Ljava/util/List;
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
|
||||
# virtual methods
|
||||
.method public run()V
|
||||
.locals 2
|
||||
|
||||
iget-object v0, p0, Lorg/gioui/PadExcl;->mView:Landroid/view/View;
|
||||
|
||||
iget-object v1, p0, Lorg/gioui/PadExcl;->mList:Ljava/util/List;
|
||||
|
||||
invoke-virtual {v0, v1}, Landroid/view/View;->setSystemGestureExclusionRects(Ljava/util/List;)V
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
'''
|
||||
(base / "smali" / "org" / "gioui" / "PadExcl.smali").write_text(padexcl)
|
||||
|
||||
# 2. Wire it up in GioActivity.onCreate (and opt out of decor auto-fit).
|
||||
p = base / "smali" / "org" / "gioui" / "GioActivity.smali"
|
||||
t = p.read_text()
|
||||
|
||||
Reference in New Issue
Block a user