libkeybinder/bind.c
static GdkModifierType
FinallyGetModifiersForKeycode (XkbDescPtr xkb,
                               KeyCode    key,
                               guint      group,
                               guint      level)
{
	int nKeyGroups;
	int effectiveGroup;
	XkbKeyTypeRec *type;
	int k;

	nKeyGroups = XkbKeyNumGroups(xkb, key);
	if ((!XkbKeycodeInRange(xkb, key)) || (nKeyGroups == 0)) {
		return MODIFIERS_ERROR;
	}

	/* Taken from GDK's MyEnhancedXkbTranslateKeyCode */
	/* find the offset of the effective group */
	effectiveGroup = group;
	if (effectiveGroup >= nKeyGroups) {
		unsigned groupInfo = XkbKeyGroupInfo(xkb,key);
		switch (XkbOutOfRangeGroupAction(groupInfo)) {
			default:
				effectiveGroup %= nKeyGroups;
				break;
			case XkbClampIntoRange:
				effectiveGroup = nKeyGroups-1;
				break;
			case XkbRedirectIntoRange:
				effectiveGroup = XkbOutOfRangeGroupNumber(groupInfo);
				if (effectiveGroup >= nKeyGroups)
					effectiveGroup = 0;
				break;
		}
	}
	type = XkbKeyKeyType(xkb, key, effectiveGroup);
	for (k = 0; k < type->map_count; k++) {
		if (type->map[k].active && type->map[k].level == level) {
			if (type->preserve) {
				return (type->map[k].mods.mask &
				        ~type->preserve[k].mask);
			} else {
				return type->map[k].mods.mask;
			}
		}
	}
	return MODIFIERS_NONE;
}
/* Return the modifier mask that needs to be pressed to produce key in the
 * given group (keyboard layout) and level ("shift level").
 */
Return the modifier mask that needs to be pressed to produce key in the
given group (keyboard layout) and level ("shift level").
Return the modifier mask that needs to be pressed to produce key in the given group ( keyboard layout ) and level ( " shift level " ) .
static GdkModifierType
FinallyGetModifiersForKeycode (XkbDescPtr xkb,
                               KeyCode    key,
                               guint      group,
                               guint      level)
{
	int nKeyGroups;
	int effectiveGroup;
	XkbKeyTypeRec *type;
	int k;
	nKeyGroups = XkbKeyNumGroups(xkb, key);
	if ((!XkbKeycodeInRange(xkb, key)) || (nKeyGroups == 0)) {
		return MODIFIERS_ERROR;
	}
	effectiveGroup = group;
	if (effectiveGroup >= nKeyGroups) {
		unsigned groupInfo = XkbKeyGroupInfo(xkb,key);
		switch (XkbOutOfRangeGroupAction(groupInfo)) {
			default:
				effectiveGroup %= nKeyGroups;
				break;
			case XkbClampIntoRange:
				effectiveGroup = nKeyGroups-1;
				break;
			case XkbRedirectIntoRange:
				effectiveGroup = XkbOutOfRangeGroupNumber(groupInfo);
				if (effectiveGroup >= nKeyGroups)
					effectiveGroup = 0;
				break;
		}
	}
	type = XkbKeyKeyType(xkb, key, effectiveGroup);
	for (k = 0; k < type->map_count; k++) {
		if (type->map[k].active && type->map[k].level == level) {
			if (type->preserve) {
				return (type->map[k].mods.mask &
				        ~type->preserve[k].mask);
			} else {
				return type->map[k].mods.mask;
			}
		}
	}
	return MODIFIERS_NONE;
}
static GdkModifierType FinallyGetModifiersForKeycode ( XkbDescPtr xkb , KeyCode key , guint group , guint level ) { int nKeyGroups ; int effectiveGroup ; XkbKeyTypeRec * type ; int k ; nKeyGroups = XkbKeyNumGroups ( xkb , key ) ; if ( ( ! XkbKeycodeInRange ( xkb , key ) ) || ( nKeyGroups == 0 ) ) { return MODIFIERS_ERROR ; } effectiveGroup = group ; if ( effectiveGroup >= nKeyGroups ) { unsigned groupInfo = XkbKeyGroupInfo ( xkb , key ) ; switch ( XkbOutOfRangeGroupAction ( groupInfo ) ) { default : effectiveGroup %= nKeyGroups ; break ; case XkbClampIntoRange : effectiveGroup = nKeyGroups - 1 ; break ; case XkbRedirectIntoRange : effectiveGroup = XkbOutOfRangeGroupNumber ( groupInfo ) ; if ( effectiveGroup >= nKeyGroups ) effectiveGroup = 0 ; break ; } } type = XkbKeyKeyType ( xkb , key , effectiveGroup ) ; for ( k = 0 ; k < type -> map_count ; k ++ ) { if ( type -> map [ k ] . active && type -> map [ k ] . level == level ) { if ( type -> preserve ) { return ( type -> map [ k ] . mods . mask & ~ type -> preserve [ k ] . mask ) ; } else { return type -> map [ k ] . mods . mask ; } } } return MODIFIERS_NONE ; }
Return the modifier mask that needs to be pressed to produce key in the
 given group (keyboard layout) and level ("shift level").
Return the modifier mask that needs to be pressed to produce key in the given group ( keyboard layout ) and level ( " shift level " ) .
/* Taken from GDK's MyEnhancedXkbTranslateKeyCode */ /* find the offset of the effective group */