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.

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.
  • Loading branch information
DemiMarie committed Jul 3, 2022
1 parent 7eaa072 commit 9ac2d26
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions gui-daemon/xside.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 9ac2d26

Please sign in to comment.