swaywm / wlroots

A modular Wayland compositor library
https://gitlab.freedesktop.org/wlroots/wlroots/
MIT License
2.15k stars 342 forks source link

wl_keyboard.enter not sent when wl_seat is bound after focus #1948

Open ifreund opened 4 years ago

ifreund commented 4 years ago

The set_keyboard_interactivity(1) request for zwlr_layer_surface_v1@7 fails to grab keyboard focus in some cases, possibly because it is called before a wl_keyboard is set up.

WAYLAND_DEBUG log of this happening

``` -> wl_display@1: get_registry [NewId(2)] -> wl_display@1: sync [NewId(3)] <- wl_display@1: delete_id [Uint(3)] <- wl_registry@2: global [Uint(1), Str("wl_shm"), Uint(1)] <- wl_registry@2: global [Uint(2), Str("zwp_linux_dmabuf_v1"), Uint(3)] <- wl_registry@2: global [Uint(3), Str("wl_drm"), Uint(2)] <- wl_registry@2: global [Uint(4), Str("wl_compositor"), Uint(4)] <- wl_registry@2: global [Uint(5), Str("wl_subcompositor"), Uint(1)] <- wl_registry@2: global [Uint(6), Str("wl_data_device_manager"), Uint(3)] <- wl_registry@2: global [Uint(7), Str("zwlr_gamma_control_manager_v1"), Uint(1)] <- wl_registry@2: global [Uint(8), Str("gtk_primary_selection_device_manager"), Uint(1)] <- wl_registry@2: global [Uint(9), Str("zxdg_output_manager_v1"), Uint(3)] <- wl_registry@2: global [Uint(10), Str("org_kde_kwin_idle"), Uint(1)] <- wl_registry@2: global [Uint(11), Str("zwp_idle_inhibit_manager_v1"), Uint(1)] <- wl_registry@2: global [Uint(12), Str("zwlr_layer_shell_v1"), Uint(1)] <- wl_registry@2: global [Uint(13), Str("zxdg_shell_v6"), Uint(1)] <- wl_registry@2: global [Uint(14), Str("xdg_wm_base"), Uint(2)] <- wl_registry@2: global [Uint(15), Str("org_kde_kwin_server_decoration_manager"), Uint(1)] <- wl_registry@2: global [Uint(16), Str("zxdg_decoration_manager_v1"), Uint(1)] <- wl_registry@2: global [Uint(17), Str("zwp_relative_pointer_manager_v1"), Uint(1)] <- wl_registry@2: global [Uint(18), Str("zwp_pointer_constraints_v1"), Uint(1)] <- wl_registry@2: global [Uint(19), Str("wp_presentation"), Uint(1)] <- wl_registry@2: global [Uint(20), Str("zwlr_output_manager_v1"), Uint(1)] <- wl_registry@2: global [Uint(21), Str("zwlr_export_dmabuf_manager_v1"), Uint(1)] <- wl_registry@2: global [Uint(22), Str("zwlr_screencopy_manager_v1"), Uint(1)] <- wl_registry@2: global [Uint(23), Str("zwlr_data_control_manager_v1"), Uint(2)] <- wl_registry@2: global [Uint(24), Str("zwp_primary_selection_device_manager_v1"), Uint(1)] <- wl_registry@2: global [Uint(25), Str("zwp_virtual_keyboard_manager_v1"), Uint(1)] <- wl_registry@2: global [Uint(26), Str("zwlr_input_inhibit_manager_v1"), Uint(1)] <- wl_registry@2: global [Uint(27), Str("wl_seat"), Uint(7)] <- wl_registry@2: global [Uint(28), Str("wl_output"), Uint(3)] <- wl_callback@3: done [Uint(180662)] -> wl_registry@2: bind [Uint(1), Str("wl_shm"), Uint(1), NewId(3)] -> wl_registry@2: bind [Uint(4), Str("wl_compositor"), Uint(4), NewId(4)] -> wl_compositor@4: create_surface [NewId(5)] -> wl_registry@2: bind [Uint(12), Str("zwlr_layer_shell_v1"), Uint(1), NewId(6)] -> zwlr_layer_shell_v1@6: get_layer_surface [NewId(7), Object(5), Object(0), Uint(3), Str("rslock")] -> zwlr_layer_surface_v1@7: set_size [Uint(0), Uint(0)] -> zwlr_layer_surface_v1@7: set_anchor [Uint(15)] -> zwlr_layer_surface_v1@7: set_exclusive_zone [Int(-1)] -> zwlr_layer_surface_v1@7: set_keyboard_interactivity [Uint(1)] -> wl_surface@5: commit [] -> wl_registry@2: bind [Uint(27), Str("wl_seat"), Uint(7), NewId(8)] -> wl_shm@3: create_pool [NewId(9), Fd(4), Int(8294400)] -> wl_shm_pool@9: create_buffer [NewId(10), Int(0), Int(1920), Int(1080), Int(7680), Uint(0)] -> wl_display@1: sync [NewId(11)] <- wl_display@1: delete_id [Uint(11)] <- zwlr_layer_surface_v1@7: configure [Uint(180664), Uint(1920), Uint(1080)] -> zwlr_layer_surface_v1@7: ack_configure [Uint(180664)] -> zwlr_layer_surface_v1@7: set_keyboard_interactivity [Uint(1)] -> wl_surface@5: attach [Object(10), Int(0), Int(0)] -> wl_surface@5: damage [Int(0), Int(0), Int(1920), Int(1080)] -> wl_surface@5: commit [] -> wl_surface@5: frame [NewId(12)] <- wl_seat@8: name [Str("seat0")] <- wl_seat@8: capabilities [Uint(3)] -> wl_seat@8: get_keyboard [NewId(13)] <- wl_callback@11: done [Uint(180666)] <- wl_keyboard@13: keymap [Uint(1), Fd(5), Uint(47217)] <- wl_keyboard@13: repeat_info [Int(25), Int(600)] ```

Here is code that can reproduce the issue: https://github.com/ifreund/rslock/tree/9d5622bad951383aae976149b9e7f382b665f877


wlroots has migrated to gitlab.freedesktop.org. This issue has been moved to:

https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/1948

ifreund commented 4 years ago

Looks like only the wl_seat needs to be requested before calling set_keyboard_interactivity(1) to successfully get keyboard focus. The keyboard can be set up later

emersion commented 4 years ago

Okay. Fixing this is not trivial since we don't have a wlr_seat_client before the client binds to the seat.