winex11.drv: Do not react to keyboard grab focus events.

Several window managers are sending FocusOut with NotifyGrab mode
then FocusOut with NotifyWhileGrabbed mode when a window focus is lost,
as a consequence of grabbing the keyboard input before changing window
focus.

This is the case during alt-tab, but keyboard can also be grabbed when
bringing activity view or clicking on the title bar. In this cases
NotifyWhileGrabbed events aren't sent until the window really loses
foreground.

In the same manner, when focus is restored, they usually send FocusIn
with NotifyWhileGrabbed mode followed by FocusIn with NotifyUngrab mode
when the keyboard grab is released.

When bringing activity view back and forth, or clicking on the title
bar, only NotifyUngrab event will be sent.

In order to be consistent across WM and to help simplifying focus
handling, just ignore focus events related to keyboard grabs.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2019-08-30 12:17:58 +02:00 committed by Alexandre Julliard
parent cfd1f614bc
commit 4b81771b00
1 changed files with 27 additions and 0 deletions

View File

@ -772,6 +772,19 @@ static BOOL X11DRV_FocusIn( HWND hwnd, XEvent *xev )
if (event->detail == NotifyPointer) return FALSE;
if (hwnd == GetDesktopWindow()) return FALSE;
switch (event->mode)
{
case NotifyGrab:
WARN( "unexpected FocusIn event with NotifyGrab mode\n" );
break;
case NotifyWhileGrabbed:
break;
case NotifyNormal:
break;
case NotifyUngrab:
return TRUE; /* ignore wm specific NotifyUngrab / NotifyGrab events w.r.t focus */
}
if ((xic = X11DRV_get_ic( hwnd ))) XSetICFocus( xic );
if (use_take_focus)
{
@ -855,6 +868,20 @@ static BOOL X11DRV_FocusOut( HWND hwnd, XEvent *xev )
return TRUE;
}
if (!hwnd) return FALSE;
switch (event->mode)
{
case NotifyUngrab:
WARN( "unexpected FocusOut event with NotifyUngrab mode\n" );
break;
case NotifyNormal:
break;
case NotifyWhileGrabbed:
break;
case NotifyGrab:
return TRUE; /* ignore wm specific NotifyUngrab / NotifyGrab events w.r.t focus */
}
focus_out( event->display, hwnd );
return TRUE;
}