From: Alexandros Frantzis alexandros.frantzis@collabora.com
--- dlls/winewayland.drv/Makefile.in | 1 + dlls/winewayland.drv/wayland.c | 9 ++++ dlls/winewayland.drv/wayland_data_device.c | 48 ++++++++++++++++++++++ dlls/winewayland.drv/waylanddrv.h | 14 +++++++ 4 files changed, 72 insertions(+) create mode 100644 dlls/winewayland.drv/wayland_data_device.c
diff --git a/dlls/winewayland.drv/Makefile.in b/dlls/winewayland.drv/Makefile.in index 9ad1ad6889d..2db42eaba09 100644 --- a/dlls/winewayland.drv/Makefile.in +++ b/dlls/winewayland.drv/Makefile.in @@ -13,6 +13,7 @@ SOURCES = \ viewporter.xml \ vulkan.c \ wayland.c \ + wayland_data_device.c \ wayland_keyboard.c \ wayland_output.c \ wayland_pointer.c \ diff --git a/dlls/winewayland.drv/wayland.c b/dlls/winewayland.drv/wayland.c index 9432dc934c9..046f6d0f138 100644 --- a/dlls/winewayland.drv/wayland.c +++ b/dlls/winewayland.drv/wayland.c @@ -143,6 +143,7 @@ static void registry_handle_global(void *data, struct wl_registry *registry, seat->global_id = id; wl_seat_add_listener(seat->wl_seat, &seat_listener, NULL); pthread_mutex_unlock(&seat->mutex); + if (process_wayland.wl_data_device_manager) wayland_data_device_init(); } else if (strcmp(interface, "wp_viewporter") == 0) { @@ -164,6 +165,13 @@ static void registry_handle_global(void *data, struct wl_registry *registry, process_wayland.zwp_relative_pointer_manager_v1 = wl_registry_bind(registry, id, &zwp_relative_pointer_manager_v1_interface, 1); } + else if (strcmp(interface, "wl_data_device_manager") == 0) + { + process_wayland.wl_data_device_manager = + wl_registry_bind(registry, id, &wl_data_device_manager_interface, + version < 3 ? version : 3); + if (process_wayland.seat.wl_seat) wayland_data_device_init(); + } }
static void registry_handle_global_remove(void *data, struct wl_registry *registry, @@ -189,6 +197,7 @@ static void registry_handle_global_remove(void *data, struct wl_registry *regist { TRACE("removing seat\n"); if (process_wayland.pointer.wl_pointer) wayland_pointer_deinit(); + if (process_wayland.data_device.wl_data_device) wayland_data_device_deinit(); pthread_mutex_lock(&seat->mutex); wl_seat_release(seat->wl_seat); seat->wl_seat = NULL; diff --git a/dlls/winewayland.drv/wayland_data_device.c b/dlls/winewayland.drv/wayland_data_device.c new file mode 100644 index 00000000000..94d7ac7f36b --- /dev/null +++ b/dlls/winewayland.drv/wayland_data_device.c @@ -0,0 +1,48 @@ +/* + * Wayland data device + * + * Copyright 2025 Alexandros Frantzis for Collabora Ltd + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#if 0 +#pragma makedep unix +#endif + +#include "config.h" + +#include "waylanddrv.h" + +void wayland_data_device_init(void) +{ + struct wayland_data_device *data_device = &process_wayland.data_device; + + data_device->wl_data_device = + wl_data_device_manager_get_data_device(process_wayland.wl_data_device_manager, + process_wayland.seat.wl_seat); +} + +void wayland_data_device_deinit(void) +{ + struct wayland_data_device *data_device = &process_wayland.data_device; + + if (wl_data_device_get_version(data_device->wl_data_device) < 2) + wl_data_device_destroy(data_device->wl_data_device); + else + wl_data_device_release(data_device->wl_data_device); + + data_device->wl_data_device = NULL; +} diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 72a37cb3ffb..51a5ddce2f5 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -118,6 +118,11 @@ struct wayland_seat pthread_mutex_t mutex; };
+struct wayland_data_device +{ + struct wl_data_device *wl_data_device; +}; + struct wayland { BOOL initialized; @@ -132,9 +137,11 @@ struct wayland struct wl_subcompositor *wl_subcompositor; struct zwp_pointer_constraints_v1 *zwp_pointer_constraints_v1; struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1; + struct wl_data_device_manager *wl_data_device_manager; struct wayland_seat seat; struct wayland_keyboard keyboard; struct wayland_pointer pointer; + struct wayland_data_device data_device; struct wl_list output_list; /* Protects the output_list and the wayland_output.current states. */ pthread_mutex_t output_mutex; @@ -340,6 +347,13 @@ void wayland_pointer_init(struct wl_pointer *wl_pointer); void wayland_pointer_deinit(void); void wayland_pointer_clear_constraint(void);
+/********************************************************************** + * Wayland data device + */ + +void wayland_data_device_init(void); +void wayland_data_device_deinit(void); + /********************************************************************** * OpenGL */