Skip to content

Commit

Permalink
Wayland: Clean up modifier key event handler
Browse files Browse the repository at this point in the history
Adapt style and naming to match the rest of the project.
  • Loading branch information
elmindreda committed Dec 31, 2021
1 parent 0ce6119 commit df8d7bc
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/wl_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,6 @@ static void keyboardHandleModifiers(void* data,
uint32_t modsLocked,
uint32_t group)
{
xkb_mod_mask_t mask;
unsigned int modifiers = 0;

_glfw.wl.serial = serial;

if (!_glfw.wl.xkb.keymap)
Expand All @@ -620,24 +617,29 @@ static void keyboardHandleModifiers(void* data,
0,
group);

mask = xkb_state_serialize_mods(_glfw.wl.xkb.state,
XKB_STATE_MODS_DEPRESSED |
XKB_STATE_LAYOUT_DEPRESSED |
XKB_STATE_MODS_LATCHED |
XKB_STATE_LAYOUT_LATCHED);
const xkb_mod_mask_t mask =
xkb_state_serialize_mods(_glfw.wl.xkb.state,
XKB_STATE_MODS_DEPRESSED |
XKB_STATE_LAYOUT_DEPRESSED |
XKB_STATE_MODS_LATCHED |
XKB_STATE_LAYOUT_LATCHED);

unsigned int mods = 0;

if (mask & _glfw.wl.xkb.controlMask)
modifiers |= GLFW_MOD_CONTROL;
mods |= GLFW_MOD_CONTROL;
if (mask & _glfw.wl.xkb.altMask)
modifiers |= GLFW_MOD_ALT;
mods |= GLFW_MOD_ALT;
if (mask & _glfw.wl.xkb.shiftMask)
modifiers |= GLFW_MOD_SHIFT;
mods |= GLFW_MOD_SHIFT;
if (mask & _glfw.wl.xkb.superMask)
modifiers |= GLFW_MOD_SUPER;
mods |= GLFW_MOD_SUPER;
if (mask & _glfw.wl.xkb.capsLockMask)
modifiers |= GLFW_MOD_CAPS_LOCK;
mods |= GLFW_MOD_CAPS_LOCK;
if (mask & _glfw.wl.xkb.numLockMask)
modifiers |= GLFW_MOD_NUM_LOCK;
_glfw.wl.xkb.modifiers = modifiers;
mods |= GLFW_MOD_NUM_LOCK;

_glfw.wl.xkb.modifiers = mods;
}

#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION
Expand Down

0 comments on commit df8d7bc

Please sign in to comment.