[sugar] Capturing all mouse events

Martin Dengler martin at martindengler.com
Sun Jun 1 20:29:29 EDT 2008


On Fri, May 30, 2008 at 09:38:39PM -0400, Benjamin M. Schwartz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Does anyone know how to capture all mouse events?

In trying to do this with pygtk, we both have run into gtk bug
#156948[1] - for the record/to close the loop, we tried calling
add_filter() on gtk.gdk.get_default_root_window()'s returned
gtk.gdk.Window. This should, in theory, give us all events[2]. But the
bug prevents the information from being useful, and it's not clear
that we're really getting all events[3].

> [...] listen to /dev/input/mouse0.

That seems promising.  I couldn't find anything useful in pygame.

> - --Ben

Martin

1. http://bugzilla.gnome.org/show_bug.cgi?id=156948
2. this is what metacity uses:

--- metacity-2.23.0/src/ui/ui.c:76
static GdkFilterReturn
filter_func (GdkXEvent *xevent,
             GdkEvent *event,
             gpointer data)
{
  g_return_val_if_fail (ef != NULL, GDK_FILTER_CONTINUE);

  if ((* ef->func) (xevent, ef->data))
    return GDK_FILTER_REMOVE;
  else
    return GDK_FILTER_CONTINUE;
}

void
meta_ui_add_event_func (Display       *xdisplay,
                        MetaEventFunc  func,
                        gpointer       data)
{
  g_return_if_fail (ef == NULL);

  ef = g_new (EventFunc, 1);
  ef->func = func;
  ef->data = data;

  gdk_window_add_filter (NULL, filter_func, ef);
}
---

3. http://markmail.org/message/ns2jcbhzr7br55ur?q=gdk+add_filter&page=1&refer=cj5iiu56mz7shm3s


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.laptop.org/pipermail/sugar/attachments/20080602/4c955eb7/attachment.pgp 


More information about the Sugar mailing list