Text input: don't send leave for destroyed client surfaces
CI / test (push) Failing after 49s

- Drop text-input and keyboard focus references when a client destroys a wl_surface, without sending leave for it
- Skip wl_keyboard.leave and zwp_text_input_v3.leave/enter for surfaces the client no longer has
- Skip pointer enter/leave for missing subsurfaces or toplevels
- Add a regression test: closing a second toplevel (e.g. OAuth popup) must return focus to the main window without leaving stale events
This commit is contained in:
nandi committed 2026-11-28 23:33:17 -08:00
1 parent 444d67ac79
commit aa92aaac6f
3 files changed
+128 -16

No files matched your search

+28 -4
View File
@@ -113,11 +113,21 @@ fn send_text_input_surface(c : ClientConn, id : UInt, opcode : UInt, surface : U
fn text_inputs_enter(c : ClientConn, surface : UInt) -> Unit {
for id, ti in c.text_inputs {
if ti.surface != 0U && ti.surface != surface {
send_text_input_surface(c, id, 1U, ti.surface)
if c.surfaces.contains(ti.surface) {
send_text_input_surface(c, id, 1U, ti.surface)
}
ti.enabled = false
ti.cursor = None
}
if ti.surface != surface {
ti.surface = surface
send_text_input_surface(c, id, 0U, surface)
if c.surfaces.contains(surface) {
ti.surface = surface
send_text_input_surface(c, id, 0U, surface)
} else {
ti.surface = 0U
ti.enabled = false
ti.cursor = None
}
}
}
}
@@ -129,7 +139,21 @@ fn text_inputs_leave(c : ClientConn, surface : UInt) -> Unit {
ti.surface = 0U
// The client disables it in answer; until it commits that, it can't take text anyway.
ti.enabled = false
send_text_input_surface(c, id, 1U, surface)
ti.cursor = None
if c.surfaces.contains(surface) {
send_text_input_surface(c, id, 1U, surface)
}
}
}
}
///| A wl_surface was destroyed by the client: drop text-input references without sending `leave`.
fn text_inputs_surface_gone(c : ClientConn, surface : UInt) -> Unit {
for _, ti in c.text_inputs {
if ti.surface == surface {
ti.surface = 0U
ti.enabled = false
ti.cursor = None
}
}
}