On 9/20/19 11:53 AM, Kimball Thurston wrote:
Sorry, randomly saw this, and don't know the full context, so sorry if this is a rehash of what you've already looked at, or I didn't understand what you're trying to fix.
But shouldn't you be doing the normal focus lost / gain notification, but instead paying attention to the EnterNotify for this condition? When the WM ungrabs the pointer, you won't necessarily receive a Focus In, but rather you should always receive an EnterNotify, and I believe it should have mode = NotifyUngrab and a detail of NotifyAncestor. In that condition, you could send the WM_ACTIVATE at that time and not try to track the focus gained / lost, which you may not get? For example, playing w/ xev under the awesome WM, when I use the hotkey + mouse to move a window, the window doesn't lose / gain focus while that happens, but it does receive the EnterNotify with the above conditions when the WM finishes the move.
Kimball
You only get EnterNotify/LeaveNotify whenever the cursor enters or leaves the client area of a window, which is not the same as getting or losing focus. For example, if you use Alt-Tab without having the cursor inside the window, you only get FocusIn/FocusOut events.
The issue I'm trying to address is the difficulty to reproduce Windows message sequence on X11 when using decorated windows. On Windows, if the window frame is clicked, for example to move or resize the window, non-client WM_NCLBUTTONDOWN message is received and a modal message loop is triggered to handle the window repositioning until the mouse is released. On X11 I couldn't find a reliable way to tell if the decoration frames were involved in the received events.