Justin Clift wrote:
I'll have to get a proper understanding of XGrabKey now, and then ask
back if (er... when?) I have probs. Heh. :)
I'm attaching a few lines of sample code with XGrabKey, as I was playing
with this a couple of weeks ago.
The code is rather incomplete, and certainly doesn't account for
"special" circumstances, or even checking return codes. But it should
demonstrate the general principle. I don't know if it's actually
correct, but it more or less works.
Build with:
gcc `pkg-config --libs --cflags gtk+-2.0` globalkeybinding.c
--Pat
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
GdkFilterReturn ff (GdkXEvent *gxe, GdkEvent *e, gpointer d)
{
GdkFilterReturn ret = GDK_FILTER_CONTINUE;
XEvent *xevent = (XEvent *) gxe;
switch (xevent->type) {
case KeyPress:
printf("Got the key!\n");
break;
case KeyRelease:
break;
}
}
int main()
{
GtkWidget *window;
GdkWindow *rw;
gtk_init(NULL, NULL);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show_all(window);
rw = gdk_get_default_root_window();
/* Ctrl + Alt + T */
XGrabKey(GDK_WINDOW_XDISPLAY(rw),
XKeysymToKeycode(GDK_WINDOW_XDISPLAY(rw), XK_T),
ControlMask | Mod1Mask, GDK_WINDOW_XWINDOW(rw),
True, GrabModeAsync, GrabModeAsync);
gdk_flush();
gdk_window_add_filter(rw, ff, NULL);
gtk_main();
}
_______________________________________________
xdg mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/xdg