RĂ©mi Bernon rbernon@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.