Problem with gdk_window_add_filter(NULL,...

	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)...

	Here is the source :

#include <stdio.h>
#include <gtk/gtk.h>

GdkFilterReturn kbd_filter (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
  GdkEventType type;
  GdkEventKey *key;

  type = event->type;

  if (type == GDK_KEY_RELEASE) {
    key = (GdkEventKey *) event;
    printf("keycode : %ld\n", key->hardware_keycode);


int main(int argc, char *argv[])
  gtk_init(&argc, &argv);

  gdk_window_add_filter(NULL, &kbd_filter, NULL);

I compile it with "gcc -o rmp3 rmp3.c `pkg-config gtk+-2.0 --cflags` `pkg-config gtk+-2.0 --libs` (on a Mandrake 9.1) and run it with ./rmp3.

Please help ! I am searching for 2 days, I searched the mailing list archive, the net with Google, looked into source code using this function but nothing gave me an answer.

	Thank you in advance.

Alexandre Jousset.

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