win32u: Use named adapters instead of struct gdi_adapter.

This commit is contained in:
Rémi Bernon 2024-03-27 08:57:10 +01:00 committed by Alexandre Julliard
parent 00a0c97879
commit fecfb44240
9 changed files with 50 additions and 70 deletions

View file

@ -1294,11 +1294,11 @@ static BOOL write_adapter_to_registry( const struct adapter *adapter, HKEY *adap
return TRUE;
}
static void add_adapter( const struct gdi_adapter *adapter, void *param )
static void add_adapter( const char *name, UINT state_flags, void *param )
{
struct device_manager_ctx *ctx = param;
TRACE( "\n" );
TRACE( "name %s, state_flags %#x\n", name, state_flags );
if (ctx->adapter_key)
{
@ -1309,11 +1309,11 @@ static void add_adapter( const struct gdi_adapter *adapter, void *param )
memset( &ctx->adapter, 0, sizeof(ctx->adapter) );
ctx->adapter.gpu = &ctx->gpu;
ctx->adapter.id = ctx->adapter_count;
ctx->adapter.state_flags = adapter->state_flags;
ctx->adapter.state_flags = state_flags;
/* Wine specific config key where adapter settings will be held, symlinked with the logically indexed config key */
sprintf( ctx->adapter.path, "%s\\%s\\Video\\%s\\Adapters\\%04x", config_keyA,
control_keyA + strlen( "\\Registry\\Machine" ), ctx->gpu.guid, ctx->gpu.adapter_count );
/* Wine specific config key where source settings will be held, symlinked with the logically indexed config key */
sprintf( ctx->adapter.path, "%s\\%s\\Video\\%s\\Sources\\%s", config_keyA,
control_keyA + strlen( "\\Registry\\Machine" ), ctx->gpu.guid, name );
if (!write_adapter_to_registry( &ctx->adapter, &ctx->adapter_key ))
WARN( "Failed to write adapter to registry\n" );
@ -1444,12 +1444,9 @@ static void add_mode( const DEVMODEW *mode, BOOL current, void *param )
if (!ctx->gpu.adapter_count)
{
static const struct gdi_adapter default_adapter =
{
.state_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE,
};
TRACE( "adding default fake adapter\n" );
add_adapter( &default_adapter, ctx );
static const DWORD source_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE;
TRACE( "adding default fake source\n" );
add_adapter( "Default", source_flags, ctx );
}
nopos_mode = *mode;
@ -1755,11 +1752,8 @@ static BOOL default_update_display_devices( const struct gdi_device_manager *man
{ .dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY,
.dmBitsPerPel = 16, .dmPelsWidth = 1024, .dmPelsHeight = 768, .dmDisplayFrequency = 60, },
};
static const DWORD source_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE;
static const struct gdi_gpu gpu;
static const struct gdi_adapter adapter =
{
.state_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE,
};
struct gdi_monitor monitor = {0};
DEVMODEW mode = {{0}};
UINT i;
@ -1767,7 +1761,7 @@ static BOOL default_update_display_devices( const struct gdi_device_manager *man
if (!force) return TRUE;
manager->add_gpu( &gpu, ctx );
manager->add_adapter( &adapter, ctx );
manager->add_adapter( "Default", source_flags, ctx );
if (!read_adapter_mode( ctx->adapter_key, ENUM_CURRENT_SETTINGS, &mode ))
{
@ -1831,10 +1825,10 @@ static void desktop_add_gpu( const struct gdi_gpu *gpu, void *param )
{
}
static void desktop_add_adapter( const struct gdi_adapter *adapter, void *param )
static void desktop_add_adapter( const char *name, UINT state_flags, void *param )
{
struct device_manager_ctx *ctx = param;
ctx->is_primary = !!(adapter->state_flags & DISPLAY_DEVICE_PRIMARY_DEVICE);
ctx->is_primary = !!(state_flags & DISPLAY_DEVICE_PRIMARY_DEVICE);
}
static void desktop_add_monitor( const struct gdi_monitor *monitor, void *param )
@ -1863,11 +1857,8 @@ static const struct gdi_device_manager desktop_device_manager =
static BOOL desktop_update_display_devices( BOOL force, struct device_manager_ctx *ctx )
{
static const DWORD source_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE;
static const struct gdi_gpu gpu;
static const struct gdi_adapter adapter =
{
.state_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE,
};
struct gdi_monitor monitor = {0};
static struct screen_size
{
@ -1932,7 +1923,7 @@ static BOOL desktop_update_display_devices( BOOL force, struct device_manager_ct
}
add_gpu( &gpu, ctx );
add_adapter( &adapter, ctx );
add_adapter( "Default", source_flags, ctx );
if (!read_adapter_mode( ctx->adapter_key, ENUM_CURRENT_SETTINGS, &current ))
{
current = mode;

View file

@ -273,11 +273,8 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag
{
if (force || force_display_devices_refresh)
{
static const DWORD source_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE;
static const struct gdi_gpu gpu;
static const struct gdi_adapter adapter =
{
.state_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE,
};
struct gdi_monitor gdi_monitor =
{
.rc_monitor = virtual_screen_rect,
@ -290,7 +287,7 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag
.dmBitsPerPel = screen_bpp, .dmPelsWidth = screen_width, .dmPelsHeight = screen_height, .dmDisplayFrequency = 60,
};
device_manager->add_gpu( &gpu, param );
device_manager->add_adapter( &adapter, param );
device_manager->add_adapter( "Default", source_flags, param );
device_manager->add_monitor( &gdi_monitor, param );
device_manager->add_mode( &mode, TRUE, param );
force_display_devices_refresh = FALSE;

View file

@ -1178,12 +1178,10 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
for (adapter = adapters; adapter < adapters + adapter_count; adapter++)
{
DEVMODEW current_mode = { .dmSize = sizeof(current_mode) };
struct gdi_adapter gdi_adapter =
{
.id = adapter->id,
.state_flags = adapter->state_flags,
};
device_manager->add_adapter( &gdi_adapter, param );
char buffer[32];
sprintf( buffer, "%04x", adapter->id );
device_manager->add_adapter( buffer, adapter->state_flags, param );
if (macdrv_get_monitors(adapter->id, &monitors, &monitor_count)) break;
TRACE("adapter: %#x, monitor count: %d\n", adapter->id, monitor_count);

View file

@ -211,18 +211,11 @@ 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, UINT state_flags, struct output_info *output_info)
{
struct gdi_adapter adapter;
adapter.id = output_id;
adapter.state_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP;
if (output_id == 0)
adapter.state_flags |= DISPLAY_DEVICE_PRIMARY_DEVICE;
TRACE("id=0x%s state_flags=0x%x\n",
wine_dbgstr_longlong(adapter.id), (UINT)adapter.state_flags);
device_manager->add_adapter(&adapter, param);
TRACE("name=%s state_flags=0x%x\n",
output_info->output->name, state_flags);
device_manager->add_adapter(output_info->output->name, state_flags, param);
}
static void wayland_add_device_monitor(const struct gdi_device_manager *device_manager,
@ -283,7 +276,7 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage
BOOL force, void *param)
{
struct wayland_output *output;
INT output_id = 0;
DWORD state_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE;
struct wl_array output_info_array;
struct output_info *output_info;
@ -312,10 +305,10 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage
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, state_flags, output_info);
wayland_add_device_monitor(device_manager, param, output_info);
wayland_add_device_modes(device_manager, param, output_info);
output_id++;
state_flags &= ~DISPLAY_DEVICE_PRIMARY_DEVICE;
}
wl_array_release(&output_info_array);

View file

@ -397,7 +397,7 @@ RECT get_host_primary_monitor_rect(void)
{
INT gpu_count, adapter_count, monitor_count;
struct gdi_gpu *gpus = NULL;
struct gdi_adapter *adapters = NULL;
struct x11drv_adapter *adapters = NULL;
struct gdi_monitor *monitors = NULL;
RECT rect = {0};
@ -515,7 +515,7 @@ static const char *debugstr_devmodew( const DEVMODEW *devmode )
BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, BOOL force, void *param )
{
struct gdi_adapter *adapters;
struct x11drv_adapter *adapters;
struct gdi_monitor *monitors;
struct gdi_gpu *gpus;
INT gpu_count, adapter_count, monitor_count;
@ -548,7 +548,8 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
x11drv_settings_id settings_id;
BOOL is_primary = adapters[adapter].state_flags & DISPLAY_DEVICE_PRIMARY_DEVICE;
device_manager->add_adapter( &adapters[adapter], param );
sprintf( buffer, "%04lx", adapters[adapter].id );
device_manager->add_adapter( buffer, adapters[adapter].state_flags, param );
if (!host_handler.get_monitors( adapters[adapter].id, &monitors, &monitor_count )) break;
TRACE("adapter: %#lx, monitor count: %d\n", adapters[adapter].id, monitor_count);

View file

@ -761,6 +761,12 @@ void init_user_driver(void);
/* X11 display device handler. Used to initialize display device registry data */
struct x11drv_adapter
{
ULONG_PTR id;
DWORD state_flags;
};
/* Required functions for display device registry initialization */
struct x11drv_display_device_handler
{
@ -779,7 +785,7 @@ struct x11drv_display_device_handler
* The first adapter has to be primary if GPU is primary.
*
* Return FALSE on failure with parameters unchanged */
BOOL (*get_adapters)(ULONG_PTR gpu_id, struct gdi_adapter **adapters, int *count);
BOOL (*get_adapters)(ULONG_PTR gpu_id, struct x11drv_adapter **adapters, int *count);
/* get_monitors will be called to get a list of monitors in EnumDisplayDevices context under an adapter.
* The first monitor has to be primary if adapter is primary.
@ -791,7 +797,7 @@ struct x11drv_display_device_handler
void (*free_gpus)(struct gdi_gpu *gpus);
/* free_adapters will be called to free an adapter list from get_adapters */
void (*free_adapters)(struct gdi_adapter *adapters);
void (*free_adapters)(struct x11drv_adapter *adapters);
/* free_monitors will be called to free a monitor list from get_monitors */
void (*free_monitors)(struct gdi_monitor *monitors, int count);

View file

@ -213,9 +213,9 @@ static void xinerama_free_gpus( struct gdi_gpu *gpus )
free( gpus );
}
static BOOL xinerama_get_adapters( ULONG_PTR gpu_id, struct gdi_adapter **new_adapters, int *count )
static BOOL xinerama_get_adapters( ULONG_PTR gpu_id, struct x11drv_adapter **new_adapters, int *count )
{
struct gdi_adapter *adapters = NULL;
struct x11drv_adapter *adapters = NULL;
INT index = 0;
INT i, j;
INT primary_index;
@ -268,7 +268,7 @@ static BOOL xinerama_get_adapters( ULONG_PTR gpu_id, struct gdi_adapter **new_ad
/* Primary adapter has to be first */
if (primary_index)
{
struct gdi_adapter tmp;
struct x11drv_adapter tmp;
tmp = adapters[primary_index];
adapters[primary_index] = adapters[0];
adapters[0] = tmp;
@ -280,7 +280,7 @@ static BOOL xinerama_get_adapters( ULONG_PTR gpu_id, struct gdi_adapter **new_ad
return TRUE;
}
static void xinerama_free_adapters( struct gdi_adapter *adapters )
static void xinerama_free_adapters( struct x11drv_adapter *adapters )
{
free( adapters );
}

View file

@ -863,9 +863,9 @@ static void xrandr14_free_gpus( struct gdi_gpu *gpus )
free( gpus );
}
static BOOL xrandr14_get_adapters( ULONG_PTR gpu_id, struct gdi_adapter **new_adapters, int *count )
static BOOL xrandr14_get_adapters( ULONG_PTR gpu_id, struct x11drv_adapter **new_adapters, int *count )
{
struct gdi_adapter *adapters = NULL;
struct x11drv_adapter *adapters = NULL;
XRRScreenResources *screen_resources = NULL;
XRRProviderInfo *provider_info = NULL;
XRRCrtcInfo *enum_crtc_info, *crtc_info = NULL;
@ -999,7 +999,7 @@ static BOOL xrandr14_get_adapters( ULONG_PTR gpu_id, struct gdi_adapter **new_ad
/* Make primary adapter the first */
if (primary_adapter)
{
struct gdi_adapter tmp = adapters[0];
struct x11drv_adapter tmp = adapters[0];
adapters[0] = adapters[primary_adapter];
adapters[primary_adapter] = tmp;
}
@ -1024,7 +1024,7 @@ done:
return ret;
}
static void xrandr14_free_adapters( struct gdi_adapter *adapters )
static void xrandr14_free_adapters( struct x11drv_adapter *adapters )
{
free( adapters );
}
@ -1219,7 +1219,7 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s
struct current_mode *tmp_modes, *new_current_modes = NULL;
INT gpu_count, adapter_count, new_current_mode_count = 0;
INT gpu_idx, adapter_idx, display_idx;
struct gdi_adapter *adapters;
struct x11drv_adapter *adapters;
struct gdi_gpu *gpus;
WCHAR *end;

View file

@ -249,12 +249,6 @@ struct gdi_gpu
ULONGLONG memory_size;
};
struct gdi_adapter
{
ULONG_PTR id;
DWORD state_flags;
};
struct gdi_monitor
{
RECT rc_monitor; /* RcMonitor in MONITORINFO struct */
@ -266,7 +260,7 @@ struct gdi_monitor
struct gdi_device_manager
{
void (*add_gpu)( const struct gdi_gpu *gpu, void *param );
void (*add_adapter)( const struct gdi_adapter *adapter, void *param );
void (*add_adapter)( const char *name, UINT state_flags, void *param );
void (*add_monitor)( const struct gdi_monitor *monitor, void *param );
void (*add_mode)( const DEVMODEW *mode, BOOL current, void *param );
};