Skip to content

Commit f01a742

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. Furthermore, it turns out that clients do care about the mode. Therefore, pass all focus events to clients, without clobbering the mode value. Fixes QubesOS/qubes-issues#7599.
1 parent 0512543 commit f01a742

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

gui-daemon/xside.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,15 +1941,25 @@ static void process_xevent_focus(Ghandles * g, const XFocusChangeEvent * ev)
19411941
struct msg_focus k;
19421942
CHECK_NONMANAGED_WINDOW(g, ev->window);
19431943

1944-
/* Ignore everything other than normal, non-temporary focus change. In
1945-
* practice it ignores NotifyGrab and NotifyUngrab. VM does not have any
1946-
* way to grab focus in dom0, so it shouldn't care about those events. Grab
1947-
* is used by window managers during task switching (either classic task
1948-
* switcher, or KDE "present windows" feature).
1944+
/* In the past, the GUI daemon ignored several such events. The
1945+
* comment used to say:
1946+
*
1947+
* > Ignore everything other than normal, non-temporary focus change. In
1948+
* > practice it ignores NotifyGrab and NotifyUngrab. VM does not have any
1949+
* > way to grab focus in dom0, so it shouldn't care about those events. Grab
1950+
* > is used by window managers during task switching (either classic task
1951+
* > switcher, or KDE "present windows" feature).
1952+
*
1953+
* In particular, events with modes other than NotifyNormal and
1954+
* NotifyWhileGrabbed were ignored.
1955+
*
1956+
* This caused problems, though. It turns out that some
1957+
* applications actually do care about these events, and ignoring
1958+
* them causes things to break. In particular, this resulted in
1959+
* lost keymap updates and the agent and daemon no longer agreeing
1960+
* on which keys are pressed. Therefore, the GUI daemon now sends
1961+
* such events to clients, and does not clobber the mode value.
19491962
*/
1950-
if (ev->mode != NotifyNormal && ev->mode != NotifyWhileGrabbed)
1951-
return;
1952-
19531963
if (ev->type == FocusIn) {
19541964
char keys[32];
19551965
XQueryKeymap(g->display, keys);
@@ -1960,10 +1970,7 @@ static void process_xevent_focus(Ghandles * g, const XFocusChangeEvent * ev)
19601970
hdr.type = MSG_FOCUS;
19611971
hdr.window = vm_window->remote_winid;
19621972
k.type = ev->type;
1963-
/* override NotifyWhileGrabbed with NotifyNormal b/c VM shouldn't care
1964-
* about window manager details during focus switching
1965-
*/
1966-
k.mode = NotifyNormal;
1973+
k.mode = ev->mode;
19671974
k.detail = ev->detail;
19681975
write_message(g->vchan, hdr, k);
19691976
}

0 commit comments

Comments
 (0)