///| Destroying a client's second wl_surface (e.g. an OAuth popup closing) must not send ///| zwp_text_input_v3.leave or wl_keyboard.leave referencing the destroyed surface when focus ///| returns to the client's remaining window. ///| test "destroying a second toplevel surface on the same client never sends leave for the gone surface" { let socket_path = "/tmp/wayland-moon-ti-destroy-" + @sys.getpid().to_string() + ".sock" let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap() let (a, shm_a, surf_a, xdg_a, _, _) = open_and_configure_client(comp, socket_path, "Main", "main") commit_shm_frame(comp, a, shm_a, surf_a, xdg_a, 1UL) assert_eq(comp.kbd_win, Some(1UL)) let (ti, kbd) = text_input_for(comp, a) ignore(drain_args(a)) // Open a second toplevel on the same client (simulating an OAuth popup). let comp_b = bind_global(a, 2U, "wl_compositor", 5U) let xdg_wm_b = bind_global(a, 2U, "xdg_wm_base", 5U) let surf_b = a.alloc_id() let w_cs = @wayland.WireWriter::new() w_cs.u32(surf_b) a.send(w_cs.finish_msg(comp_b, 0U)) let xdg_b = a.alloc_id() let w_xs = @wayland.WireWriter::new() w_xs.u32(xdg_b) w_xs.u32(surf_b) a.send(w_xs.finish_msg(xdg_wm_b, 2U)) let tl_b = a.alloc_id() let w_tl = @wayland.WireWriter::new() w_tl.u32(tl_b) a.send(w_tl.finish_msg(xdg_b, 1U)) let w_t = @wayland.WireWriter::new() w_t.str("Popup") a.send(w_t.finish_msg(tl_b, 2U)) let w_a = @wayland.WireWriter::new() w_a.str("popup") a.send(w_a.finish_msg(tl_b, 3U)) a.configure_serial = None a.configured_w = 0 a.configured_h = 0 a.send(@wayland.WireWriter::new().finish_msg(surf_b, 6U)) for _i = 0; _i < 20; _i = _i + 1 { comp.step() a.read_events(xdg_b, tl_b, 0U) if a.configure_serial is Some(_) && a.configured_w > 0 { break } @sys.sleep_ms(2) } commit_shm_frame(comp, a, shm_a, surf_b, xdg_b, 2UL) assert_eq(comp.kbd_win, Some(2UL)) text_input_state(comp, a, ti, true, 10, 10, 16) ignore(drain_args(a)) // Destroy the popup toplevel + xdg_surface + wl_surface together, as Electron/Ozone does on close. a.send(@wayland.WireWriter::new().finish_msg(tl_b, 0U)) a.send(@wayland.WireWriter::new().finish_msg(xdg_b, 0U)) a.send(@wayland.WireWriter::new().finish_msg(surf_b, 0U)) for _i = 0; _i < 5; _i = _i + 1 { comp.step() @sys.sleep_ms(2) } assert_eq(comp.kbd_win, Some(1UL)) let msgs = drain_args(a) let ti_leaves_gone = msgs.filter(m => m.0 == ti && m.1 == 1U && m.2.length() > 0 && m.2[0] == surf_b) let kbd_leaves_gone = msgs.filter(m => m.0 == kbd && m.1 == 2U && m.2.length() > 1 && m.2[1] == surf_b) let ti_enters_main = msgs.filter(m => m.0 == ti && m.1 == 0U && m.2.length() > 0 && m.2[0] == surf_a) assert_eq(ti_leaves_gone.length(), 0) assert_eq(kbd_leaves_gone.length(), 0) assert_true(ti_enters_main.length() >= 1) comp.close() }