Thank you for replying,

I decided to use the record extension as a workaround and it works fine,

Once again, than you very much for your fine help,

On Sat, May 31, 2008 at 11:19 AM, Peter Liljenberg <> wrote:
> Moreover, I tried again the example again, this time using different window
> managers and I found that the only one that did not make python-xlib to
> complain was metacity (apart from running the example with no window manager
> at all).

Apparently I was not entirely correct about the event masks.  The man
page for XChangeWindowAttributes does say that only one client can set
ButtonPressMask (I have no idea why), so you can only set it on the
root window if you are the first one to do it:

      Multiple clients can select input on the same window.  Their
event masks are maintained sepa­
      rately.  When an event is generated, it is reported to all
interested clients.  However, only
      one client at a time can select for SubstructureRedirectMask,
ResizeRedirectMask, and Button­
      PressMask.  If a client attempts to select any of these event
masks and some other client has
      already selected one, a BadAccess error results.

So the answer is that you must find another way to catch the events
you need in the presence of a window manager that sets this event