From 9ac2d2650f4eec5512c8e1676f9cb9d3ce01ff11 Mon Sep 17 00:00:00 2001 From: Demi Marie Obenour Date: Sun, 3 Jul 2022 16:38:51 -0400 Subject: [PATCH] Pass all focus events to clients Ignoring some focus events can result in the client and server disagreeing on which window is focused or which keys have been pressed. The results are unpredictable and generally undesirable. Therefore, pass all focus events to clients. The mode is still overridden with NotifyNormal to avoid leaking window manager implementation details. Fixes QubesOS/qubes-issues#7599. --- gui-daemon/xside.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/gui-daemon/xside.c b/gui-daemon/xside.c index da1002fd..36c6829c 100644 --- a/gui-daemon/xside.c +++ b/gui-daemon/xside.c @@ -1940,15 +1940,24 @@ static void process_xevent_focus(Ghandles * g, const XFocusChangeEvent * ev) struct msg_focus k; CHECK_NONMANAGED_WINDOW(g, ev->window); - /* Ignore everything other than normal, non-temporary focus change. In - * practice it ignores NotifyGrab and NotifyUngrab. VM does not have any - * way to grab focus in dom0, so it shouldn't care about those events. Grab - * is used by window managers during task switching (either classic task - * switcher, or KDE "present windows" feature). + /* In the past, the GUI daemon ignored several such events. The + * comment used to say: + * + * > Ignore everything other than normal, non-temporary focus change. In + * > practice it ignores NotifyGrab and NotifyUngrab. VM does not have any + * > way to grab focus in dom0, so it shouldn't care about those events. Grab + * > is used by window managers during task switching (either classic task + * > switcher, or KDE "present windows" feature). + * + * In particular, events with modes other than NotifyNormal and + * NotifyWhileGrabbed were ignored. + * + * This caused problems, though, because at least xfwm4 relies on + * these events being received. In particular, this resulted in + * lost keymap updates and the agent and daemon no longer agreeing + * on which keys are pressed. Therefore, the GUI daemon now sends + * such events to clients. */ - if (ev->mode != NotifyNormal && ev->mode != NotifyWhileGrabbed) - return; - if (ev->type == FocusIn) { char keys[32]; XQueryKeymap(g->display, keys); @@ -1959,8 +1968,8 @@ static void process_xevent_focus(Ghandles * g, const XFocusChangeEvent * ev) hdr.type = MSG_FOCUS; hdr.window = vm_window->remote_winid; k.type = ev->type; - /* override NotifyWhileGrabbed with NotifyNormal b/c VM shouldn't care - * about window manager details during focus switching + /* Override mode with NotifyNormal. The VM shouldn't care + * about window manager details during focus switching. */ k.mode = NotifyNormal; k.detail = ev->detail;