From: Alexandros Frantzis <alexandros.frantzis(a)collabora.com> Handle allocation and deallocation of per-thread data (currently without any actual contents). Signed-off-by: Alexandros Frantzis <alexandros.frantzis(a)collabora.com> --- dlls/winewayland.drv/Makefile.in | 2 +- dlls/winewayland.drv/waylanddrv.h | 20 +++++++++ dlls/winewayland.drv/waylanddrv_main.c | 59 +++++++++++++++++++++++++- 3 files changed, 79 insertions(+), 2 deletions(-) diff --git a/dlls/winewayland.drv/Makefile.in b/dlls/winewayland.drv/Makefile.in index fc1fe8119ec..ba460fcc792 100644 --- a/dlls/winewayland.drv/Makefile.in +++ b/dlls/winewayland.drv/Makefile.in @@ -1,7 +1,7 @@ MODULE = winewayland.drv UNIXLIB = winewayland.so UNIX_CFLAGS = $(WAYLAND_CLIENT_CFLAGS) -UNIX_LIBS = $(WAYLAND_CLIENT_LIBS) +UNIX_LIBS = -lwin32u $(WAYLAND_CLIENT_LIBS) C_SRCS = \ dllmain.c \ diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 3fd8728d81b..057eb3f8350 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -25,8 +25,13 @@ # error You must include config.h to use this header #endif +#include <stdarg.h> #include <wayland-client.h> +#include "windef.h" +#include "winbase.h" +#include "ntuser.h" + #include "unixlib.h" /********************************************************************** @@ -35,6 +40,21 @@ extern struct wl_display *process_wl_display DECLSPEC_HIDDEN; +/********************************************************************** + * Wayland thread data + */ + +struct wayland_thread_data +{ +}; + +extern struct wayland_thread_data *wayland_init_thread_data(void) DECLSPEC_HIDDEN; + +static inline struct wayland_thread_data *wayland_thread_data(void) +{ + return (struct wayland_thread_data *)(UINT_PTR)NtUserGetThreadInfo()->driver_data; +} + /********************************************************************** * Wayland initialization */ diff --git a/dlls/winewayland.drv/waylanddrv_main.c b/dlls/winewayland.drv/waylanddrv_main.c index d4018683239..10410157709 100644 --- a/dlls/winewayland.drv/waylanddrv_main.c +++ b/dlls/winewayland.drv/waylanddrv_main.c @@ -29,11 +29,68 @@ #include "waylanddrv.h" +#include "wine/debug.h" +#include "wine/gdi_driver.h" + +#include <stdlib.h> + +WINE_DEFAULT_DEBUG_CHANNEL(waylanddrv); + +/*********************************************************************** + * Initialize per thread data + */ +struct wayland_thread_data *wayland_init_thread_data(void) +{ + struct wayland_thread_data *data = wayland_thread_data(); + + if (data) return data; + + if (!(data = calloc(1, sizeof(*data)))) + { + ERR("could not create data\n"); + NtTerminateProcess(0, 1); + } + + NtUserGetThreadInfo()->driver_data = (UINT_PTR)data; + + return data; +} + +/*********************************************************************** + * ThreadDetach (WAYLAND.@) + */ +static void WAYLAND_ThreadDetach(void) +{ + struct wayland_thread_data *data = wayland_thread_data(); + + if (data) + { + free(data); + /* clear data in case we get re-entered from user32 before the thread is truly dead */ + NtUserGetThreadInfo()->driver_data = 0; + } +} + +static const struct user_driver_funcs waylanddrv_funcs = +{ + .pThreadDetach = WAYLAND_ThreadDetach, +}; + +static const struct user_driver_funcs null_funcs = { 0 }; + static NTSTATUS waylanddrv_unix_init(void *arg) { - if (!wayland_process_init()) return STATUS_UNSUCCESSFUL; + /* Set the user driver functions now so that they are available during + * our initialization. We clear them on error. */ + __wine_set_user_driver(&waylanddrv_funcs, WINE_GDI_DRIVER_VERSION); + + if (!wayland_process_init()) goto err; return 0; + +err: + __wine_set_user_driver(&null_funcs, WINE_GDI_DRIVER_VERSION); + return STATUS_UNSUCCESSFUL; } const unixlib_entry_t __wine_unix_call_funcs[] = -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/2275