Skip to content

Commit 9ac2d26

Browse files
committed
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.
1 parent 7eaa072 commit 9ac2d26

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

gui-daemon/xside.c

+19-10
Original file line numberDiff line numberDiff line change
@@ -1940,15 +1940,24 @@ static void process_xevent_focus(Ghandles * g, const XFocusChangeEvent * ev)
19401940
struct msg_focus k;
19411941
CHECK_NONMANAGED_WINDOW(g, ev->window);
19421942

1943-
/* Ignore everything other than normal, non-temporary focus change. In
1944-
* practice it ignores NotifyGrab and NotifyUngrab. VM does not have any
1945-
* way to grab focus in dom0, so it shouldn't care about those events. Grab
1946-
* is used by window managers during task switching (either classic task
1947-
* switcher, or KDE "present windows" feature).
1943+
/* In the past, the GUI daemon ignored several such events. The
1944+
* comment used to say:
1945+
*
1946+
* > Ignore everything other than normal, non-temporary focus change. In
1947+
* > practice it ignores NotifyGrab and NotifyUngrab. VM does not have any
1948+
* > way to grab focus in dom0, so it shouldn't care about those events. Grab
1949+
* > is used by window managers during task switching (either classic task
1950+
* > switcher, or KDE "present windows" feature).
1951+
*
1952+
* In particular, events with modes other than NotifyNormal and
1953+
* NotifyWhileGrabbed were ignored.
1954+
*
1955+
* This caused problems, though, because at least xfwm4 relies on
1956+
* these events being received. In particular, this resulted in
1957+
* lost keymap updates and the agent and daemon no longer agreeing
1958+
* on which keys are pressed. Therefore, the GUI daemon now sends
1959+
* such events to clients.
19481960
*/
1949-
if (ev->mode != NotifyNormal && ev->mode != NotifyWhileGrabbed)
1950-
return;
1951-
19521961
if (ev->type == FocusIn) {
19531962
char keys[32];
19541963
XQueryKeymap(g->display, keys);
@@ -1959,8 +1968,8 @@ static void process_xevent_focus(Ghandles * g, const XFocusChangeEvent * ev)
19591968
hdr.type = MSG_FOCUS;
19601969
hdr.window = vm_window->remote_winid;
19611970
k.type = ev->type;
1962-
/* override NotifyWhileGrabbed with NotifyNormal b/c VM shouldn't care
1963-
* about window manager details during focus switching
1971+
/* Override mode with NotifyNormal. The VM shouldn't care
1972+
* about window manager details during focus switching.
19641973
*/
19651974
k.mode = NotifyNormal;
19661975
k.detail = ev->detail;

0 commit comments

Comments
 (0)