detached 8ab1d07

fix(core): clear pointer and grab when an unmanaged window unmaps

commit
8ab1d07e6792b323831afb58b582827427c84aca
author
brice · · 2026-10-22 15:27 UTC
committer
brice · · 2026-10-22 17:54 UTC
parent
b3f6b3a
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +32 -0
M internal/core/unmanaged.go +11 -0
@@ -48,6 +48,17 @@ func (c *Core) unmanagedEvent(ctx context.Context, ev ports.ClientEvent) (change
4848 if err := c.dataDragGone(ctx, v.ID); err != nil {
4949 return false, err
5050 }
51+ // rehit does nothing while a button grab or drag is held: do not
52+ // leave the pointer and grab on the dead window.
53+ if c.grab == v.ID {
54+ c.grab = 0
55+ }
56+ if c.pointer == v.ID {
57+ c.pointer = 0
58+ if err := c.pointerFocus(ctx, ports.PointerFocus{}); err != nil {
59+ return false, err
60+ }
61+ }
5162 }
5263 // The window under a still pointer may have changed.
5364 return true, c.rehit(ctx)
@@ -48,6 +48,17 @@ func (c *Core) unmanagedEvent(ctx context.Context, ev ports.ClientEvent) (change
48 if err := c.dataDragGone(ctx, v.ID); err != nil {48 if err := c.dataDragGone(ctx, v.ID); err != nil {
49 return false, err49 return false, err
50 }50 }
51+ // rehit does nothing while a button grab or drag is held: do not
52+ // leave the pointer and grab on the dead window.
53+ if c.grab == v.ID {
54+ c.grab = 0
55+ }
56+ if c.pointer == v.ID {
57+ c.pointer = 0
58+ if err := c.pointerFocus(ctx, ports.PointerFocus{}); err != nil {
59+ return false, err
60+ }
61+ }
51 }62 }
52 // The window under a still pointer may have changed.63 // The window under a still pointer may have changed.
53 return true, c.rehit(ctx)64 return true, c.rehit(ctx)
M internal/core/unmanaged_test.go +21 -0
@@ -122,3 +122,24 @@ func TestUnmanagedHitAllocations(t *testing.T) {
122122 t.Fatalf("hit allocs = %v", n)
123123 }
124124 }
125+
126+func TestUnmanagedUnmapDuringGrabClearsPointer(t *testing.T) {
127+ c := publishRig(t, 1)
128+ mapUnmanaged(t, c, 100, 10, 10, 50, 40, false)
129+ cmds := make(chan ports.ClientCommand, 64)
130+ c.ch.Commands = cmds
131+ c.pointer, c.grab = 100, 100
132+ c.clientEvent(context.Background(), ports.UnmanagedUnmapped{ID: 100})
133+ if c.pointer == 100 || c.grab != 0 {
134+ t.Fatalf("pointer %d grab %d left on the dead window", c.pointer, c.grab)
135+ }
136+ var focus bool
137+ for len(cmds) > 0 {
138+ if f, ok := (<-cmds).(ports.PointerFocus); ok && f == (ports.PointerFocus{}) {
139+ focus = true
140+ }
141+ }
142+ if !focus {
143+ t.Fatal("pointer focus not reset")
144+ }
145+}
@@ -122,3 +122,24 @@ func TestUnmanagedHitAllocations(t *testing.T) {
122 t.Fatalf("hit allocs = %v", n)122 t.Fatalf("hit allocs = %v", n)
123 }123 }
124 }124 }
125+
126+func TestUnmanagedUnmapDuringGrabClearsPointer(t *testing.T) {
127+ c := publishRig(t, 1)
128+ mapUnmanaged(t, c, 100, 10, 10, 50, 40, false)
129+ cmds := make(chan ports.ClientCommand, 64)
130+ c.ch.Commands = cmds
131+ c.pointer, c.grab = 100, 100
132+ c.clientEvent(context.Background(), ports.UnmanagedUnmapped{ID: 100})
133+ if c.pointer == 100 || c.grab != 0 {
134+ t.Fatalf("pointer %d grab %d left on the dead window", c.pointer, c.grab)
135+ }
136+ var focus bool
137+ for len(cmds) > 0 {
138+ if f, ok := (<-cmds).(ports.PointerFocus); ok && f == (ports.PointerFocus{}) {
139+ focus = true
140+ }
141+ }
142+ if !focus {
143+ t.Fatal("pointer focus not reset")
144+ }
145+}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 25

Tags 10

↑↓ moveenter openesc close