[PATCH v2 3/4] winex11.drv: Retrieve virtual and primary monitor rectangles from SetupAPI.

Zhiyi Zhang zzhang at codeweavers.com
Fri Nov 1 08:25:35 CDT 2019



On 11/1/19 2:33 AM, Alexandre Julliard wrote:
> Zhiyi Zhang <zzhang at codeweavers.com> writes:
>
>> +/* Update screen rect cache from SetupAPI if it's outdated, return FALSE on failure and TRUE on success */
>> +static BOOL update_screen_cache(void)
>> +{
>> +    RECT virtual_rect = {0}, primary_rect = {0}, monitor_rect;
>> +    SP_DEVINFO_DATA device_data = {sizeof(device_data)};
>> +    HDEVINFO devinfo = INVALID_HANDLE_VALUE;
>> +    FILETIME filetime;
>> +    HKEY video_key;
>> +    HANDLE mutex;
>> +    DWORD i = 0;
>> +    INT result;
>> +    DWORD type;
>> +    LSTATUS lr;
>> +    BOOL ret = FALSE;
>> +
>> +    if (RegOpenKeyW(HKEY_LOCAL_MACHINE, video_keyW, &video_key))
>> +        return FALSE;
>> +    lr = RegQueryInfoKeyW(video_key, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &filetime);
>> +    RegCloseKey(video_key);
>> +    if (lr)
>> +        return FALSE;
>> +
>> +    EnterCriticalSection(&screen_section);
>> +    result = CompareFileTime(&filetime, &last_query_screen_time);
>> +    LeaveCriticalSection(&screen_section);
>> +    if (result < 1)
>> +        return TRUE;
> That looks pretty inefficient as caching mechanism. Hopefully we can
> handle that without adding multiple wineserver calls.
>
Ok. I sent a new version that only use one wineserver call, at the expense of
keeping a registry key open. Those two rectangles are not used that frequently,
so I was thinking it might be better not to leak a registry key handle.

Thanks,
Zhiyi



More information about the wine-devel mailing list