[PATCH] winex11.drv: Stop assuming that GenericEvent has a window.

Jefferson Carpenter jeffersoncarpenter2 at gmail.com
Mon Feb 15 06:04:25 CST 2021


On 2/15/2021 11:26 AM, Dmitry Timoshkov wrote:
> Rémi Bernon <rbernon at codeweavers.com> wrote:
> 
>> On 2/15/21 11:25 AM, Dmitry Timoshkov wrote:
>>> Rémi Bernon <rbernon at codeweavers.com> wrote:
>>>
>>>> -    if (XFindContext( display, event->xany.window, winContext, (char **)&hwnd ) != 0)
>>>> -        hwnd = 0;  /* not for a registered window */
>>>> +    if (event->type == GenericEvent || XFindContext( display, event->xany.window, winContext, (char **)&hwnd ))
>>>> +        hwnd = NULL;  /* not for a registered window */
>>>
>>> Changing 0 to NULL looks gratuitous.
>>>
>>
>> Sure, and the != 0 removal too. I think HWND are set with NULL
>> elsewhere. I took the opportunity of the change to make things a bit
>> more consistent.
> 
> Window handles are not pointers, please avoid gratuitous changes in the diffs.
> 

Question is what the proper null value is for an HWND: 0 or NULL. 
Semantically, I think NULL is the proper choice - an MSDN example 
compares an HWND against NULL [1].  Also in Wine the underlying type of 
HWND is a pointer type [2][3] and the NULL macro is defined to compare 
equal to a null pointer, so it seems NULL is the right choice.

[1] 
https://docs.microsoft.com/en-us/windows/win32/learnwin32/creating-a-window
[2] https://github.com/wine-mirror/wine/blob/wine-6.2/include/windef.h#L333
[3] https://github.com/wine-mirror/wine/blob/wine-6.2/include/winnt.h#L583



More information about the wine-devel mailing list