libkeybinder/bind.c
static gboolean
grab_ungrab_with_ignorable_modifiers (GdkWindow *rootwin,
                                      guint      keycode,
                                      guint      modifiers,
                                      gboolean   grab)
{
	guint i;
	gboolean success = FALSE;

	/* Ignorable modifiers */
	guint mod_masks [] = {
		0, /* modifier only */
		GDK_MOD2_MASK,
		GDK_LOCK_MASK,
		GDK_MOD2_MASK | GDK_LOCK_MASK,
	};

	gdk_error_trap_push ();

	for (i = 0; i < G_N_ELEMENTS (mod_masks); i++) {
		if (grab) {
			XGrabKey (GDK_WINDOW_XDISPLAY (rootwin),
			          keycode,
			          modifiers | mod_masks [i],
			          GDK_WINDOW_XID (rootwin),
			          False,
			          GrabModeAsync,
			          GrabModeAsync);
		} else {
			XUngrabKey (GDK_WINDOW_XDISPLAY (rootwin),
			            keycode,
			            modifiers | mod_masks [i],
			            GDK_WINDOW_XID (rootwin));
		}
	}
	gdk_flush();
	if (gdk_error_trap_pop()) {
		TRACE (g_print ("Failed grab/ungrab!\n"));
		if (grab) {
			/* On error, immediately release keys again */
			grab_ungrab_with_ignorable_modifiers(rootwin,
			                                     keycode,
			                                     modifiers,
			                                     FALSE);
		}
	} else {
		success = TRUE;
	}
	return success;
}
/* Grab or ungrab the keycode+modifiers combination, first plainly, and then
 * including each ignorable modifier in turn.
 */
Grab or ungrab the keycode+modifiers combination, first plainly, and then
including each ignorable modifier in turn.
Grab or ungrab the keycode + modifiers combination first plainly and then including each ignorable modifier in turn .
static gboolean
grab_ungrab_with_ignorable_modifiers (GdkWindow *rootwin,
                                      guint      keycode,
                                      guint      modifiers,
                                      gboolean   grab)
{
	guint i;
	gboolean success = FALSE;
	guint mod_masks [] = {
		0, 
		GDK_MOD2_MASK,
		GDK_LOCK_MASK,
		GDK_MOD2_MASK | GDK_LOCK_MASK,
	};
	gdk_error_trap_push ();
	for (i = 0; i < G_N_ELEMENTS (mod_masks); i++) {
		if (grab) {
			XGrabKey (GDK_WINDOW_XDISPLAY (rootwin),
			          keycode,
			          modifiers | mod_masks [i],
			          GDK_WINDOW_XID (rootwin),
			          False,
			          GrabModeAsync,
			          GrabModeAsync);
		} else {
			XUngrabKey (GDK_WINDOW_XDISPLAY (rootwin),
			            keycode,
			            modifiers | mod_masks [i],
			            GDK_WINDOW_XID (rootwin));
		}
	}
	gdk_flush();
	if (gdk_error_trap_pop()) {
		TRACE (g_print ("Failed grab/ungrab!\n"));
		if (grab) {
			grab_ungrab_with_ignorable_modifiers(rootwin,
			                                     keycode,
			                                     modifiers,
			                                     FALSE);
		}
	} else {
		success = TRUE;
	}
	return success;
}
static gboolean grab_ungrab_with_ignorable_modifiers ( GdkWindow * rootwin , guint keycode , guint modifiers , gboolean grab ) { guint i ; gboolean success = FALSE ; guint mod_masks [ ] = { 0 , GDK_MOD2_MASK , GDK_LOCK_MASK , GDK_MOD2_MASK | GDK_LOCK_MASK , } ; gdk_error_trap_push ( ) ; for ( i = 0 ; i < G_N_ELEMENTS ( mod_masks ) ; i ++ ) { if ( grab ) { XGrabKey ( GDK_WINDOW_XDISPLAY ( rootwin ) , keycode , modifiers | mod_masks [ i ] , GDK_WINDOW_XID ( rootwin ) , False , GrabModeAsync , GrabModeAsync ) ; } else { XUngrabKey ( GDK_WINDOW_XDISPLAY ( rootwin ) , keycode , modifiers | mod_masks [ i ] , GDK_WINDOW_XID ( rootwin ) ) ; } } gdk_flush ( ) ; if ( gdk_error_trap_pop ( ) ) { TRACE ( g_print ( " \n " ) ) ; if ( grab ) { grab_ungrab_with_ignorable_modifiers ( rootwin , keycode , modifiers , FALSE ) ; } } else { success = TRUE ; } return success ; }
Grab or ungrab the keycode+modifiers combination, first plainly, and then
 including each ignorable modifier in turn.
Grab or ungrab the keycode + modifiers combination first plainly and then including each ignorable modifier in turn .
/* Ignorable modifiers */ /* modifier only */ /* On error, immediately release keys again */