winex11.drv: Use generic GetMonitorInfo.

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2019-06-25 16:39:01 +08:00 committed by Alexandre Julliard
parent 074abfe097
commit 23b28323cb
7 changed files with 72 additions and 61 deletions

View File

@ -197,8 +197,6 @@ void USER_unload_driver(void)
* These are fallbacks for entry points that are not implemented in the real driver.
*/
#define NULLDRV_DEFAULT_HMONITOR ((HMONITOR)(UINT_PTR)(0x10000 + 1))
static HKL CDECL nulldrv_ActivateKeyboardLayout( HKL layout, UINT flags )
{
return 0;
@ -359,27 +357,6 @@ static BOOL CDECL nulldrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVM
return FALSE;
}
static BOOL CDECL nulldrv_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
{
RECT r = {0, 0, 640, 480};
static const WCHAR device[] = {'W','i','n','D','i','s','c',0};
TRACE("(%p, %p)\n", handle, info);
if (handle != NULLDRV_DEFAULT_HMONITOR)
{
SetLastError(ERROR_INVALID_MONITOR_HANDLE);
return FALSE;
}
info->rcMonitor = r;
info->rcWork = r;
info->dwFlags = MONITORINFOF_PRIMARY;
if (info->cbSize >= sizeof(MONITORINFOEXW))
lstrcpyW( ((MONITORINFOEXW *)info)->szDevice, device );
return TRUE;
}
static BOOL CDECL nulldrv_CreateDesktopWindow( HWND hwnd )
{
return TRUE;

View File

@ -252,6 +252,8 @@ static const WCHAR CSrgb[] = {'%','u',' ','%','u',' ','%','u',0};
/* Wine specific monitor properties */
DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_MONITOR_STATEFLAGS, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5b, 2);
DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_MONITOR_RCMONITOR, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5b, 3);
DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_MONITOR_RCWORK, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5b, 4);
DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_MONITOR_ADAPTERNAME, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5b, 5);
#define NULLDRV_DEFAULT_HMONITOR ((HMONITOR)(UINT_PTR)(0x10000 + 1))
@ -3720,6 +3722,58 @@ HMONITOR WINAPI MonitorFromWindow(HWND hWnd, DWORD dwFlags)
return MonitorFromRect( &rect, dwFlags );
}
BOOL CDECL nulldrv_GetMonitorInfo( HMONITOR handle, MONITORINFO *info )
{
SP_DEVINFO_DATA device_data = {sizeof(device_data)};
WCHAR adapter_name[CCHDEVICENAME];
HDEVINFO devinfo;
DWORD error = 0;
HANDLE mutex;
DWORD type;
BOOL ret;
TRACE("(%p, %p)\n", handle, info);
/* Fallback to report one monitor */
if (handle == NULLDRV_DEFAULT_HMONITOR)
{
RECT default_rect = {0, 0, 640, 480};
info->rcMonitor = default_rect;
info->rcWork = default_rect;
info->dwFlags = MONITORINFOF_PRIMARY;
if (info->cbSize >= sizeof(MONITORINFOEXW))
lstrcpyW( ((MONITORINFOEXW *)info)->szDevice, DEFAULT_ADAPTER_NAME );
return TRUE;
}
/* Use SetupAPI to get monitors */
mutex = get_display_device_init_mutex();
devinfo = SetupDiGetClassDevsW( &GUID_DEVCLASS_MONITOR, NULL, NULL, 0 );
if (SetupDiEnumDeviceInfo(devinfo, (DWORD)(UINT_PTR)handle - 1, &device_data))
{
SetupDiGetDevicePropertyW( devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_RCMONITOR, &type,
(BYTE *)&info->rcMonitor, sizeof(info->rcMonitor), NULL, 0 );
SetupDiGetDevicePropertyW( devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_RCWORK, &type,
(BYTE *)&info->rcWork, sizeof(info->rcWork), NULL, 0 );
SetupDiGetDevicePropertyW( devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_ADAPTERNAME, &type,
(BYTE *)adapter_name, sizeof(adapter_name), NULL, 0 );
info->dwFlags = !lstrcmpW( DEFAULT_ADAPTER_NAME, adapter_name ) ? MONITORINFOF_PRIMARY : 0;
if (info->cbSize >= sizeof(MONITORINFOEXW))
lstrcpyW( ((MONITORINFOEXW *)info)->szDevice, adapter_name );
ret = TRUE;
}
else
{
error = ERROR_INVALID_MONITOR_HANDLE;
ret = FALSE;
}
SetupDiDestroyDeviceInfoList( devinfo );
release_display_device_init_mutex( mutex );
if (error)
SetLastError( ERROR_INVALID_MONITOR_HANDLE );
return ret;
}
/***********************************************************************
* GetMonitorInfoA (USER32.@)
*/

View File

@ -123,6 +123,7 @@ extern const USER_DRIVER *USER_Driver DECLSPEC_HIDDEN;
extern void USER_unload_driver(void) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_EnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc, LPARAM lp ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_GetMonitorInfo( HMONITOR handle, MONITORINFO *info ) DECLSPEC_HIDDEN;
struct received_message_info;

View File

