gnome cd on Laptops (w/ patch) v2



I can now use my MM keys to control gnome-cd on my laptop.

-Nigel

7,8d6
<  *
<  * Modified njh bandsman co uk to respond directly to MM keys
28,29d25
< #include <X11/XF86keysym.h>
< 
39,42d34
< static	GdkFilterReturn	filter_keys(GdkXEvent *xevent, GdkEvent *event, gpointer data);
< static	void	grab_key(int key_code, GdkWindow *root);
< static	void	start_listener(GnomeCD *gcd);
< 
737,821d728
< /*
<  * Start of code by Nigel Horne <njh bandsman co uk> to handle MM key input
<  */
< static GdkFilterReturn
< filter_keys(GdkXEvent *xevent, GdkEvent *event, gpointer data)
< {
< 	XEvent *xev;
< 	XKeyEvent *key;
< 	GnomeCD *gcd;
< 	guint keycode;
< 
< 	xev = (XEvent *) xevent;
< 	if (xev->type != KeyPress)
< 		return GDK_FILTER_CONTINUE;
< 
< 	key = (XKeyEvent *) xevent;
< 
< 	keycode = key->keycode;
< 
< 	gcd = (GnomeCD *)data;
< 
< 	if(XKeysymToKeycode(GDK_DISPLAY(), XF86XK_AudioNext) == keycode) {
< 		next_cb(NULL, gcd);
< 		return GDK_FILTER_REMOVE;
< 	}
< 	if(XKeysymToKeycode(GDK_DISPLAY(), XF86XK_AudioPrev) == keycode) {
< 		back_cb(NULL, gcd);
< 		return GDK_FILTER_REMOVE;
< 	}
< 	if(XKeysymToKeycode(GDK_DISPLAY(), XF86XK_AudioStop) == keycode) {
< 		play_cb(NULL, gcd);
< 		return GDK_FILTER_REMOVE;
< 	}
< 	if(XKeysymToKeycode(GDK_DISPLAY(), XF86XK_AudioPlay) == keycode) {
< 		stop_cb(NULL, gcd);
< 		return GDK_FILTER_REMOVE;
< 	}
< 	return GDK_FILTER_CONTINUE;
< }
< 
< static void
< grab_key(int key_code, GdkWindow *root)
< {
< 	Window window = GDK_WINDOW_XID(root);
< 	static const unsigned int modifiers[] = {
< 		0, Mod2Mask, Mod5Mask, LockMask,
< 		Mod2Mask|Mod5Mask, Mod2Mask|LockMask,
< 		Mod5Mask|LockMask, Mod2Mask|Mod5Mask|LockMask
< 	};
< 	int i;
< 
< 	for(i = 0; i < sizeof(modifiers) / sizeof(unsigned int); i++)
< 		XGrabKey (GDK_DISPLAY (), key_code, modifiers[i], window, True,
< 			  GrabModeAsync, GrabModeAsync);
< 
< 	gdk_flush();
< }
< 
< static void
< start_listener(GnomeCD *gcd)
< {
< 	int i;
< 	GdkDisplay *display;
< 	gint keycodes[] = {0, 0, 0, 0};
< 
< 	keycodes[0] = XKeysymToKeycode(GDK_DISPLAY(), XF86XK_AudioPrev);
< 	keycodes[1] = XKeysymToKeycode(GDK_DISPLAY(), XF86XK_AudioNext);
< 	keycodes[2] = XKeysymToKeycode(GDK_DISPLAY(), XF86XK_AudioPlay);
< 	keycodes[3] = XKeysymToKeycode(GDK_DISPLAY(), XF86XK_AudioStop);
< 
< 	display = gdk_display_get_default();
< 	for (i = 0; i < gdk_display_get_n_screens(display); i++) {
< 		GdkScreen *screen = gdk_display_get_screen(display, i);
< 
< 		if (screen != NULL) {
< 			GdkWindow *root = gdk_screen_get_root_window(screen);
< 			int j;
< 
< 			for(j = 0; j < 4; j++)
< 				grab_key(keycodes[j], root);
< 			gdk_window_add_filter(root, filter_keys, gcd);
< 		}
< 	}
< }
< 
836c743
< 	/*CDSelection *cd_selection;*/
---
> 	CDSelection *cd_selection;
898,900c805
< 
< 	start_listener(gcd);
< 
---
> 	


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