From: Alexandros Frantzis alexandros.frantzis@collabora.com
Handle allocation and deallocation of per-thread data (currently without any actual contents), and initialize them for the desktop window thread.
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- dlls/winewayland.drv/Makefile.in | 3 +- dlls/winewayland.drv/waylanddrv.h | 26 ++++++++++++++ dlls/winewayland.drv/waylanddrv_main.c | 50 ++++++++++++++++++++++++++ dlls/winewayland.drv/window.c | 50 ++++++++++++++++++++++++++ 4 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 dlls/winewayland.drv/window.c
diff --git a/dlls/winewayland.drv/Makefile.in b/dlls/winewayland.drv/Makefile.in index fc1fe8119ec..b3ad75fb624 100644 --- a/dlls/winewayland.drv/Makefile.in +++ b/dlls/winewayland.drv/Makefile.in @@ -1,11 +1,12 @@ 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 \ wayland.c \ waylanddrv_main.c \ + window.c \
RC_SRCS = version.rc diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 3fd8728d81b..2b159a0a345 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,10 +40,31 @@
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 */
BOOL wayland_process_init(void) DECLSPEC_HIDDEN;
+/********************************************************************** + * USER driver functions + */ + +BOOL WAYLAND_CreateWindow(HWND hwnd) DECLSPEC_HIDDEN; + #endif /* __WINE_WAYLANDDRV_H */ diff --git a/dlls/winewayland.drv/waylanddrv_main.c b/dlls/winewayland.drv/waylanddrv_main.c index d4018683239..294e9101d06 100644 --- a/dlls/winewayland.drv/waylanddrv_main.c +++ b/dlls/winewayland.drv/waylanddrv_main.c @@ -29,10 +29,60 @@
#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 = +{ + .pCreateWindow = WAYLAND_CreateWindow, + .pThreadDetach = WAYLAND_ThreadDetach, +}; + static NTSTATUS waylanddrv_unix_init(void *arg) { if (!wayland_process_init()) return STATUS_UNSUCCESSFUL;
+ __wine_set_user_driver(&waylanddrv_funcs, WINE_GDI_DRIVER_VERSION); + return 0; }
diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c new file mode 100644 index 00000000000..54c40a32bbb --- /dev/null +++ b/dlls/winewayland.drv/window.c @@ -0,0 +1,50 @@ +/* + * Window related functions + * + * Copyright 2020 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" + +#include "wine/debug.h" + +#include "ntuser.h" + +WINE_DEFAULT_DEBUG_CHANNEL(waylanddrv); + +/********************************************************************** + * WAYLAND_CreateWindow + */ +BOOL WAYLAND_CreateWindow(HWND hwnd) +{ + TRACE("%p\n", hwnd); + + if (hwnd == NtUserGetDesktopWindow()) + { + /* Initialize wayland so that the desktop window thread has access + * to all the wayland related information (e.g., displays). */ + wayland_init_thread_data(); + } + + return TRUE; +}