shl: misc: fix XKB modifier collector to check for errors

The XKB functions actually return <0 if the modifier is invalid. This
cannot happen for the hard-coded modifiers that we use, but it is still
safer to check correctly whether the returned value is >0.

Reported-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-10-11 16:45:30 +02:00
parent aaa084c01d
commit cc02876d6c

View File

@ -93,19 +93,19 @@ static inline unsigned int shl_get_xkb_mods(struct xkb_state *state)
unsigned int mods = 0; unsigned int mods = 0;
if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_SHIFT, if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_SHIFT,
XKB_STATE_EFFECTIVE)) XKB_STATE_EFFECTIVE) > 0)
mods |= SHL_SHIFT_MASK; mods |= SHL_SHIFT_MASK;
if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CAPS, if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CAPS,
XKB_STATE_EFFECTIVE)) XKB_STATE_EFFECTIVE) > 0)
mods |= SHL_LOCK_MASK; mods |= SHL_LOCK_MASK;
if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CTRL, if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CTRL,
XKB_STATE_EFFECTIVE)) XKB_STATE_EFFECTIVE) > 0)
mods |= SHL_CONTROL_MASK; mods |= SHL_CONTROL_MASK;
if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_ALT, if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_ALT,
XKB_STATE_EFFECTIVE)) XKB_STATE_EFFECTIVE) > 0)
mods |= SHL_ALT_MASK; mods |= SHL_ALT_MASK;
if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_LOGO, if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_LOGO,
XKB_STATE_EFFECTIVE)) XKB_STATE_EFFECTIVE) > 0)
mods |= SHL_LOGO_MASK; mods |= SHL_LOGO_MASK;
return mods; return mods;