From: Alexandros Frantzis alexandros.frantzis@collabora.com
Since non-desktop processes rely on the win32u internal current settings handling 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 | 15 ++++----------- dlls/winewayland.drv/wayland.c | 3 +++ dlls/winewayland.drv/waylanddrv.h | 6 ++++++ dlls/winewayland.drv/waylanddrv_main.c | 25 +++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 11 deletions(-)
diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index cd009c54a7a..adf981d92e6 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -44,16 +44,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, @@ -146,7 +137,9 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage struct wayland_output *output; INT output_id = 0;
- if (!force && !force_display_devices_refresh) return TRUE; + /* For now, update the display devices only when a compositor side update + * is received in the desktop window process. */ + if (!force_display_devices_refresh) return TRUE;
TRACE("force=%d force_refresh=%d\n", force, force_display_devices_refresh);
diff --git a/dlls/winewayland.drv/wayland.c b/dlls/winewayland.drv/wayland.c index 104a091ea80..2f728355438 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 941b4672d0d..77797c005c2 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -84,6 +84,12 @@ void wayland_init_display_devices(void) DECLSPEC_HIDDEN; BOOL wayland_output_create(uint32_t id, uint32_t version) DECLSPEC_HIDDEN; void wayland_output_destroy(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 35e7ecd3a6d..ec7efef9366 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,