Commit b112b4d4 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winex11.drv: Use the primary adapter info instead of calling back win32u.

parent 2fec6dd3
...@@ -123,13 +123,9 @@ BOOL is_virtual_desktop(void) ...@@ -123,13 +123,9 @@ BOOL is_virtual_desktop(void)
} }
/* Virtual desktop display settings handler */ /* Virtual desktop display settings handler */
static BOOL X11DRV_desktop_get_id( const WCHAR *device_name, ULONG_PTR *id ) static BOOL X11DRV_desktop_get_id( const WCHAR *device_name, BOOL is_primary, ULONG_PTR *id )
{ {
WCHAR primary_adapter[CCHDEVICENAME]; if (!is_primary) return FALSE;
if (!get_primary_adapter( primary_adapter ) || wcsicmp( primary_adapter, device_name ))
return FALSE;
*id = 0; *id = 0;
return TRUE; return TRUE;
} }
......
...@@ -66,14 +66,9 @@ void X11DRV_Settings_SetHandler(const struct x11drv_settings_handler *new_handle ...@@ -66,14 +66,9 @@ void X11DRV_Settings_SetHandler(const struct x11drv_settings_handler *new_handle
* Default handlers if resolution switching is not enabled * Default handlers if resolution switching is not enabled
* *
*/ */
static BOOL nores_get_id(const WCHAR *device_name, ULONG_PTR *id) static BOOL nores_get_id(const WCHAR *device_name, BOOL is_primary, ULONG_PTR *id)
{ {
WCHAR primary_adapter[CCHDEVICENAME]; *id = is_primary ? 1 : 0;
if (!get_primary_adapter( primary_adapter ))
return FALSE;
*id = !wcsicmp( device_name, primary_adapter ) ? 1 : 0;
return TRUE; return TRUE;
} }
...@@ -196,24 +191,6 @@ void init_registry_display_settings(void) ...@@ -196,24 +191,6 @@ void init_registry_display_settings(void)
} }
} }
BOOL get_primary_adapter(WCHAR *name)
{
DISPLAY_DEVICEW dd;
DWORD i;
dd.cb = sizeof(dd);
for (i = 0; !NtUserEnumDisplayDevices( NULL, i, &dd, 0 ); ++i)
{
if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
{
lstrcpyW(name, dd.DeviceName);
return TRUE;
}
}
return FALSE;
}
static void set_display_depth(ULONG_PTR display_id, DWORD depth) static void set_display_depth(ULONG_PTR display_id, DWORD depth)
{ {
struct x11drv_display_depth *display_depth; struct x11drv_display_depth *display_depth;
...@@ -271,7 +248,7 @@ BOOL X11DRV_GetCurrentDisplaySettings( LPCWSTR name, BOOL is_primary, LPDEVMODEW ...@@ -271,7 +248,7 @@ BOOL X11DRV_GetCurrentDisplaySettings( LPCWSTR name, BOOL is_primary, LPDEVMODEW
DEVMODEW mode; DEVMODEW mode;
ULONG_PTR id; ULONG_PTR id;
if (!settings_handler.get_id( name, &id ) || !settings_handler.get_current_mode( id, &mode )) if (!settings_handler.get_id( name, is_primary, &id ) || !settings_handler.get_current_mode( id, &mode ))
{ {
ERR("Failed to get %s current display settings.\n", wine_dbgstr_w(name)); ERR("Failed to get %s current display settings.\n", wine_dbgstr_w(name));
return FALSE; return FALSE;
...@@ -409,7 +386,7 @@ LONG X11DRV_ChangeDisplaySettings( LPDEVMODEW displays, LPCWSTR primary_name, HW ...@@ -409,7 +386,7 @@ LONG X11DRV_ChangeDisplaySettings( LPDEVMODEW displays, LPCWSTR primary_name, HW
if (!(ids = calloc( count, sizeof(*ids) ))) return DISP_CHANGE_FAILED; if (!(ids = calloc( count, sizeof(*ids) ))) return DISP_CHANGE_FAILED;
for (count = 0, mode = displays; mode->dmSize; mode = NEXT_DEVMODEW(mode), count++) for (count = 0, mode = displays; mode->dmSize; mode = NEXT_DEVMODEW(mode), count++)
{ {
if (!settings_handler.get_id( mode->dmDeviceName, ids + count )) goto done; if (!settings_handler.get_id( mode->dmDeviceName, !wcsicmp( mode->dmDeviceName, primary_name ), ids + count )) goto done;
mode->dmPosition.x -= left_most; mode->dmPosition.x -= left_most;
mode->dmPosition.y -= top_most; mode->dmPosition.y -= top_most;
} }
......
...@@ -710,7 +710,7 @@ struct x11drv_settings_handler ...@@ -710,7 +710,7 @@ struct x11drv_settings_handler
* Following functions use this id to identify the device. * Following functions use this id to identify the device.
* *
* Return FALSE if the device cannot be found and TRUE on success */ * Return FALSE if the device cannot be found and TRUE on success */
BOOL (*get_id)(const WCHAR *device_name, ULONG_PTR *id); BOOL (*get_id)(const WCHAR *device_name, BOOL is_primary, ULONG_PTR *id);
/* get_modes() will be called to get a list of supported modes of the device of id in modes /* get_modes() will be called to get a list of supported modes of the device of id in modes
* with respect to flags, which could be 0, EDS_RAWMODE or EDS_ROTATEDMODE. If the implementation * with respect to flags, which could be 0, EDS_RAWMODE or EDS_ROTATEDMODE. If the implementation
...@@ -751,7 +751,6 @@ extern BOOL is_virtual_desktop(void) DECLSPEC_HIDDEN; ...@@ -751,7 +751,6 @@ extern BOOL is_virtual_desktop(void) DECLSPEC_HIDDEN;
extern BOOL is_desktop_fullscreen(void) DECLSPEC_HIDDEN; extern BOOL is_desktop_fullscreen(void) DECLSPEC_HIDDEN;
extern BOOL is_detached_mode(const DEVMODEW *) DECLSPEC_HIDDEN; extern BOOL is_detached_mode(const DEVMODEW *) DECLSPEC_HIDDEN;
extern BOOL create_desktop_win_data( Window win ) DECLSPEC_HIDDEN; extern BOOL create_desktop_win_data( Window win ) DECLSPEC_HIDDEN;
extern BOOL get_primary_adapter(WCHAR *) DECLSPEC_HIDDEN;
void X11DRV_Settings_Init(void) DECLSPEC_HIDDEN; void X11DRV_Settings_Init(void) DECLSPEC_HIDDEN;
void X11DRV_XF86VM_Init(void) DECLSPEC_HIDDEN; void X11DRV_XF86VM_Init(void) DECLSPEC_HIDDEN;
......
...@@ -144,17 +144,12 @@ static int XRandRErrorHandler(Display *dpy, XErrorEvent *event, void *arg) ...@@ -144,17 +144,12 @@ static int XRandRErrorHandler(Display *dpy, XErrorEvent *event, void *arg)
} }
/* XRandR 1.0 display settings handler */ /* XRandR 1.0 display settings handler */
static BOOL xrandr10_get_id( const WCHAR *device_name, ULONG_PTR *id ) static BOOL xrandr10_get_id( const WCHAR *device_name, BOOL is_primary, ULONG_PTR *id )
{ {
WCHAR primary_adapter[CCHDEVICENAME];
if (!get_primary_adapter( primary_adapter ))
return FALSE;
/* RandR 1.0 only supports changing the primary adapter settings. /* RandR 1.0 only supports changing the primary adapter settings.
* For non-primary adapters, an id is still provided but getting * For non-primary adapters, an id is still provided but getting
* and changing non-primary adapters' settings will be ignored. */ * and changing non-primary adapters' settings will be ignored. */
*id = !wcsicmp( device_name, primary_adapter ) ? 1 : 0; *id = is_primary ? 1 : 0;
return TRUE; return TRUE;
} }
...@@ -1224,7 +1219,7 @@ static void xrandr14_register_event_handlers(void) ...@@ -1224,7 +1219,7 @@ static void xrandr14_register_event_handlers(void)
} }
/* XRandR 1.4 display settings handler */ /* XRandR 1.4 display settings handler */
static BOOL xrandr14_get_id( const WCHAR *device_name, ULONG_PTR *id ) static BOOL xrandr14_get_id( const WCHAR *device_name, BOOL is_primary, ULONG_PTR *id )
{ {
struct current_mode *tmp_modes, *new_current_modes = NULL; struct current_mode *tmp_modes, *new_current_modes = NULL;
INT gpu_count, adapter_count, new_current_mode_count = 0; INT gpu_count, adapter_count, new_current_mode_count = 0;
......
...@@ -85,17 +85,12 @@ static int XVidModeErrorHandler(Display *dpy, XErrorEvent *event, void *arg) ...@@ -85,17 +85,12 @@ static int XVidModeErrorHandler(Display *dpy, XErrorEvent *event, void *arg)
} }
/* XF86VidMode display settings handler */ /* XF86VidMode display settings handler */
static BOOL xf86vm_get_id(const WCHAR *device_name, ULONG_PTR *id) static BOOL xf86vm_get_id(const WCHAR *device_name, BOOL is_primary, ULONG_PTR *id)
{ {
WCHAR primary_adapter[CCHDEVICENAME];
if (!get_primary_adapter( primary_adapter ))
return FALSE;
/* XVidMode only supports changing the primary adapter settings. /* XVidMode only supports changing the primary adapter settings.
* For non-primary adapters, an id is still provided but getting * For non-primary adapters, an id is still provided but getting
* and changing non-primary adapters' settings will be ignored. */ * and changing non-primary adapters' settings will be ignored. */
*id = !wcsicmp( device_name, primary_adapter ) ? 1 : 0; *id = is_primary ? 1 : 0;
return TRUE; return TRUE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment