History

video/out/wayland_common: create per-seat objects on seat hotplug

This is to allow data device and text input to be used on seats that are hotplugged after vo init.

Attila Fidan committed 1 year ago

Commit fbf366d1 parent a1424d51 file · +25 −5Browse files

Unified · Split

video/out/wayland_common.c+25−5
@@ -265,6 +265,8 @@ static void remove_feedback(struct vo_wayland_feedback_pool *fback_pool, · 264 unmodified lines
265265 struct wp_presentation_feedback *fback);
266266 static void remove_output(struct vo_wayland_output *out);
267267 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);
268270 static void request_decoration_mode(struct vo_wayland_state *wl, uint32_t mode);
269271 static void rescale_geometry(struct vo_wayland_state *wl, double old_scale);
270272 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
18511853 seat->seat = wl_registry_bind(reg, id, &wl_seat_interface, ver);
18521854 wl_seat_add_listener(seat->seat, &seat_listener, seat);
18531855 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);
18541862 }
18551863
18561864 if (!strcmp(interface, wl_shm_interface.name) && found++) {
@@ -2562,6 +2570,19 @@ static void remove_seat(struct vo_wayland_seat *seat) · 705 unmodified lines
25622570 return;
25632571 }
25642572
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+
25652586 static void reset_color_management(struct vo_wayland_state *wl)
25662587 {
25672588 if (!wl->color_surface)
@@ -3339,8 +3360,8 @@ bool vo_wayland_init(struct vo *vo) · 771 unmodified lines
33393360 if (wl->devman) {
33403361 struct vo_wayland_seat *seat;
33413362 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);
33443365 }
33453366 } else {
33463367 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
33823403 if (wl->text_input_manager) {
33833404 struct vo_wayland_seat *seat;
33843405 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);
33883408 }
33893409 } else {
33903410 MP_VERBOSE(wl, "Compositor doesn't support the %s protocol!\n",

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t