Improved X11 focus event filtering.

Some focus events need to be ignored to allow functionality like
Alt+Tab and volume indicators to not affect application-visible window
focus.  However, the previous filtering was too broad and missed virtual
desktop switching, Alt+Tab and programmatic iconification.

Fixes #405.
master
Camilla Berglund ago%!(EXTRA string=10 years)
parent 56122cbe2f
commit dba59cf903
  1. 1
      README.md
  2. 38
      src/x11_window.c

@ -76,6 +76,7 @@ GLFW bundles a number of dependencies in the `deps/` directory.
- [X11] Bugfix: The response to `_NET_WM_PING` was sent to the wrong window
- [X11] Bugfix: Character input via XIM did not work in many cases
- [X11] Bugfix: No fallback existed for missing `_NET_ACTIVE_WINDOW` support
- [X11] Bugfix: Some significant window focus events were ignored
- [WGL] Removed `GLFW_USE_DWM_SWAP_INTERVAL` compile-time option
- [WGL] Bugfix: Swap interval was ignored when DWM was enabled
- [GLX] Added dependency on `libdl` on systems where it provides `dlopen`

@ -1220,32 +1220,42 @@ static void processEvent(XEvent *event)
case FocusIn:
{
if (event->xfocus.mode == NotifyNormal)
if (event->xfocus.mode == NotifyGrab ||
event->xfocus.mode == NotifyUngrab)
{
if (window->x11.ic)
XSetICFocus(window->x11.ic);
// Ignore focus events from popup indicator windows, window menu
// key chords and window dragging
return;
}
if (window->x11.ic)
XSetICFocus(window->x11.ic);
_glfwInputWindowFocus(window, GL_TRUE);
_glfwInputWindowFocus(window, GL_TRUE);
if (window->cursorMode == GLFW_CURSOR_DISABLED)
disableCursor(window);
}
if (window->cursorMode == GLFW_CURSOR_DISABLED)
disableCursor(window);
return;
}
case FocusOut:
{
if (event->xfocus.mode == NotifyNormal)
if (event->xfocus.mode == NotifyGrab ||
event->xfocus.mode == NotifyUngrab)
{
if (window->x11.ic)
XUnsetICFocus(window->x11.ic);
// Ignore focus events from popup indicator windows, window menu
// key chords and window dragging
return;
}
if (window->x11.ic)
XUnsetICFocus(window->x11.ic);
_glfwInputWindowFocus(window, GL_FALSE);
_glfwInputWindowFocus(window, GL_FALSE);
if (window->cursorMode == GLFW_CURSOR_DISABLED)
restoreCursor(window);
}
if (window->cursorMode == GLFW_CURSOR_DISABLED)
restoreCursor(window);
return;
}

Loading…
Cancel
Save