Fix color updates when changing client focus from key events
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

sunaku/wmii,sunaku/wmii,sunaku/wmii,sunaku/wmii,sunaku/wmii