From: Alexandros Frantzis alexandros.frantzis@collabora.com
Introduce per-thread data for GUI enabled threads. For now we create the per-thread data only for the desktop window. --- dlls/winewayland.drv/Makefile.in | 1 + dlls/winewayland.drv/waylanddrv.h | 12 +++++++ dlls/winewayland.drv/waylanddrv_main.c | 44 +++++++++++++++++++++++++ dlls/winewayland.drv/window.c | 45 ++++++++++++++++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 dlls/winewayland.drv/window.c
diff --git a/dlls/winewayland.drv/Makefile.in b/dlls/winewayland.drv/Makefile.in index 3f9c052f2b0..454a7e5a4b4 100644 --- a/dlls/winewayland.drv/Makefile.in +++ b/dlls/winewayland.drv/Makefile.in @@ -10,4 +10,5 @@ SOURCES = \ wayland.c \ wayland_output.c \ waylanddrv_main.c \ + window.c \ xdg-output-unstable-v1.xml diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 600fcfce355..c05a1818211 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -86,12 +86,23 @@ struct wayland_output struct wayland_output_state current; };
+struct wayland_thread_data +{ + DWORD dummy; +}; + /********************************************************************** * Wayland initialization */
BOOL wayland_process_init(void) DECLSPEC_HIDDEN; void wayland_init_display_devices(BOOL force) DECLSPEC_HIDDEN; +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 output @@ -105,6 +116,7 @@ void wayland_output_use_xdg_extension(struct wayland_output *output) DECLSPEC_HI * USER driver functions */
+BOOL WAYLAND_CreateWindow(HWND hwnd) DECLSPEC_HIDDEN; BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manager, BOOL force, void *param) DECLSPEC_HIDDEN;
diff --git a/dlls/winewayland.drv/waylanddrv_main.c b/dlls/winewayland.drv/waylanddrv_main.c index a578db76c66..2afdea23332 100644 --- a/dlls/winewayland.drv/waylanddrv_main.c +++ b/dlls/winewayland.drv/waylanddrv_main.c @@ -29,8 +29,52 @@
#include "waylanddrv.h"
+#include "wine/debug.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 *thread = wayland_thread_data(); + + if (thread) return thread; + + if (!(thread = calloc(1, sizeof(*thread)))) + { + ERR("Failed to allocate space for thread data\n"); + NtTerminateProcess(0, 1); + } + + NtUserGetThreadInfo()->driver_data = (UINT_PTR)thread; + + return thread; +} + +/*********************************************************************** + * ThreadDetach (WAYLAND.@) + */ +static void WAYLAND_ThreadDetach(void) +{ + struct wayland_thread_data *thread = wayland_thread_data(); + + if (thread) + { + free(thread); + /* 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, .pUpdateDisplayDevices = WAYLAND_UpdateDisplayDevices, };
diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c new file mode 100644 index 00000000000..039a27fbecf --- /dev/null +++ b/dlls/winewayland.drv/window.c @@ -0,0 +1,45 @@ +/* + * Wayland driver + * + * 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()) wayland_init_thread_data(); + + return TRUE; +}