RE: XGrabKey



Hi Mario.  I did something very similar in my app.  Now that you are
using X functions to process those keys, you need to handle them with X
instead of GTK.  So, keep your GTK key handler for regular keys, but for
the keys you've grabbed use something like the following.

// This function handles all of the keys which were grabbed via X
GdkFilterReturn key_filter(GdkXEvent *gdk_xevent, GdkEvent *event,
gpointer data) {

int type;
int key, keysym;
XKeyEvent *xevent;
gboolean bResult;

        xevent = gdk_xevent;
        type = xevent->type;

        if (type == KeyPress) {
                key = ((XKeyEvent *)xevent)->keycode;
                keysym = XKeycodeToKeysym(GDK_DISPLAY(), key, 0);

printf("caught keysym %i\n", keysym);

                switch (keysym) {
                        case your_keysym:
                                // your key handler code
                        break;
                }
        }
        return GDK_FILTER_CONTINUE;
}


Alex Levin
CAC Media
Vice President of Technology:
Consumer Electronics Division
212-631-7483
alex cacmedia tv

-----Original Message-----
From: gtk-app-devel-list-bounces gnome org
[mailto:gtk-app-devel-list-bounces gnome org] On Behalf Of Mario
Levinsky
Sent: Wednesday, August 17, 2005 4:43 PM
To: gtk-app-devel-list gnome org
Subject: XGrabKey

Hi!

I would like to make possilbe in my gtk+ application using global hot
keys,
I found xbindkeys application, and use part of its code.

Usage is simple: 

first I call this

void grab_keys(Display *dpy, Keys_t *keys, int nb_keys);

and after that I catch XKeyEvent.

In xbindkeys it works,

in gtk application I use instead of dpy

gdk_x11_display_get_xdisplay(gdk_screen_get_display(gtk_window_get_scree
n(GTK_WINDOW(topLevelWindow))))

instead of XKeyEvent
"key_press_event" of topLevelWindow,

but I got strange result, I press key and my window has focus, I can
catch
all keys with the exclusion of which I give grab_keys functions,
and when my window has no focus I can not catch anything.

Any help?
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list





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