Missing events sometimes

Olivier Fourdan fourdan at gmail.com
Tue Oct 25 01:16:17 PDT 2011


Hi all,

I have been facing a bug in the xfce [1] window manager xfwm4 [2], for
a very long time, no doubt the fault is with my code yet I fail to
find the fix.

Sometimes, when the system is heavily loaded and/or swapping
intensively, the event loop does not get the ButtonReleasse or
KeyRelease events it's waiting to exit the event loop.

The logic used in the code is the following:

1. For keyboard, it installs a passive grab in sync mode on keyboard, ie:

    XGrabKey (dpy, keycode, modifier, w, TRUE, GrabModeAsync, GrabModeSync);

2. For buttons, same with Sync mode on pointer

    XGrabButton (dpy, button, modifier, w, FALSE,
ButtonPressMask|ButtonReleaseMask, GrabModeSync, GrabModeAsync, None,
None);

3. Then when the user activates a keyboard shortcut or moves a window
usign the mouse, the window manager installs an active grab on the
keyboard / pointer using the timestamp of the event:

    XGrabKeyboard (dpy, root, TRUE, GrabModeAsync, GrabModeAsync, timestamp)

or

    XGrabPointer (dpy, root, FALSE, PointerMotionMask |
ButtonMotionMask |  ButtonReleaseMask | LeaveWindowMask,
GrabModeAsync, GrabModeAsync, root, cursor, timestamp);

4. Then enters an event loop processing events, until a KeyRelease
event (in the case of a keyboard shortcut) or a ButtonRelease is
received (in the case of a mouse op).

Using this logic, the code sometimes (when the system is loaded or
swapping) remains in the event loop because the ButtonRelease or
KeyRelease event is not received in the event loop, so I guess it's
consumed somehow before the code enters the event loop, but how?

As I said, there's probably a flaw somewhere in the logic, but I fail
to find it (also because of the nature of the probl;em it's quite hard
to reproduce and therefore investigate and test), so I am open to any
suggestion...

PS: Note that xfwm4 is built on gtk+ so the events here are taken from
a gdk event filter, I am not sure of the influence of that on the
behavior...

TIA
Olivier,

[1] http://www.xfce.org
[2] http://git.xfce.org/xfce/xfwm4/



More information about the xorg mailing list