Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/user32/sysparams.c | 156 ++-------------------------------------- 1 file changed, 4 insertions(+), 152 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index 85f4446cc11..bde878f8401 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -102,25 +102,10 @@ DEFINE_DEVPROPKEY(DEVPROPKEY_MONITOR_OUTPUT_ID, 0xca085853, 0x16ce, 0x48aa, 0xb1
/* 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))
-/* Cached monitor information */ -static MONITORINFOEXW *monitors; -static UINT monitor_count; -static FILETIME last_query_monitors_time; -static CRITICAL_SECTION monitors_section; -static CRITICAL_SECTION_DEBUG monitors_critsect_debug = -{ - 0, 0, &monitors_section, - { &monitors_critsect_debug.ProcessLocksList, &monitors_critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": monitors_section") } -}; -static CRITICAL_SECTION monitors_section = { &monitors_critsect_debug, -1 , 0, 0, 0, 0 }; - static HDC display_dc; static CRITICAL_SECTION display_dc_section; static CRITICAL_SECTION_DEBUG critsect_debug = @@ -144,7 +129,6 @@ static DPI_AWARENESS dpi_awareness; static DPI_AWARENESS default_awareness = DPI_AWARENESS_UNAWARE;
static HKEY volatile_base_key; -static HKEY video_key;
union sysparam_all_entry;
@@ -3782,100 +3766,8 @@ HMONITOR WINAPI MonitorFromWindow(HWND hWnd, DWORD dwFlags) return MonitorFromRect( &rect, dwFlags ); }
-/* Return FALSE on failure and TRUE on success */ -static BOOL update_monitor_cache(void) -{ - SP_DEVINFO_DATA device_data = {sizeof(device_data)}; - HDEVINFO devinfo = INVALID_HANDLE_VALUE; - MONITORINFOEXW *monitor_array; - FILETIME filetime = {0}; - DWORD device_count = 0; - HANDLE mutex = NULL; - DWORD state_flags; - BOOL ret = FALSE; - BOOL is_replica; - DWORD i = 0, j; - DWORD type; - - /* Update monitor cache from SetupAPI if it's outdated */ - if (!video_key && RegOpenKeyW( HKEY_LOCAL_MACHINE, L"HARDWARE\DEVICEMAP\VIDEO", &video_key )) - return FALSE; - if (RegQueryInfoKeyW( video_key, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &filetime )) - return FALSE; - if (CompareFileTime( &filetime, &last_query_monitors_time ) < 1) - return TRUE; - - mutex = get_display_device_init_mutex(); - EnterCriticalSection( &monitors_section ); - devinfo = SetupDiGetClassDevsW( &GUID_DEVCLASS_MONITOR, L"DISPLAY", NULL, DIGCF_PRESENT ); - - while (SetupDiEnumDeviceInfo( devinfo, i++, &device_data )) - { - /* Inactive monitors don't get enumerated */ - if (!SetupDiGetDevicePropertyW( devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_STATEFLAGS, &type, - (BYTE *)&state_flags, sizeof(DWORD), NULL, 0 )) - goto fail; - if (state_flags & DISPLAY_DEVICE_ACTIVE) - device_count++; - } - - if (device_count && monitor_count < device_count) - { - monitor_array = heap_alloc( device_count * sizeof(*monitor_array) ); - if (!monitor_array) - goto fail; - heap_free( monitors ); - monitors = monitor_array; - } - - for (i = 0, monitor_count = 0; SetupDiEnumDeviceInfo( devinfo, i, &device_data ); i++) - { - if (!SetupDiGetDevicePropertyW( devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_STATEFLAGS, &type, - (BYTE *)&state_flags, sizeof(DWORD), NULL, 0 )) - goto fail; - if (!(state_flags & DISPLAY_DEVICE_ACTIVE)) - continue; - if (!SetupDiGetDevicePropertyW( devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_RCMONITOR, &type, - (BYTE *)&monitors[monitor_count].rcMonitor, sizeof(RECT), NULL, 0 )) - goto fail; - - /* Replicas in mirroring monitor sets don't get enumerated */ - is_replica = FALSE; - for (j = 0; j < monitor_count; j++) - { - if (EqualRect(&monitors[j].rcMonitor, &monitors[monitor_count].rcMonitor)) - { - is_replica = TRUE; - break; - } - } - if (is_replica) - continue; - - if (!SetupDiGetDevicePropertyW( devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_RCWORK, &type, - (BYTE *)&monitors[monitor_count].rcWork, sizeof(RECT), NULL, 0 )) - goto fail; - if (!SetupDiGetDevicePropertyW( devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_ADAPTERNAME, &type, - (BYTE *)monitors[monitor_count].szDevice, CCHDEVICENAME * sizeof(WCHAR), NULL, 0)) - goto fail; - monitors[monitor_count].dwFlags = - !wcscmp( L"\\.\DISPLAY1", monitors[monitor_count].szDevice ) ? MONITORINFOF_PRIMARY : 0; - - monitor_count++; - } - - last_query_monitors_time = filetime; - ret = TRUE; -fail: - SetupDiDestroyDeviceInfoList( devinfo ); - LeaveCriticalSection( &monitors_section ); - release_display_device_init_mutex( mutex ); - return ret; -} - BOOL CDECL nulldrv_GetMonitorInfo( HMONITOR handle, MONITORINFO *info ) { - UINT index = (UINT_PTR)handle - 1; NTSTATUS status;
TRACE("(%p, %p)\n", handle, info); @@ -3917,29 +3809,8 @@ BOOL CDECL nulldrv_GetMonitorInfo( HMONITOR handle, MONITORINFO *info ) return TRUE; }
- if (!update_monitor_cache()) - { - SetLastError( ERROR_INVALID_MONITOR_HANDLE ); - return FALSE; - } - - EnterCriticalSection( &monitors_section ); - if (index < monitor_count) - { - info->rcMonitor = monitors[index].rcMonitor; - info->rcWork = monitors[index].rcWork; - info->dwFlags = monitors[index].dwFlags; - if (info->cbSize >= sizeof(MONITORINFOEXW)) - lstrcpyW( ((MONITORINFOEXW *)info)->szDevice, monitors[index].szDevice ); - LeaveCriticalSection( &monitors_section ); - return TRUE; - } - else - { - LeaveCriticalSection( &monitors_section ); - SetLastError( ERROR_INVALID_MONITOR_HANDLE ); - return FALSE; - } + SetLastError( ERROR_INVALID_MONITOR_HANDLE ); + return FALSE; }
/*********************************************************************** @@ -4081,27 +3952,8 @@ BOOL CDECL nulldrv_EnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC pro if (i) return TRUE;
- if (update_monitor_cache()) - { - while (TRUE) - { - EnterCriticalSection( &monitors_section ); - if (i >= monitor_count) - { - LeaveCriticalSection( &monitors_section ); - return TRUE; - } - monitor_rect = monitors[i].rcMonitor; - LeaveCriticalSection( &monitors_section ); - - if (!proc( (HMONITOR)(UINT_PTR)(i + 1), hdc, &monitor_rect, lp )) - return FALSE; - - ++i; - } - } - - /* Fallback to report one monitor if using SetupAPI failed */ + /* Fallback to report one monitor if wineserver calls failed */ + ERR("Failed to enumerate monitors, reporting a 640x480 monitor.\n"); SetRect( &monitor_rect, 0, 0, 640, 480 ); if (!proc( NULLDRV_DEFAULT_HMONITOR, hdc, &monitor_rect, lp )) return FALSE;