Permalink
Browse files

Fix color updates when changing client focus from key events

This patch was originally posted on this Arch Linux forum thread:

  https://bbs.archlinux.org/viewtopic.php?id=176489

It was created against the combined wmii+ixp release found here:

  http://dl.suckless.org/wmii/wmii+ixp-3.9.2.tbz

I'm having a hard time remembering the details of the bug this patch
fixes now, but here is the e-mail I sent to Kris Maglione and Arch's
wmii package maintainer if you're interested:

> The problem comes down to the focusout() function in cmd/wmii/event.c.
> It tests for the condition that the event's mode is NotifyGrab and
> there is a KeyPress event later in the queue, and if both of these
> fail then it proceeds to handle the FocusOut event, eventually
> clearing disp.focus to c_magic in focusout_event()
> (cmd/wmii/client.c).  Then, when the KeyPress event finally does
> arrive, client_focus() is unable to update the previously-focused
> client's border with normcolors because disp.focus was already
> cleared.
>
> My fix simply tweaks focusout()'s logic so that the else branch never
> executes if ev->mode == NotifyGrab, regardless of whether there's a
> KeyPress event in the queue yet.  I don't know whether it should be
> considered a bug in X that we received a FocusOut-NotifyGrab event
> before the KeyPress event is available, but this change seems to work.

Corey
  • Loading branch information...
cmtptr authored and sunaku committed Feb 10, 2014
1 parent 0d2ad7e commit fc3e1989d400761ff8007487bc090409a4c3324e
Showing with 4 additions and 3 deletions.
  1. +4 −3 cmd/wmii/event.c
View
@@ -70,9 +70,10 @@ event_focusout(XFocusChangeEvent *ev) {
if(ev->mode == NotifyUngrab)
disp.hasgrab = nil;
- if((ev->mode == NotifyGrab)
- && XCheckMaskEvent(display, KeyPressMask, &me))
- event_dispatch(&me);
+ if(ev->mode == NotifyGrab) {
+ if (XCheckMaskEvent(display, KeyPressMask, &me))
+ event_dispatch(&me);
+ }
else if((w = findwin(ev->window)))
event_handle(w, focusout, ev);
}

0 comments on commit fc3e198

Please sign in to comment.