From: Alexandros Frantzis alexandros.frantzis@collabora.com
Since non-desktop processes rely on the shared memory region to get display information, they don't need to access wl_output objects themselves for now.
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- dlls/winewayland.drv/display.c | 11 +---------- dlls/winewayland.drv/wayland.c | 3 +++ dlls/winewayland.drv/waylanddrv.h | 6 ++++++ dlls/winewayland.drv/waylanddrv_main.c | 25 +++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index 640829142c1..354e10162ca 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -111,16 +111,7 @@ static void wayland_refresh_display_devices(void)
void wayland_init_display_devices(void) { - struct ntuser_thread_info *thread_info = NtUserGetThreadInfo(); - DWORD current_pid = GetCurrentProcessId(); - HWND desktop_hwnd = UlongToHandle(thread_info->top_window); - DWORD desktop_pid = 0; - - if (desktop_hwnd) NtUserGetWindowThread(desktop_hwnd, &desktop_pid); - - /* Refresh devices only from the desktop window process. */ - if (!desktop_pid || current_pid == desktop_pid) - wayland_refresh_display_devices(); + wayland_refresh_display_devices(); }
static void wayland_add_device_gpu(const struct gdi_device_manager *device_manager, diff --git a/dlls/winewayland.drv/wayland.c b/dlls/winewayland.drv/wayland.c index 30ef22df52d..2eb58fb7139 100644 --- a/dlls/winewayland.drv/wayland.c +++ b/dlls/winewayland.drv/wayland.c @@ -45,6 +45,9 @@ static void registry_handle_global(void *data, struct wl_registry *registry, { TRACE("interface=%s version=%u id=%u\n", interface, version, id);
+ /* For now only the desktop process needs wl_output objects. */ + if (GetCurrentProcessId() != get_desktop_process_id()) return; + if (strcmp(interface, "wl_output") == 0) { if (!wayland_output_create(id, version)) diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 794cff2b0dd..2f1a83ee542 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -89,6 +89,12 @@ BOOL wayland_output_create(uint32_t id, uint32_t version) DECLSPEC_HIDDEN; void wayland_output_destroy(struct wayland_output *output) DECLSPEC_HIDDEN; void wayland_output_use_xdg_extension(struct wayland_output *output) DECLSPEC_HIDDEN;
+/********************************************************************** + * USER32 helpers + */ + +DWORD get_desktop_process_id(void) DECLSPEC_HIDDEN; + /********************************************************************** * USER driver functions */ diff --git a/dlls/winewayland.drv/waylanddrv_main.c b/dlls/winewayland.drv/waylanddrv_main.c index d83314cd74f..cb9702c4564 100644 --- a/dlls/winewayland.drv/waylanddrv_main.c +++ b/dlls/winewayland.drv/waylanddrv_main.c @@ -27,8 +27,33 @@ #include "ntstatus.h" #define WIN32_NO_STATUS
+#include "wine/server.h" + #include "waylanddrv.h"
+DWORD get_desktop_process_id(void) +{ + struct ntuser_thread_info *thread_info = NtUserGetThreadInfo(); + HWND desktop_hwnd = UlongToHandle(thread_info->top_window); + DWORD desktop_pid; + + /* The thread information may not have been updated yet, so also query + * the server directly to be certain. */ + if (!desktop_hwnd) + { + SERVER_START_REQ(get_desktop_window) + { + req->force = 0; + if (!wine_server_call(req)) + desktop_hwnd = UlongToHandle(reply->top_window); + } + SERVER_END_REQ; + } + + return NtUserGetWindowThread(desktop_hwnd, &desktop_pid) ? + desktop_pid : GetCurrentProcessId(); +} + static const struct user_driver_funcs waylanddrv_funcs = { .pGetCurrentDisplaySettings = WAYLAND_GetCurrentDisplaySettings,