From: Alexandros Frantzis alexandros.frantzis@collabora.com
Update the desktop window size to match the current virtual screen rect.
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- dlls/winewayland.drv/Makefile.in | 3 +- dlls/winewayland.drv/display.c | 3 ++ dlls/winewayland.drv/waylanddrv.h | 15 +++++++- dlls/winewayland.drv/waylanddrv_main.c | 7 ++-- dlls/winewayland.drv/window.c | 50 ++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 dlls/winewayland.drv/window.c
diff --git a/dlls/winewayland.drv/Makefile.in b/dlls/winewayland.drv/Makefile.in index faa6186db21..013d0ca9c87 100644 --- a/dlls/winewayland.drv/Makefile.in +++ b/dlls/winewayland.drv/Makefile.in @@ -8,7 +8,8 @@ C_SRCS = \ dllmain.c \ wayland.c \ wayland_output.c \ - waylanddrv_main.c + waylanddrv_main.c \ + window.c
WAYLAND_PROTOCOL_SRCS = \ xdg-output-unstable-v1.xml diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index 8c637e35442..aa75cc25057 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -163,8 +163,11 @@ static void wayland_init_registry_display_settings(void)
void wayland_init_display_devices(void) { + HWND desktop_hwnd = get_desktop_window(); + wayland_refresh_display_devices(); wayland_init_registry_display_settings(); + if (desktop_hwnd) send_message(desktop_hwnd, WM_DISPLAYCHANGE, 0, 0); }
static void wayland_add_device_gpu(const struct gdi_device_manager *device_manager, diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 492976a5070..38501b470e7 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -96,12 +96,25 @@ void wayland_output_use_xdg_extension(struct wayland_output *output) DECLSPEC_HI * USER32 helpers */
-DWORD get_desktop_process_id(void) DECLSPEC_HIDDEN; +HWND get_desktop_window(void) DECLSPEC_HIDDEN; + +static inline DWORD get_desktop_process_id(void) +{ + DWORD desktop_pid; + return NtUserGetWindowThread(get_desktop_window(), &desktop_pid) ? + desktop_pid : GetCurrentProcessId(); +} + +static inline LRESULT send_message(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + return NtUserMessageCall(hwnd, msg, wparam, lparam, NULL, NtUserSendDriverMessage, FALSE); +}
/********************************************************************** * USER driver functions */
+LRESULT WAYLAND_DesktopWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) DECLSPEC_HIDDEN; BOOL WAYLAND_GetCurrentDisplaySettings(LPCWSTR name, BOOL is_primary, LPDEVMODEW devmode) DECLSPEC_HIDDEN; BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manager, diff --git a/dlls/winewayland.drv/waylanddrv_main.c b/dlls/winewayland.drv/waylanddrv_main.c index cb9702c4564..d267e43068c 100644 --- a/dlls/winewayland.drv/waylanddrv_main.c +++ b/dlls/winewayland.drv/waylanddrv_main.c @@ -31,11 +31,10 @@
#include "waylanddrv.h"
-DWORD get_desktop_process_id(void) +HWND get_desktop_window(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. */ @@ -50,12 +49,12 @@ DWORD get_desktop_process_id(void) SERVER_END_REQ; }
- return NtUserGetWindowThread(desktop_hwnd, &desktop_pid) ? - desktop_pid : GetCurrentProcessId(); + return desktop_hwnd; }
static const struct user_driver_funcs waylanddrv_funcs = { + .pDesktopWindowProc = WAYLAND_DesktopWindowProc, .pGetCurrentDisplaySettings = WAYLAND_GetCurrentDisplaySettings, .pUpdateDisplayDevices = WAYLAND_UpdateDisplayDevices, }; diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c new file mode 100644 index 00000000000..7d56d9b3b02 --- /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 "ntuser.h" + +/********************************************************************** + * WAYLAND_DesktopWindowProc + */ +LRESULT WAYLAND_DesktopWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) +{ + switch (msg) + { + case WM_DISPLAYCHANGE: + { + RECT virtual_rect = NtUserGetVirtualScreenRect(); + NtUserSetWindowPos(hwnd, 0, virtual_rect.left, virtual_rect.top, + virtual_rect.right - virtual_rect.left, + virtual_rect.bottom - virtual_rect.top, + SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE); + } + break; + } + + return NtUserMessageCall(hwnd, msg, wp, lp, 0, NtUserDefWindowProc, FALSE); +}