[PATCH] winex11.drv: Wait for XGrabPointer to succeed on FocusIn events.

Rémi Bernon rbernon at codeweavers.com
Fri Sep 20 03:11:08 CDT 2019


On 9/19/19 1:09 PM, Alexander Julliard wrote:
> Rémi Bernon <rbernon at codeweavers.com> writes:
> 
>> Because on X11 we cannot accurately reproduce the proper non-client
>> messages sequence when using decorated windows, applications sometimes
>> assume it is safe to call ClipCursor with a rectangle that matches the
>> current window position as soon as they receive a WM_ACTIVATE message.
>> When the WM finishes moving the window, and since commit
>> 92177b0b161e91f1d609615d89d8e3199feea33f we would retry to clip the
>> cursor with an incorrect rectangle.
>>
>> Before the WM starts moving a window, an active pointer grab is usually
>> initiated and we can use the result of XGrabPointer to decide whether
>> the window is really focused or if we should wait until the WM has
>> finished.
>>
>> This adds a pseudo modal loop that waits for XGrabPointer to succeed -
>> without any confine window to avoid spurious cursor movements - before
>> notifying the applications of FocusIn events.
> 
> I don't think that's not a good idea. We used to have waits at various
> points to try to synchronize with the WM, but in the end it causes more
> trouble than it's worth. There's always some WM that doesn't follow the
> expected sequence, and then you get long timeouts and deadlocks. You
> need to find a way to make this work asynchronously.
> 

 From my investigation it looks to me so far that calling XGrabPointer 
is the most "reliable" way - and so far the only way - to tell if a 
window manager is manipulating a window or not, and if there's some WM 
out there that do not grab the cursor while moving their window... well 
it's going to be the same as the current situation where applications 
assume they can freely control the cursor.

Then there could theoretically be some environments where it is not 
possible to ever grab the pointer, in which case I don't see any 
practical solution to this.

If it is better, it could be possible to delay the processing of FocusIn 
events until the grab succeeds. Retrying on every new event instead of 
actively waiting for it. Of course, if it is not possible to grab the 
pointer at all, then we're screwed as well.
-- 
Rémi Bernon <rbernon at codeweavers.com>



More information about the wine-devel mailing list