[PATCH resend] winex11.drv: Don't set the foreground for focus events that are older than the last SetFocus sent without an event

Rémi Bernon rbernon at codeweavers.com
Thu Aug 22 07:30:26 CDT 2019


On 8/22/19 2:26 PM, Gabriel Ivăncescu wrote:
> Hi Rémi,
> 
> Thanks for the review.
> 
> On 8/22/19 12:29 PM, Rémi Bernon wrote:
>> On 8/15/19 3:57 PM, Gabriel Ivăncescu wrote:
>>> @@ -803,7 +820,7 @@ static void focus_out( Display *display , HWND 
>>> hwnd )
>>>       if (ximInComposeMode) return;
>>> -    x11drv_thread_data()->last_focus = hwnd;
>>> +    thread_data->last_focus = hwnd;
>>>       if ((xic = X11DRV_get_ic( hwnd ))) XUnsetICFocus( xic );
>>>       if (root_window != DefaultRootWindow(display))
>>> @@ -812,6 +829,12 @@ static void focus_out( Display *display , HWND 
>>> hwnd )
>>>           return;
>>>       }
>>>       if (hwnd != GetForegroundWindow()) return;
>>> +
>>> +    if ((long)(thread_data->focus_serial - serial) > 0)
>>> +    {
>>> +        TRACE("ignoring old serial %lu/%lu\n", serial, 
>>> thread_data->focus_serial);
>>> +        return;
>>> +    }
>>
>> I'm not sure if this is the right thing to do here.
>>
>> I understand the reason to skip calling SetForegroundWindow on FocusIn 
>> events - because SetFocus called by DefWinProc would already have done 
>> it before, as a consequence of ShowWindow / WM_ACTIVATE messages - but 
>> in the case of focus out events, I believe it is already skipped if 
>> the newly focused window is another Wine window.
>>
> 
> So I should not add it to focus out then, right?
> 

Yes I think focus_out is fine as it is. Except for the WM_CANCELMODE 
message that is a bit unclear, all it does right now is setting back the 
focus to desktop window if there is no more Wine window with input focus.

I think it will not happen in your scenario. And even if it does, if the 
X server says that Wine windows do not have input focus then we should 
trust it.
-- 
Rémi Bernon <rbernon at codeweavers.com>



More information about the wine-devel mailing list