diff options
Diffstat (limited to '4947.patch')
-rw-r--r-- | 4947.patch | 1017 |
1 files changed, 0 insertions, 1017 deletions
diff --git a/4947.patch b/4947.patch deleted file mode 100644 index db17ead5d5a5..000000000000 --- a/4947.patch +++ /dev/null @@ -1,1017 +0,0 @@ -From ee42a8156180a15b24efc9e5c2a14935befb9d1d Mon Sep 17 00:00:00 2001 -From: Alexandros Frantzis <alexandros.frantzis@collabora.com> -Date: Tue, 16 Jan 2024 10:40:15 +0200 -Subject: [PATCH 1/7] winewayland.drv: Advertise common display modes. - -The reporting of non-current wl_output modes is deprecated, and most -compositors now report only the current display mode. - -Since Wayland doesn't allow clients to directly change the hardware -display mode, we can safely make some common display modes available to -applications. ---- - dlls/winewayland.drv/wayland_output.c | 94 ++++++++++++++++++++++++--- - 1 file changed, 85 insertions(+), 9 deletions(-) - -diff --git a/dlls/winewayland.drv/wayland_output.c b/dlls/winewayland.drv/wayland_output.c -index f5941c10f6f..0dfc1d974e4 100644 ---- a/dlls/winewayland.drv/wayland_output.c -+++ b/dlls/winewayland.drv/wayland_output.c -@@ -40,6 +40,54 @@ static uint32_t next_output_id = 0; - #define WAYLAND_OUTPUT_CHANGED_LOGICAL_XY 0x04 - #define WAYLAND_OUTPUT_CHANGED_LOGICAL_WH 0x08 - -+static const struct { int32_t width; int32_t height; } common_modes[] = { -+ { 320, 200}, /* CGA 16:10 */ -+ { 320, 240}, /* QVGA 4:3 */ -+ { 400, 300}, /* qSVGA 4:3 */ -+ { 480, 320}, /* HVGA 3:2 */ -+ { 512, 384}, /* MAC 4:3 */ -+ { 640, 360}, /* nHD 16:9 */ -+ { 640, 400}, /* VESA-0100h 16:10 */ -+ { 640, 480}, /* VGA 4:3 */ -+ { 720, 480}, /* WVGA 3:2 */ -+ { 720, 576}, /* PAL 5:4 */ -+ { 768, 480}, /* WVGA 16:10 */ -+ { 768, 576}, /* PAL* 4:3 */ -+ { 800, 600}, /* SVGA 4:3 */ -+ { 854, 480}, /* FWVGA 16:9 */ -+ { 960, 540}, /* qHD 16:9 */ -+ { 960, 640}, /* DVGA 3:2 */ -+ {1024, 576}, /* WSVGA 16:9 */ -+ {1024, 640}, /* WSVGA 16:10 */ -+ {1024, 768}, /* XGA 4:3 */ -+ {1152, 864}, /* XGA+ 4:3 */ -+ {1280, 720}, /* HD 16:9 */ -+ {1280, 768}, /* WXGA 5:3 */ -+ {1280, 800}, /* WXGA 16:10 */ -+ {1280, 960}, /* SXGA- 4:3 */ -+ {1280, 1024}, /* SXGA 5:4 */ -+ {1366, 768}, /* FWXGA 16:9 */ -+ {1400, 1050}, /* SXGA+ 4:3 */ -+ {1440, 900}, /* WSXGA 16:10 */ -+ {1600, 900}, /* HD+ 16:9 */ -+ {1600, 1200}, /* UXGA 4:3 */ -+ {1680, 1050}, /* WSXGA+ 16:10 */ -+ {1920, 1080}, /* FHD 16:9 */ -+ {1920, 1200}, /* WUXGA 16:10 */ -+ {2048, 1152}, /* QWXGA 16:9 */ -+ {2048, 1536}, /* QXGA 4:3 */ -+ {2560, 1440}, /* QHD 16:9 */ -+ {2560, 1600}, /* WQXGA 16:10 */ -+ {2560, 2048}, /* QSXGA 5:4 */ -+ {2880, 1620}, /* 3K 16:9 */ -+ {3200, 1800}, /* QHD+ 16:9 */ -+ {3200, 2400}, /* QUXGA 4:3 */ -+ {3840, 2160}, /* 4K 16:9 */ -+ {3840, 2400}, /* WQUXGA 16:10 */ -+ {5120, 2880}, /* 5K 16:9 */ -+ {7680, 4320}, /* 8K 16:9 */ -+}; -+ - /********************************************************************** - * Output handling - */ -@@ -102,6 +150,31 @@ static void wayland_output_state_add_mode(struct wayland_output_state *state, - if (current) state->current_mode = mode; - } - -+static void wayland_output_state_add_common_modes(struct wayland_output_state *state) -+{ -+ int i; -+ -+ for (i = 0; i < ARRAY_SIZE(common_modes); i++) -+ { -+ int32_t width = common_modes[i].width; -+ int32_t height = common_modes[i].height; -+ -+ /* Skip if this mode is larger than the current (native) mode. */ -+ if (width > state->current_mode->width || -+ height > state->current_mode->height) -+ { -+ TRACE("Skipping mode %dx%d (current: %dx%d)\n", -+ width, height, state->current_mode->width, -+ state->current_mode->height); -+ continue; -+ } -+ -+ wayland_output_state_add_mode(state, width, height, -+ state->current_mode->refresh, -+ FALSE); -+ } -+} -+ - static void maybe_init_display_devices(void) - { - DWORD desktop_pid = 0; -@@ -136,14 +209,15 @@ static void wayland_output_done(struct wayland_output *output) - - if (output->pending_flags & WAYLAND_OUTPUT_CHANGED_MODES) - { -- RB_FOR_EACH_ENTRY(mode, &output->pending.modes, struct wayland_output_mode, entry) -- { -- wayland_output_state_add_mode(&output->current, -- mode->width, mode->height, mode->refresh, -- mode == output->pending.current_mode); -- } -- rb_destroy(&output->pending.modes, wayland_output_mode_free_rb, NULL); -+ rb_destroy(&output->current.modes, wayland_output_mode_free_rb, NULL); -+ output->current.modes = output->pending.modes; -+ output->current.current_mode = output->pending.current_mode; -+ if (!output->current.current_mode) -+ WARN("No current mode reported by compositor\n"); -+ else -+ wayland_output_state_add_common_modes(&output->current); - rb_init(&output->pending.modes, wayland_output_mode_cmp_rb); -+ output->pending.current_mode = NULL; - } - - if (output->pending_flags & WAYLAND_OUTPUT_CHANGED_NAME) -@@ -206,11 +280,13 @@ static void output_handle_mode(void *data, struct wl_output *wl_output, - { - struct wayland_output *output = data; - -+ /* Non-current mode information is deprecated. */ -+ if (!(flags & WL_OUTPUT_MODE_CURRENT)) return; -+ - /* Windows apps don't expect a zero refresh rate, so use a default value. */ - if (refresh == 0) refresh = default_refresh; - -- wayland_output_state_add_mode(&output->pending, width, height, refresh, -- (flags & WL_OUTPUT_MODE_CURRENT)); -+ wayland_output_state_add_mode(&output->pending, width, height, refresh, TRUE); - - output->pending_flags |= WAYLAND_OUTPUT_CHANGED_MODES; - } --- -GitLab - - -From a5deba20bed30dcbace5d234def95fdcd17e79ec Mon Sep 17 00:00:00 2001 -From: Alexandros Frantzis <alexandros.frantzis@collabora.com> -Date: Thu, 25 Jan 2024 10:41:45 +0200 -Subject: [PATCH 2/7] winewayland.drv: Advertise display modes for 8 bpp and 16 - bpp. - ---- - dlls/winewayland.drv/display.c | 28 ++++++++++++++++++---------- - 1 file changed, 18 insertions(+), 10 deletions(-) - -diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c -index ebe151ffab0..a8fcaf2a2f5 100644 ---- a/dlls/winewayland.drv/display.c -+++ b/dlls/winewayland.drv/display.c -@@ -246,13 +246,14 @@ static void wayland_add_device_monitor(const struct gdi_device_manager *device_m - device_manager->add_monitor(&monitor, param); - } - --static void populate_devmode(struct wayland_output_mode *output_mode, DEVMODEW *mode) -+static void populate_devmode(struct wayland_output_mode *output_mode, DWORD bpp, -+ DEVMODEW *mode) - { - mode->dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | - DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY; - mode->dmDisplayOrientation = DMDO_DEFAULT; - mode->dmDisplayFlags = 0; -- mode->dmBitsPerPel = 32; -+ mode->dmBitsPerPel = bpp; - mode->dmPelsWidth = output_mode->width; - mode->dmPelsHeight = output_mode->height; - mode->dmDisplayFrequency = output_mode->refresh / 1000; -@@ -261,21 +262,28 @@ static void populate_devmode(struct wayland_output_mode *output_mode, DEVMODEW * - static void wayland_add_device_modes(const struct gdi_device_manager *device_manager, - void *param, struct output_info *output_info) - { -+ static const DWORD bpps[] = {32, 16, 8}; - struct wayland_output_mode *output_mode; -+ int i; - - RB_FOR_EACH_ENTRY(output_mode, &output_info->output->modes, - struct wayland_output_mode, entry) - { -- DEVMODEW mode = {.dmSize = sizeof(mode)}; -- BOOL mode_is_current = output_mode == output_info->output->current_mode; -- populate_devmode(output_mode, &mode); -- if (mode_is_current) -+ for (i = 0; i < ARRAY_SIZE(bpps); i++) - { -- mode.dmFields |= DM_POSITION; -- mode.dmPosition.x = output_info->x; -- mode.dmPosition.y = output_info->y; -+ DEVMODEW mode = {.dmSize = sizeof(mode)}; -+ BOOL mode_is_current = output_mode == output_info->output->current_mode && -+ bpps[i] == 32; -+ -+ populate_devmode(output_mode, bpps[i], &mode); -+ if (mode_is_current) -+ { -+ mode.dmFields |= DM_POSITION; -+ mode.dmPosition.x = output_info->x; -+ mode.dmPosition.y = output_info->y; -+ } -+ device_manager->add_mode(&mode, mode_is_current, param); - } -- device_manager->add_mode(&mode, mode_is_current, param); - } - } - --- -GitLab - - -From bac33e2f0f91891cc508905b61c23538e224c633 Mon Sep 17 00:00:00 2001 -From: Alexandros Frantzis <alexandros.frantzis@collabora.com> -Date: Fri, 26 Jan 2024 11:19:11 +0200 -Subject: [PATCH 3/7] winewayland.drv: Dissociate current display mode from - Wayland native mode. - -Refactor output_info to dissociate the current display mode from the -Wayland native display mode, in preparation for handling display mode changes. ---- - dlls/winewayland.drv/display.c | 36 ++++++++++++++++++++++------------ - 1 file changed, 23 insertions(+), 13 deletions(-) - -diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c -index a8fcaf2a2f5..888c6e5aabb 100644 ---- a/dlls/winewayland.drv/display.c -+++ b/dlls/winewayland.drv/display.c -@@ -51,6 +51,8 @@ struct output_info - { - int x, y; - struct wayland_output_state *output; -+ struct wayland_output_mode *mode; -+ UINT bpp; - }; - - static int output_info_cmp_primary_x_y(const void *va, const void *vb) -@@ -71,10 +73,10 @@ static int output_info_cmp_primary_x_y(const void *va, const void *vb) - - static inline BOOL output_info_overlap(struct output_info *a, struct output_info *b) - { -- return b->x < a->x + a->output->current_mode->width && -- b->x + b->output->current_mode->width > a->x && -- b->y < a->y + a->output->current_mode->height && -- b->y + b->output->current_mode->height > a->y; -+ return b->x < a->x + a->mode->width && -+ b->x + b->mode->width > a->x && -+ b->y < a->y + a->mode->height && -+ b->y + b->mode->height > a->y; - } - - /* Map a point to one of the four quadrants of our 2d coordinate space: -@@ -156,16 +158,16 @@ static BOOL output_info_array_resolve_overlaps(struct wl_array *output_info_arra - rel_x = (move->output->logical_x - anchor->output->logical_x + - (x_use_end ? move->output->logical_w : 0)) / - (double)anchor->output->logical_w; -- move->x = anchor->x + anchor->output->current_mode->width * rel_x - -- (x_use_end ? move->output->current_mode->width : 0); -+ move->x = anchor->x + anchor->mode->width * rel_x - -+ (x_use_end ? move->mode->width : 0); - - /* Similarly for the Y axis. */ - y_use_end = move->output->logical_y < anchor->output->logical_y; - rel_y = (move->output->logical_y - anchor->output->logical_y + - (y_use_end ? move->output->logical_h : 0)) / - (double)anchor->output->logical_h; -- move->y = anchor->y + anchor->output->current_mode->height * rel_y - -- (y_use_end ? move->output->current_mode->height : 0); -+ move->y = anchor->y + anchor->mode->height * rel_y - -+ (y_use_end ? move->mode->height : 0); - } - } - -@@ -231,8 +233,8 @@ static void wayland_add_device_monitor(const struct gdi_device_manager *device_m - struct gdi_monitor monitor = {0}; - - SetRect(&monitor.rc_monitor, output_info->x, output_info->y, -- output_info->x + output_info->output->current_mode->width, -- output_info->y + output_info->output->current_mode->height); -+ output_info->x + output_info->mode->width, -+ output_info->y + output_info->mode->height); - - /* We don't have a direct way to get the work area in Wayland. */ - monitor.rc_work = monitor.rc_monitor; -@@ -272,8 +274,8 @@ static void wayland_add_device_modes(const struct gdi_device_manager *device_man - for (i = 0; i < ARRAY_SIZE(bpps); i++) - { - DEVMODEW mode = {.dmSize = sizeof(mode)}; -- BOOL mode_is_current = output_mode == output_info->output->current_mode && -- bpps[i] == 32; -+ BOOL mode_is_current = output_mode == output_info->mode && -+ bpps[i] == output_info->bpp; - - populate_devmode(output_mode, bpps[i], &mode); - if (mode_is_current) -@@ -287,6 +289,14 @@ static void wayland_add_device_modes(const struct gdi_device_manager *device_man - } - } - -+static void output_info_init(struct output_info *output_info, -+ struct wayland_output *output) -+{ -+ output_info->output = &output->current; -+ output_info->mode = output->current.current_mode; -+ output_info->bpp = 32; -+} -+ - /*********************************************************************** - * UpdateDisplayDevices (WAYLAND.@) - */ -@@ -312,7 +322,7 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage - { - if (!output->current.current_mode) continue; - output_info = wl_array_add(&output_info_array, sizeof(*output_info)); -- if (output_info) output_info->output = &output->current; -+ if (output_info) output_info_init(output_info, output); - else ERR("Failed to allocate space for output_info\n"); - } - --- -GitLab - - -From 8b38be18592fb0538efee64a46e4de9a7321d34b Mon Sep 17 00:00:00 2001 -From: Alexandros Frantzis <alexandros.frantzis@collabora.com> -Date: Thu, 25 Jan 2024 12:06:54 +0200 -Subject: [PATCH 4/7] winewayland.drv: Respect current device mode on display - device updates. - -Since Wayland doesn't support mode changes, we let win32u handle them by -just recording them in the registry, and we use that information as the -authoritative source for the current mode when updating the devices. ---- - dlls/win32u/sysparams.c | 29 ++++++++++++++++++++- - dlls/winewayland.drv/display.c | 47 +++++++++++++++++++++++++++++++--- - include/wine/gdi_driver.h | 1 + - 3 files changed, 72 insertions(+), 5 deletions(-) - -diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c -index e2c5b10da9e..694c41cb317 100644 ---- a/dlls/win32u/sysparams.c -+++ b/dlls/win32u/sysparams.c -@@ -1253,8 +1253,8 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) - { - ctx->mutex = get_display_device_init_mutex(); - pthread_mutex_lock( &display_lock ); -- prepare_devices(); - } -+ if (gpu_index == 0) prepare_devices(); - - sprintf( buffer, "PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X\\%08X", - gpu->vendor_id, gpu->device_id, gpu->subsys_id, gpu->revision_id, gpu_index ); -@@ -1634,12 +1634,33 @@ static void add_mode( const DEVMODEW *mode, BOOL current, void *param ) - } - } - -+static struct display_device *find_adapter_device_by_id( UINT index ); -+ -+static BOOL get_adapter( UINT adapter_idx, DEVMODEW *mode, void *param ) -+{ -+ struct device_manager_ctx *ctx = param; -+ struct display_device *device; -+ struct adapter *adapter = NULL; -+ -+ if (!ctx->mutex) -+ { -+ ctx->mutex = get_display_device_init_mutex(); -+ pthread_mutex_lock( &display_lock ); -+ } -+ -+ if (!(device = find_adapter_device_by_id( adapter_idx ))) return FALSE; -+ adapter = CONTAINING_RECORD( device, struct adapter, dev ); -+ -+ return adapter_get_current_settings( adapter, mode ); -+} -+ - static const struct gdi_device_manager device_manager = - { - add_gpu, - add_adapter, - add_monitor, - add_mode, -+ get_adapter, - }; - - static void reset_display_manager_ctx( struct device_manager_ctx *ctx ) -@@ -1899,12 +1920,18 @@ static void desktop_add_mode( const DEVMODEW *mode, BOOL current, void *param ) - } - } - -+static BOOL desktop_get_adapter( UINT id, DEVMODEW *mode, void *param ) -+{ -+ return FALSE; -+} -+ - static const struct gdi_device_manager desktop_device_manager = - { - desktop_add_gpu, - desktop_add_adapter, - desktop_add_monitor, - desktop_add_mode, -+ desktop_get_adapter, - }; - - static BOOL desktop_update_display_devices( BOOL force, struct device_manager_ctx *ctx ) -diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c -index 888c6e5aabb..584732a73db 100644 ---- a/dlls/winewayland.drv/display.c -+++ b/dlls/winewayland.drv/display.c -@@ -289,12 +289,47 @@ static void wayland_add_device_modes(const struct gdi_device_manager *device_man - } - } - -+static struct wayland_output_mode *get_matching_output_mode(struct wayland_output *output, -+ DEVMODEW *devmode) -+{ -+ struct wayland_output_mode *output_mode; -+ -+ RB_FOR_EACH_ENTRY(output_mode, &output->current.modes, -+ struct wayland_output_mode, entry) -+ { -+ if (devmode->dmPelsWidth == output_mode->width && -+ devmode->dmPelsHeight == output_mode->height && -+ output_mode->refresh / 1000 == devmode->dmDisplayFrequency) -+ { -+ return output_mode; -+ } -+ } -+ -+ return NULL; -+} -+ - static void output_info_init(struct output_info *output_info, -- struct wayland_output *output) -+ struct wayland_output *output, -+ int adapter_id, -+ const struct gdi_device_manager *device_manager, -+ void *param) - { -+ DEVMODEW devmode = {.dmSize = sizeof(devmode)}; -+ struct wayland_output_mode *mode; -+ - output_info->output = &output->current; -- output_info->mode = output->current.current_mode; -- output_info->bpp = 32; -+ -+ if (device_manager->get_adapter(adapter_id, &devmode, param) && -+ (mode = get_matching_output_mode(output, &devmode))) -+ { -+ output_info->mode = mode; -+ output_info->bpp = devmode.dmBitsPerPel; -+ } -+ else -+ { -+ output_info->mode = output->current.current_mode; -+ output_info->bpp = 32; -+ } - } - - /*********************************************************************** -@@ -322,8 +357,11 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage - { - if (!output->current.current_mode) continue; - output_info = wl_array_add(&output_info_array, sizeof(*output_info)); -- if (output_info) output_info_init(output_info, output); -+ /* TODO: Don't assume that the order of devices matches the order -+ * of the outputs in the list. */ -+ if (output_info) output_info_init(output_info, output, output_id, device_manager, param); - else ERR("Failed to allocate space for output_info\n"); -+ output_id++; - } - - output_info_array_arrange_physical_coords(&output_info_array); -@@ -331,6 +369,7 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage - /* Populate GDI devices. */ - wayland_add_device_gpu(device_manager, param); - -+ output_id = 0; - wl_array_for_each(output_info, &output_info_array) - { - wayland_add_device_adapter(device_manager, param, output_id); -diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h -index bd827c31cb1..d3679377344 100644 ---- a/include/wine/gdi_driver.h -+++ b/include/wine/gdi_driver.h -@@ -275,6 +275,7 @@ struct gdi_device_manager - void (*add_adapter)( const struct gdi_adapter *adapter, void *param ); - void (*add_monitor)( const struct gdi_monitor *monitor, void *param ); - void (*add_mode)( const DEVMODEW *mode, BOOL current, void *param ); -+ BOOL (*get_adapter)( UINT id, DEVMODEW *mode, void *param ); - }; - - #define WINE_DM_UNSUPPORTED 0x80000000 --- -GitLab - - -From 9252671be93e24ab266ee7b1f996748b1e34b0b9 Mon Sep 17 00:00:00 2001 -From: Alexandros Frantzis <alexandros.frantzis@collabora.com> -Date: Tue, 16 Jan 2024 10:36:58 +0200 -Subject: [PATCH 5/7] winewayland.drv: Associate each GDI adapter with its - Wayland output. - -Introduce and use driver data for GDI adapters to associate each -adapter with its corresponding Wayland output. - -Use this association to ensure we get the proper current display -mode for each output, when updating the display devices. ---- - dlls/win32u/sysparams.c | 36 +++++++++++++++++++++++--- - dlls/winewayland.drv/display.c | 47 +++++++++++++++++++++++----------- - include/wine/gdi_driver.h | 4 ++- - 3 files changed, 68 insertions(+), 19 deletions(-) - -diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c -index 694c41cb317..9b01c3c1513 100644 ---- a/dlls/win32u/sysparams.c -+++ b/dlls/win32u/sysparams.c -@@ -183,6 +183,7 @@ static const WCHAR linkedW[] = {'L','i','n','k','e','d',0}; - static const WCHAR symbolic_link_valueW[] = - {'S','y','m','b','o','l','i','c','L','i','n','k','V','a','l','u','e',0}; - static const WCHAR state_flagsW[] = {'S','t','a','t','e','F','l','a','g','s',0}; -+static const WCHAR driver_dataW[] = {'D','r','i','v','e','r','D','a','t','a',0}; - static const WCHAR gpu_idW[] = {'G','P','U','I','D',0}; - static const WCHAR hardware_idW[] = {'H','a','r','d','w','a','r','e','I','D',0}; - static const WCHAR device_descW[] = {'D','e','v','i','c','e','D','e','s','c',0}; -@@ -243,6 +244,8 @@ struct adapter - const WCHAR *config_key; - unsigned int mode_count; - DEVMODEW *modes; -+ unsigned char *driver_data; -+ UINT driver_data_len; - }; - - #define MONITOR_INFO_HAS_MONITOR_ID 0x00000001 -@@ -476,6 +479,7 @@ static void adapter_release( struct adapter *adapter ) - if (!InterlockedDecrement( &adapter->refcount )) - { - free( adapter->modes ); -+ free( adapter->driver_data ); - free( adapter ); - } - } -@@ -760,6 +764,21 @@ static BOOL read_display_adapter_settings( unsigned int index, struct adapter *i - if (query_reg_value( hkey, state_flagsW, value, sizeof(buffer) ) && value->Type == REG_DWORD) - info->dev.state_flags = *(const DWORD *)value->Data; - -+ /* DriverData */ -+ if (query_reg_value( hkey, driver_dataW, value, sizeof(buffer) ) && value->Type == REG_BINARY) -+ { -+ info->driver_data = malloc( value->DataLength ); -+ if (info->driver_data) -+ { -+ memcpy( info->driver_data, value->Data, value->DataLength ); -+ info->driver_data_len = value->DataLength; -+ } -+ else -+ { -+ info->driver_data_len = 0; -+ } -+ } -+ - /* Interface name */ - info->dev.interface_name[0] = 0; - -@@ -1479,6 +1498,11 @@ static void add_adapter( const struct gdi_adapter *adapter, void *param ) - (lstrlenW( ctx->gpuid ) + 1) * sizeof(WCHAR) ); - set_reg_value( ctx->adapter_key, state_flagsW, REG_DWORD, &adapter->state_flags, - sizeof(adapter->state_flags) ); -+ if (adapter->driver_data && adapter->driver_data_len) -+ { -+ set_reg_value( ctx->adapter_key, driver_dataW, REG_BINARY, -+ adapter->driver_data, adapter->driver_data_len ); -+ } - } - - static void add_monitor( const struct gdi_monitor *monitor, void *param ) -@@ -1636,7 +1660,7 @@ static void add_mode( const DEVMODEW *mode, BOOL current, void *param ) - - static struct display_device *find_adapter_device_by_id( UINT index ); - --static BOOL get_adapter( UINT adapter_idx, DEVMODEW *mode, void *param ) -+static BOOL get_adapter( UINT adapter_idx, DEVMODEW *mode, void *data, UINT *data_len, void *param ) - { - struct device_manager_ctx *ctx = param; - struct display_device *device; -@@ -1651,7 +1675,13 @@ static BOOL get_adapter( UINT adapter_idx, DEVMODEW *mode, void *param ) - if (!(device = find_adapter_device_by_id( adapter_idx ))) return FALSE; - adapter = CONTAINING_RECORD( device, struct adapter, dev ); - -- return adapter_get_current_settings( adapter, mode ); -+ if (!adapter_get_current_settings( adapter, mode )) return FALSE; -+ -+ *data_len = min( *data_len, adapter->driver_data_len ); -+ if (data && adapter->driver_data) -+ memcpy( data, adapter->driver_data, *data_len ); -+ -+ return TRUE; - } - - static const struct gdi_device_manager device_manager = -@@ -1920,7 +1950,7 @@ static void desktop_add_mode( const DEVMODEW *mode, BOOL current, void *param ) - } - } - --static BOOL desktop_get_adapter( UINT id, DEVMODEW *mode, void *param ) -+static BOOL desktop_get_adapter( UINT id, DEVMODEW *mode, void *data, UINT *data_len, void *param ) - { - return FALSE; - } -diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c -index 584732a73db..ab7f7599659 100644 ---- a/dlls/winewayland.drv/display.c -+++ b/dlls/winewayland.drv/display.c -@@ -47,6 +47,11 @@ void wayland_init_display_devices(BOOL force) - NtUserGetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &num_path, &num_mode); - } - -+struct wayland_adapter_data -+{ -+ char output_name[64]; -+}; -+ - struct output_info - { - int x, y; -@@ -213,14 +218,21 @@ static void wayland_add_device_gpu(const struct gdi_device_manager *device_manag - } - - static void wayland_add_device_adapter(const struct gdi_device_manager *device_manager, -- void *param, INT output_id) -+ void *param, INT output_id, -+ struct output_info *output_info) - { - struct gdi_adapter adapter; -+ struct wayland_adapter_data data; -+ - adapter.id = output_id; - adapter.state_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP; - if (output_id == 0) - adapter.state_flags |= DISPLAY_DEVICE_PRIMARY_DEVICE; - -+ lstrcpynA(data.output_name, output_info->output->name, sizeof(data.output_name)); -+ adapter.driver_data = &data; -+ adapter.driver_data_len = sizeof(data); -+ - TRACE("id=0x%s state_flags=0x%x\n", - wine_dbgstr_longlong(adapter.id), (UINT)adapter.state_flags); - -@@ -310,25 +322,32 @@ static struct wayland_output_mode *get_matching_output_mode(struct wayland_outpu - - static void output_info_init(struct output_info *output_info, - struct wayland_output *output, -- int adapter_id, - const struct gdi_device_manager *device_manager, - void *param) - { - DEVMODEW devmode = {.dmSize = sizeof(devmode)}; - struct wayland_output_mode *mode; -+ struct wayland_adapter_data data; -+ UINT data_len = sizeof(data); -+ UINT id = 0; - - output_info->output = &output->current; -+ output_info->mode = output->current.current_mode; -+ output_info->bpp = 32; - -- if (device_manager->get_adapter(adapter_id, &devmode, param) && -- (mode = get_matching_output_mode(output, &devmode))) -- { -- output_info->mode = mode; -- output_info->bpp = devmode.dmBitsPerPel; -- } -- else -+ while (device_manager->get_adapter(id, &devmode, &data, &data_len, param)) - { -- output_info->mode = output->current.current_mode; -- output_info->bpp = 32; -+ if (data_len == sizeof(data) && -+ !strcmp(output->current.name, data.output_name)) -+ { -+ if ((mode = get_matching_output_mode(output, &devmode))) -+ { -+ output_info->mode = mode; -+ output_info->bpp = devmode.dmBitsPerPel; -+ } -+ } -+ data_len = sizeof(data); -+ ++id; - } - } - -@@ -359,9 +378,8 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage - output_info = wl_array_add(&output_info_array, sizeof(*output_info)); - /* TODO: Don't assume that the order of devices matches the order - * of the outputs in the list. */ -- if (output_info) output_info_init(output_info, output, output_id, device_manager, param); -+ if (output_info) output_info_init(output_info, output, device_manager, param); - else ERR("Failed to allocate space for output_info\n"); -- output_id++; - } - - output_info_array_arrange_physical_coords(&output_info_array); -@@ -369,10 +387,9 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage - /* Populate GDI devices. */ - wayland_add_device_gpu(device_manager, param); - -- output_id = 0; - wl_array_for_each(output_info, &output_info_array) - { -- wayland_add_device_adapter(device_manager, param, output_id); -+ wayland_add_device_adapter(device_manager, param, output_id, output_info); - wayland_add_device_monitor(device_manager, param, output_info); - wayland_add_device_modes(device_manager, param, output_info); - output_id++; -diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h -index d3679377344..202a164d070 100644 ---- a/include/wine/gdi_driver.h -+++ b/include/wine/gdi_driver.h -@@ -258,6 +258,8 @@ struct gdi_adapter - { - ULONG_PTR id; - DWORD state_flags; -+ void *driver_data; -+ UINT driver_data_len; - }; - - struct gdi_monitor -@@ -275,7 +277,7 @@ struct gdi_device_manager - void (*add_adapter)( const struct gdi_adapter *adapter, void *param ); - void (*add_monitor)( const struct gdi_monitor *monitor, void *param ); - void (*add_mode)( const DEVMODEW *mode, BOOL current, void *param ); -- BOOL (*get_adapter)( UINT id, DEVMODEW *mode, void *param ); -+ BOOL (*get_adapter)( UINT id, DEVMODEW *mode, void *data, UINT *data_len, void *param ); - }; - - #define WINE_DM_UNSUPPORTED 0x80000000 --- -GitLab - - -From 0bd3a469e4745ce1c9474b63b2c5d5e68e4a4634 Mon Sep 17 00:00:00 2001 -From: Alexandros Frantzis <alexandros.frantzis@collabora.com> -Date: Thu, 25 Jan 2024 15:21:22 +0200 -Subject: [PATCH 6/7] winewayland.drv: Adjust window scaling based on the - monitor display mode. - -Emulate the visual effect of a display mode change, by scaling the window according -to the ratios of the native vs current mode. - -We provide the adapter scaling information to the driver as part of the adapter -driver data so it's consistent across all processes. ---- - dlls/win32u/main.c | 6 ++++++ - dlls/win32u/sysparams.c | 17 +++++++++++++++++ - dlls/win32u/win32syscalls.h | 14 ++++++++------ - dlls/win32u/win32u.spec | 1 + - dlls/winewayland.drv/display.c | 9 ++++----- - dlls/winewayland.drv/waylanddrv.h | 7 +++++++ - dlls/winewayland.drv/window.c | 17 +++++++++++++++++ - dlls/wow64win/user.c | 6 ++++++ - include/ntuser.h | 1 + - 9 files changed, 67 insertions(+), 11 deletions(-) - -diff --git a/dlls/win32u/main.c b/dlls/win32u/main.c -index 2dc66e5df11..432f3fa892a 100644 ---- a/dlls/win32u/main.c -+++ b/dlls/win32u/main.c -@@ -2140,6 +2140,12 @@ HWND SYSCALL_API NtUserWindowFromPoint( LONG x, LONG y ) - __ASM_SYSCALL_FUNC( __id_NtUserWindowFromPoint ); - } - -+BOOL SYSCALL_API __wine_get_adapter_driver_data( UNICODE_STRING *devname, -+ void *data, UINT *data_len ) -+{ -+ __ASM_SYSCALL_FUNC( __id___wine_get_adapter_driver_data ); -+} -+ - BOOL SYSCALL_API __wine_get_file_outline_text_metric( const WCHAR *path, TEXTMETRICW *otm, - UINT *em_square, WCHAR *face_name ) - { -diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c -index 9b01c3c1513..65437801970 100644 ---- a/dlls/win32u/sysparams.c -+++ b/dlls/win32u/sysparams.c -@@ -6631,3 +6631,20 @@ NTSTATUS WINAPI NtUserDisplayConfigGetDeviceInfo( DISPLAYCONFIG_DEVICE_INFO_HEAD - return STATUS_INVALID_PARAMETER; - } - } -+ -+void WINAPI __wine_get_adapter_driver_data( UNICODE_STRING *devname, void *data, UINT *data_len ) -+{ -+ struct adapter *adapter; -+ -+ if ((adapter = find_adapter( devname ))) -+ { -+ *data_len = min( *data_len, adapter->driver_data_len ); -+ if (data && adapter->driver_data) -+ memcpy( data, adapter->driver_data, *data_len ); -+ adapter_release( adapter ); -+ } -+ else -+ { -+ *data_len = 0; -+ } -+} -diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec -index 24dccb6ec1d..18c973941e1 100644 ---- a/dlls/win32u/win32u.spec -+++ b/dlls/win32u/win32u.spec -@@ -1323,3 +1323,4 @@ - @ stdcall -syscall __wine_get_icm_profile(long long ptr ptr) - @ stdcall -syscall __wine_get_file_outline_text_metric(wstr ptr ptr ptr) - @ stdcall -syscall __wine_send_input(long ptr ptr) -+@ stdcall -syscall __wine_get_adapter_driver_data(ptr ptr ptr) -diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c -index ab7f7599659..eba592a585e 100644 ---- a/dlls/winewayland.drv/display.c -+++ b/dlls/winewayland.drv/display.c -@@ -47,11 +47,6 @@ void wayland_init_display_devices(BOOL force) - NtUserGetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &num_path, &num_mode); - } - --struct wayland_adapter_data --{ -- char output_name[64]; --}; -- - struct output_info - { - int x, y; -@@ -230,6 +225,10 @@ static void wayland_add_device_adapter(const struct gdi_device_manager *device_m - adapter.state_flags |= DISPLAY_DEVICE_PRIMARY_DEVICE; - - lstrcpynA(data.output_name, output_info->output->name, sizeof(data.output_name)); -+ data.scale_width = ((double)output_info->output->current_mode->width) / -+ output_info->mode->width; -+ data.scale_height = ((double)output_info->output->current_mode->height) / -+ output_info->mode->height; - adapter.driver_data = &data; - adapter.driver_data_len = sizeof(data); - -diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h -index 0883c43f1ff..48de2fb8c3f 100644 ---- a/dlls/winewayland.drv/waylanddrv.h -+++ b/dlls/winewayland.drv/waylanddrv.h -@@ -215,6 +215,13 @@ struct wayland_shm_buffer - HRGN damage_region; - }; - -+struct wayland_adapter_data -+{ -+ char output_name[64]; -+ /* How much larger the native mode is compared to current mode. */ -+ double scale_width, scale_height; -+}; -+ - /********************************************************************** - * Wayland initialization - */ -diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c -index ac5da371e5c..ae63b66b83e 100644 ---- a/dlls/winewayland.drv/window.c -+++ b/dlls/winewayland.drv/window.c -@@ -162,6 +162,8 @@ static void wayland_win_data_get_config(struct wayland_win_data *data, - struct wayland_window_config *conf) - { - enum wayland_surface_config_state window_state = 0; -+ MONITORINFOEXW mi = {.cbSize = sizeof(mi)}; -+ HMONITOR hmon; - DWORD style; - - conf->rect = data->window_rect; -@@ -187,6 +189,21 @@ static void wayland_win_data_get_config(struct wayland_win_data *data, - conf->scale = NtUserGetDpiForWindow(data->hwnd) / 96.0; - conf->visible = (style & WS_VISIBLE) == WS_VISIBLE; - conf->managed = data->managed; -+ -+ /* Adjust the window scale for the current display mode. */ -+ if ((hmon = NtUserMonitorFromWindow(data->hwnd, MONITOR_DEFAULTTOPRIMARY)) && -+ NtUserGetMonitorInfo(hmon, (MONITORINFO *)&mi)) -+ { -+ struct wayland_adapter_data adapter_data; -+ UINT adapter_data_len = sizeof(adapter_data); -+ UNICODE_STRING dev; -+ -+ RtlInitUnicodeString(&dev, mi.szDevice); -+ __wine_get_adapter_driver_data(&dev, &adapter_data, &adapter_data_len); -+ -+ if (adapter_data_len == sizeof(adapter_data)) -+ conf->scale /= min(adapter_data.scale_width, adapter_data.scale_height); -+ } - } - - static void wayland_win_data_update_wayland_surface(struct wayland_win_data *data) -diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c -index 2dd811578f5..446856eecce 100644 ---- a/dlls/wow64win/user.c -+++ b/dlls/wow64win/user.c -@@ -4874,3 +4874,9 @@ NTSTATUS WINAPI wow64___wine_send_input( UINT *args ) - ERR( "not supported\n" ); - return 0; - } -+ -+NTSTATUS WINAPI wow64___wine_get_adapter_driver_data( UINT *args ) -+{ -+ ERR( "not supported\n" ); -+ return 0; -+} -diff --git a/include/ntuser.h b/include/ntuser.h -index 31b93ef36e9..70f46bf14b6 100644 ---- a/include/ntuser.h -+++ b/include/ntuser.h -@@ -1406,5 +1406,6 @@ static inline BOOL NtUserShowOwnedPopups( HWND hwnd, BOOL show ) - - /* Wine extensions */ - W32KAPI BOOL WINAPI __wine_send_input( HWND hwnd, const INPUT *input, const RAWINPUT *rawinput ); -+W32KAPI void WINAPI __wine_get_adapter_driver_data( UNICODE_STRING *devname, void *data, UINT *data_len ); - - #endif /* _NTUSER_ */ --- -GitLab - - -From 1aaeaeaac9a66ea5aaa66e5782d7d25fdfb1c7be Mon Sep 17 00:00:00 2001 -From: Alexandros Frantzis <alexandros.frantzis@collabora.com> -Date: Fri, 26 Jan 2024 16:04:15 +0200 -Subject: [PATCH 7/7] winewayland.drv: Refresh surfaces after display - configuration. - -Since a display reconfiguration may affect the compositor side scaling -which we apply to a surface, instruct all surfaces to refresh themselves -by committing an updated state based on the latest window state. ---- - dlls/winewayland.drv/display.c | 5 +++++ - dlls/winewayland.drv/waylanddrv.h | 1 + - dlls/winewayland.drv/window.c | 21 +++++++++++++++++++++ - 3 files changed, 27 insertions(+) - -diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c -index eba592a585e..3eb60354081 100644 ---- a/dlls/winewayland.drv/display.c -+++ b/dlls/winewayland.drv/display.c -@@ -398,5 +398,10 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage - - pthread_mutex_unlock(&process_wayland.output_mutex); - -+ /* Refresh all windows to ensure they have been committed with proper -+ * scaling applied. */ -+ if (process_wayland.initialized) -+ NtUserPostMessage(HWND_BROADCAST, WM_WAYLAND_REFRESH, 0, 0); -+ - return TRUE; - } -diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h -index 48de2fb8c3f..ae423047240 100644 ---- a/dlls/winewayland.drv/waylanddrv.h -+++ b/dlls/winewayland.drv/waylanddrv.h -@@ -62,6 +62,7 @@ enum wayland_window_message - WM_WAYLAND_INIT_DISPLAY_DEVICES = WM_WINE_FIRST_DRIVER_MSG, - WM_WAYLAND_CONFIGURE, - WM_WAYLAND_SET_FOREGROUND, -+ WM_WAYLAND_REFRESH, - }; - - enum wayland_surface_config_state -diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c -index ae63b66b83e..6695e3e3830 100644 ---- a/dlls/winewayland.drv/window.c -+++ b/dlls/winewayland.drv/window.c -@@ -631,6 +631,24 @@ static void wayland_configure_window(HWND hwnd) - NtUserSetWindowPos(hwnd, 0, 0, 0, window_width, window_height, flags); - } - -+static void wayland_refresh_window(HWND hwnd) -+{ -+ struct wayland_win_data *data; -+ -+ if (!(data = wayland_win_data_get(hwnd))) return; -+ -+ if (data->wayland_surface) -+ { -+ pthread_mutex_lock(&data->wayland_surface->mutex); -+ wayland_win_data_get_config(data, &data->wayland_surface->window); -+ if (wayland_surface_reconfigure(data->wayland_surface)) -+ wl_surface_commit(data->wayland_surface->wl_surface); -+ pthread_mutex_unlock(&data->wayland_surface->mutex); -+ } -+ -+ wayland_win_data_release(data); -+} -+ - /********************************************************************** - * WAYLAND_WindowMessage - */ -@@ -648,6 +666,9 @@ LRESULT WAYLAND_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) - case WM_WAYLAND_SET_FOREGROUND: - NtUserSetForegroundWindow(hwnd); - return 0; -+ case WM_WAYLAND_REFRESH: -+ wayland_refresh_window(hwnd); -+ return 0; - default: - FIXME("got window msg %x hwnd %p wp %lx lp %lx\n", msg, hwnd, (long)wp, lp); - return 0; --- -GitLab - |