Wayland: Cleanup

(cherry picked from commit 523fdf50c1)
This commit is contained in:
Camilla Löwy 2022-06-16 13:32:31 +02:00
parent 3ec59687f1
commit 9f8ec83411

View File

@ -1601,51 +1601,31 @@ static void keyboardHandleModifiers(void* userData,
0, 0,
group); group);
unsigned int mods = 0; _glfw.wl.xkb.modifiers = 0;
if (xkb_state_mod_index_is_active(_glfw.wl.xkb.state, struct
_glfw.wl.xkb.controlIndex,
XKB_STATE_MODS_EFFECTIVE) == 1)
{ {
mods |= GLFW_MOD_CONTROL; xkb_mod_index_t index;
} unsigned int bit;
} modifiers[] =
if (xkb_state_mod_index_is_active(_glfw.wl.xkb.state,
_glfw.wl.xkb.altIndex,
XKB_STATE_MODS_EFFECTIVE) == 1)
{ {
mods |= GLFW_MOD_ALT; { _glfw.wl.xkb.controlIndex, GLFW_MOD_CONTROL },
} { _glfw.wl.xkb.altIndex, GLFW_MOD_ALT },
{ _glfw.wl.xkb.shiftIndex, GLFW_MOD_SHIFT },
{ _glfw.wl.xkb.superIndex, GLFW_MOD_SUPER },
{ _glfw.wl.xkb.capsLockIndex, GLFW_MOD_CAPS_LOCK },
{ _glfw.wl.xkb.numLockIndex, GLFW_MOD_NUM_LOCK }
};
if (xkb_state_mod_index_is_active(_glfw.wl.xkb.state, for (size_t i = 0; i < sizeof(modifiers) / sizeof(modifiers[0]); i++)
_glfw.wl.xkb.shiftIndex,
XKB_STATE_MODS_EFFECTIVE) == 1)
{ {
mods |= GLFW_MOD_SHIFT; if (xkb_state_mod_index_is_active(_glfw.wl.xkb.state,
modifiers[i].index,
XKB_STATE_MODS_EFFECTIVE) == 1)
{
_glfw.wl.xkb.modifiers |= modifiers[i].bit;
}
} }
if (xkb_state_mod_index_is_active(_glfw.wl.xkb.state,
_glfw.wl.xkb.superIndex,
XKB_STATE_MODS_EFFECTIVE) == 1)
{
mods |= GLFW_MOD_SUPER;
}
if (xkb_state_mod_index_is_active(_glfw.wl.xkb.state,
_glfw.wl.xkb.capsLockIndex,
XKB_STATE_MODS_EFFECTIVE) == 1)
{
mods |= GLFW_MOD_CAPS_LOCK;
}
if (xkb_state_mod_index_is_active(_glfw.wl.xkb.state,
_glfw.wl.xkb.numLockIndex,
XKB_STATE_MODS_EFFECTIVE) == 1)
{
mods |= GLFW_MOD_NUM_LOCK;
}
_glfw.wl.xkb.modifiers = mods;
} }
#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION #ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION