This is to allow data device and text input to be used on seats that are hotplugged after vo init.
Unified · Split
| @@ -265,6 +265,8 @@ static void remove_feedback(struct vo_wayland_feedback_pool *fback_pool, · 264 unmodified lines | ||
| 265 | 265 | struct wp_presentation_feedback *fback); |
| 266 | 266 | static void remove_output(struct vo_wayland_output *out); |
| 267 | 267 | static void remove_seat(struct vo_wayland_seat *seat); |
| 268 | +static void seat_create_dnd_ddev(struct vo_wayland_seat *seat); | |
| 269 | +static void seat_create_text_input(struct vo_wayland_seat *seat); | |
| 268 | 270 | static void request_decoration_mode(struct vo_wayland_state *wl, uint32_t mode); |
| 269 | 271 | static void rescale_geometry(struct vo_wayland_state *wl, double old_scale); |
| 270 | 272 | static void set_geometry(struct vo_wayland_state *wl, bool resize); |
| @@ -1851,6 +1853,12 @@ static void registry_handle_add(void *data, struct wl_registry *reg, uint32_t id · 1580 unmodified lines | ||
| 1851 | 1853 | seat->seat = wl_registry_bind(reg, id, &wl_seat_interface, ver); |
| 1852 | 1854 | wl_seat_add_listener(seat->seat, &seat_listener, seat); |
| 1853 | 1855 | wl_list_insert(&wl->seat_list, &seat->link); |
| 1856 | + | |
| 1857 | + if (wl->devman) | |
| 1858 | + seat_create_dnd_ddev(seat); | |
| 1859 | + | |
| 1860 | + if (wl->text_input_manager) | |
| 1861 | + seat_create_text_input(seat); | |
| 1854 | 1862 | } |
| 1855 | 1863 | |
| 1856 | 1864 | if (!strcmp(interface, wl_shm_interface.name) && found++) { |
| @@ -2562,6 +2570,19 @@ static void remove_seat(struct vo_wayland_seat *seat) · 705 unmodified lines | ||
| 2562 | 2570 | return; |
| 2563 | 2571 | } |
| 2564 | 2572 | |
| 2573 | +static void seat_create_dnd_ddev(struct vo_wayland_seat *seat) | |
| 2574 | +{ | |
| 2575 | + seat->dnd_ddev = wl_data_device_manager_get_data_device(seat->wl->devman, seat->seat); | |
| 2576 | + wl_data_device_add_listener(seat->dnd_ddev, &data_device_listener, seat); | |
| 2577 | +} | |
| 2578 | + | |
| 2579 | +static void seat_create_text_input(struct vo_wayland_seat *seat) | |
| 2580 | +{ | |
| 2581 | + seat->text_input = talloc_zero(seat, struct vo_wayland_text_input); | |
| 2582 | + seat->text_input->text_input = zwp_text_input_manager_v3_get_text_input(seat->wl->text_input_manager, seat->seat); | |
| 2583 | + zwp_text_input_v3_add_listener(seat->text_input->text_input, &text_input_listener, seat); | |
| 2584 | +} | |
| 2585 | + | |
| 2565 | 2586 | static void reset_color_management(struct vo_wayland_state *wl) |
| 2566 | 2587 | { |
| 2567 | 2588 | if (!wl->color_surface) |
| @@ -3339,8 +3360,8 @@ bool vo_wayland_init(struct vo *vo) · 771 unmodified lines | ||
| 3339 | 3360 | if (wl->devman) { |
| 3340 | 3361 | struct vo_wayland_seat *seat; |
| 3341 | 3362 | wl_list_for_each(seat, &wl->seat_list, link) { |
| 3342 | − seat->dnd_ddev = wl_data_device_manager_get_data_device(wl->devman, seat->seat); | |
| 3343 | − wl_data_device_add_listener(seat->dnd_ddev, &data_device_listener, seat); | |
| 3363 | + if (!seat->dnd_ddev) | |
| 3364 | + seat_create_dnd_ddev(seat); | |
| 3344 | 3365 | } |
| 3345 | 3366 | } else { |
| 3346 | 3367 | MP_VERBOSE(wl, "Compositor doesn't support the %s (ver. 3) protocol!\n", |
| @@ -3382,9 +3403,8 @@ bool vo_wayland_init(struct vo *vo) · 35 unmodified lines | ||
| 3382 | 3403 | if (wl->text_input_manager) { |
| 3383 | 3404 | struct vo_wayland_seat *seat; |
| 3384 | 3405 | wl_list_for_each(seat, &wl->seat_list, link) { |
| 3385 | − seat->text_input = talloc_zero(seat, struct vo_wayland_text_input); | |
| 3386 | − seat->text_input->text_input = zwp_text_input_manager_v3_get_text_input(wl->text_input_manager, seat->seat); | |
| 3387 | − zwp_text_input_v3_add_listener(seat->text_input->text_input, &text_input_listener, seat); | |
| 3406 | + if (!seat->text_input) | |
| 3407 | + seat_create_text_input(seat); | |
| 3388 | 3408 | } |
| 3389 | 3409 | } else { |
| 3390 | 3410 | MP_VERBOSE(wl, "Compositor doesn't support the %s protocol!\n", |