Re: [dwm] Catching a button press outside a window

From: Anselm R. Garbe <>
Date: Mon, 24 Sep 2007 08:49:26 +0200

On Mon, Sep 24, 2007 at 07:00:19AM +0200, Alpt wrote:
> How is it possible to catch a buttonpress event outside any window, without
> messing up everything?

Yes, you should only grab the root window if the input focus is
on the root window (you could even passively grab the pointer in
such a case). Whenever the pointer enters a
child window of the root window you should immediately ungrab
and XSync() for those events (or XUngrabPointer() resp.).

> Until now I've tried to apply grabbuttons to the root window, with
> focused=True. Doing so, the root window catches the button press, but it
> catches too much, i.e. every button press. So every other window becomes deaf.

Well the root window is focused all the time in a single head
setup. Only in a multihead setup your assumption would work ;)

> I've tried also to create a ghost window with CWOverrideRedirect, like barwin
> does, which has the same size of the root window. It works.
> However, since I don't update it, old pixels remains when a window is moved.
> Is there a simple solution, or do I have to update the ghost win every time?

Hmm, try creating that window with the ParentRelative pixmap and
catch exposures for that window that it is cleared accordingly.
Anyway, I'd highly recommend you the above solution which
consumes less X resources - though it is quite nasty to
grab/ungrab for button presses or passively query/unquery the pointer.

So I won't bother and NOT doing such stuff if I were you :-)


 Anselm R. Garbe >< >< GPG key: 0D73F361
Received on Mon Sep 24 2007 - 08:49:26 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:55:13 UTC