@ -42,12 +42,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
/* Wine specific monitor properties */
DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_MONITOR_STATEFLAGS, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5b, 2);
DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_MONITOR_RCMONITOR, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5b, 3);
DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_MONITOR_RCWORK, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5b, 4);
DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_MONITOR_ADAPTERNAME, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5b, 5);
static const WCHAR driver_descW[] = {'D','r','i','v','e','r','D','e','s','c',0};
static const WCHAR video_idW[] = {'V','i','d','e','o','I','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 gpu_idW[] = {'G','P','U','I','D',0};
static const WCHAR mointor_id_fmtW[] = {'M','o','n','i','t','o','r','I','D','%','d',0};
static const WCHAR adapter_name_fmtW[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','%','d',0};
static const WCHAR state_flagsW[] = {'S','t','a','t','e','F','l','a','g','s',0};
static const WCHAR guid_fmtW[] = {
'{','%','0','8','x','-','%','0','4','x','-','%','0','4','x','-','%','0','2','x','%','0','2','x','-',
@ -281,6 +284,15 @@ static BOOL X11DRV_InitMonitor(HDEVINFO devinfo, const struct x11drv_monitor *mo
if (!SetupDiSetDevicePropertyW(devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_RCMONITOR, DEVPROP_TYPE_BINARY,
(const BYTE *)&monitor->rc_monitor, sizeof(monitor->rc_monitor), 0))
goto done;
/* RcWork */
if (!SetupDiSetDevicePropertyW(devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_RCWORK, DEVPROP_TYPE_BINARY,
(const BYTE *)&monitor->rc_work, sizeof(monitor->rc_work), 0))
goto done;
/* Adapter name */
sprintfW(bufferW, adapter_name_fmtW, video_index + 1);
if (!SetupDiSetDevicePropertyW(devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_ADAPTERNAME, DEVPROP_TYPE_STRING,
(const BYTE *)bufferW, (strlenW(bufferW) + 1) * sizeof(WCHAR), 0))
goto done;
ret = TRUE;
done:

View File

@ -21,7 +21,6 @@
@ cdecl ClipCursor(ptr) X11DRV_ClipCursor
@ cdecl ChangeDisplaySettingsEx(ptr ptr long long long) X11DRV_ChangeDisplaySettingsEx
@ cdecl EnumDisplaySettingsEx(ptr long ptr long) X11DRV_EnumDisplaySettingsEx
@ cdecl GetMonitorInfo(long ptr) X11DRV_GetMonitorInfo
@ cdecl CreateDesktopWindow(long) X11DRV_CreateDesktopWindow
@ cdecl CreateWindow(long) X11DRV_CreateWindow
@ cdecl DestroyWindow(long) X11DRV_DestroyWindow

View File

@ -697,6 +697,8 @@ struct x11drv_monitor
WCHAR name[128];
/* RcMonitor in MONITORINFO struct */
RECT rc_monitor;
/* RcWork in MONITORINFO struct */
RECT rc_work;
/* StateFlags in DISPLAY_DEVICE struct */
DWORD state_flags;
};

View File

@ -57,18 +57,6 @@ static inline MONITORINFOEXW *get_primary(void)
return &monitors[idx];
}
static inline HMONITOR index_to_monitor( int index )
{
return (HMONITOR)(UINT_PTR)(index + 1);
}
static inline int monitor_to_index( HMONITOR handle )
{
UINT_PTR index = (UINT_PTR)handle;
if (index < 1 || index > nb_monitors) return -1;
return index - 1;
}
static void query_work_area( RECT *rc_work )
{
Atom type;
@ -154,8 +142,6 @@ static int query_screens(void)
monitors[i].dwFlags = 0;
if (!IntersectRect( &monitors[i].rcWork, &rc_work, &monitors[i].rcMonitor ))
monitors[i].rcWork = monitors[i].rcMonitor;
/* FIXME: using the same device name for all monitors for now */
lstrcpyW( monitors[i].szDevice, default_monitor.szDevice );
}
get_primary()->dwFlags |= MONITORINFOF_PRIMARY;
@ -322,6 +308,7 @@ static BOOL xinerama_get_monitors( ULONG_PTR adapter_id, struct x11drv_monitor *
{
lstrcpyW( monitor[index].name, generic_nonpnp_monitorW );
monitor[index].rc_monitor = monitors[i].rcMonitor;
monitor[index].rc_work = monitors[i].rcWork;
/* Xinerama only reports monitors already attached */
monitor[index].state_flags = DISPLAY_DEVICE_ATTACHED;
if (!IsRectEmpty( &monitors[i].rcMonitor ))
@ -371,8 +358,8 @@ void xinerama_init( unsigned int width, unsigned int height )
OffsetRect( &monitors[i].rcMonitor, rect.left, rect.top );
OffsetRect( &monitors[i].rcWork, rect.left, rect.top );
UnionRect( &virtual_screen_rect, &virtual_screen_rect, &monitors[i].rcMonitor );
TRACE( "monitor %p: %s work %s%s\n",
index_to_monitor(i), wine_dbgstr_rect(&monitors[i].rcMonitor),
TRACE( "monitor 0x%x: %s work %s%s\n",
i, wine_dbgstr_rect(&monitors[i].rcMonitor),
wine_dbgstr_rect(&monitors[i].rcWork),
(monitors[i].dwFlags & MONITORINFOF_PRIMARY) ? " (primary)" : "" );
}
@ -390,24 +377,3 @@ void xinerama_init( unsigned int width, unsigned int height )
TRACE( "virtual size: %s primary: %s\n",
wine_dbgstr_rect(&virtual_screen_rect), wine_dbgstr_rect(&primary->rcMonitor) );
}
/***********************************************************************
* X11DRV_GetMonitorInfo (X11DRV.@)
*/
BOOL CDECL X11DRV_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
{
int i = monitor_to_index( handle );
if (i == -1)
{
SetLastError( ERROR_INVALID_HANDLE );
return FALSE;
}
info->rcMonitor = monitors[i].rcMonitor;
info->rcWork = monitors[i].rcWork;
info->dwFlags = monitors[i].dwFlags;
if (info->cbSize >= sizeof(MONITORINFOEXW))
lstrcpyW( ((MONITORINFOEXW *)info)->szDevice, monitors[i].szDevice );
return TRUE;
}