Skip to content

Commit

Permalink
Pass all focus events to clients
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DemiMarie committed Aug 2, 2022
1 parent 0512543 commit f01a742
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions gui-daemon/xside.c
Original file line number Diff line number Diff line change
Expand Up @@ -1941,15 +1941,25 @@ 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. It turns out that some
* applications actually do care about these events, and ignoring
* them causes things to break. 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, and does not clobber the mode value.
*/
if (ev->mode != NotifyNormal && ev->mode != NotifyWhileGrabbed)
return;

if (ev->type == FocusIn) {
char keys[32];
XQueryKeymap(g->display, keys);
Expand All @@ -1960,10 +1970,7 @@ 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
*/
k.mode = NotifyNormal;
k.mode = ev->mode;
k.detail = ev->detail;
write_message(g->vchan, hdr, k);
}
Expand Down

0 comments on commit f01a742

Please sign in to comment.