Re: Problem with gdk_window_add_filter(NULL,...



On Thu, 2003-08-21 at 04:44, Alexandre Jousset NL wrote:
> 	Hi all...
> 
> 	I have a problem with gdk_window_add_filter(NULL, &func, NULL) which is 
> supposed to catch all events globally. I have done a little program in 
> Gtk2 to test this and it only reacts on modifier keys and mouse clicks. 
> And even with this, I am not able to see the keycode, I only see the 
> word "seen" in my terminal, which indicates that my callback was called. 
> I would like to see other keypresses because I am trying to implement a 
> special keys controller for xmms (special cd-player-like keys on my 
> laptop which generate events in xev)...

gdk_window_add_filter() filters *XEvents* prior to their translation
into GdkEvents.

> --8<-------------------------------------------------------------
> #include <stdio.h>
> #include <gtk/gtk.h>
> 
> GdkFilterReturn kbd_filter (GdkXEvent *gdk_xevent, GdkEvent *event, 
> gpointer data)
> {
>    GdkEventType type;
>    GdkEventKey *key;
> 
>    printf("seen\n");
>    type = event->type;
> 
>    if (type == GDK_KEY_RELEASE) {
>      key = (GdkEventKey *) event;
>      printf("keycode : %ld\n", key->hardware_keycode);
>    }

event->type isn't filled in at this point. Only event->window
is filled in. You want to do:

 XEvent *xevent = gdk_xevent;
 /* Do stuff with xevent */

Note that you won't see events destined for other apps without
XGrabKey usage. It sounds like you should look at 'acme', which has all
the necessary stuff done for hooking multimedia keys to the desktop.

Regards,
						Owen





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]