Wayland: Fix missing lock key modifier bits
The modifier bits for lock keys were only set when the corresponding key
was reported as held down or latched, but not when it was released and
locked.
(cherry picked from commit e9c58bc181
)
This commit is contained in:
parent
2a6d25d1aa
commit
6de6446aca
@ -145,6 +145,7 @@ information on what to include when reporting a bug.
|
|||||||
- [Wayland] Bugfix: MIME type matching was not performed for clipboard string
|
- [Wayland] Bugfix: MIME type matching was not performed for clipboard string
|
||||||
- [Wayland] Bugfix: The OSMesa library was not unloaded on termination
|
- [Wayland] Bugfix: The OSMesa library was not unloaded on termination
|
||||||
- [Wayland] Bugfix: `glfwCreateWindow` could emit `GLFW_PLATFORM_ERROR`
|
- [Wayland] Bugfix: `glfwCreateWindow` could emit `GLFW_PLATFORM_ERROR`
|
||||||
|
- [Wayland] Bugfix: Lock key modifier bits were only set when lock keys were pressed
|
||||||
|
|
||||||
|
|
||||||
## Contact
|
## Contact
|
||||||
|
@ -381,10 +381,10 @@ int _glfwPlatformInit(void)
|
|||||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_key_get_syms");
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_key_get_syms");
|
||||||
_glfw.wl.xkb.state_update_mask = (PFN_xkb_state_update_mask)
|
_glfw.wl.xkb.state_update_mask = (PFN_xkb_state_update_mask)
|
||||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_update_mask");
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_update_mask");
|
||||||
_glfw.wl.xkb.state_serialize_mods = (PFN_xkb_state_serialize_mods)
|
|
||||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_serialize_mods");
|
|
||||||
_glfw.wl.xkb.state_key_get_layout = (PFN_xkb_state_key_get_layout)
|
_glfw.wl.xkb.state_key_get_layout = (PFN_xkb_state_key_get_layout)
|
||||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_key_get_layout");
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_key_get_layout");
|
||||||
|
_glfw.wl.xkb.state_mod_index_is_active = (PFN_xkb_state_mod_index_is_active)
|
||||||
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_mod_index_is_active");
|
||||||
|
|
||||||
_glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale)
|
_glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale)
|
||||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale");
|
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale");
|
||||||
|
@ -115,8 +115,8 @@ typedef struct xkb_state* (* PFN_xkb_state_new)(struct xkb_keymap*);
|
|||||||
typedef void (* PFN_xkb_state_unref)(struct xkb_state*);
|
typedef void (* PFN_xkb_state_unref)(struct xkb_state*);
|
||||||
typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, const xkb_keysym_t**);
|
typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, const xkb_keysym_t**);
|
||||||
typedef enum xkb_state_component (* PFN_xkb_state_update_mask)(struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t);
|
typedef enum xkb_state_component (* PFN_xkb_state_update_mask)(struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t);
|
||||||
typedef xkb_mod_mask_t (* PFN_xkb_state_serialize_mods)(struct xkb_state*, enum xkb_state_component);
|
|
||||||
typedef xkb_layout_index_t (* PFN_xkb_state_key_get_layout)(struct xkb_state*,xkb_keycode_t);
|
typedef xkb_layout_index_t (* PFN_xkb_state_key_get_layout)(struct xkb_state*,xkb_keycode_t);
|
||||||
|
typedef int (* PFN_xkb_state_mod_index_is_active)(struct xkb_state*,xkb_mod_index_t,enum xkb_state_component);
|
||||||
#define xkb_context_new _glfw.wl.xkb.context_new
|
#define xkb_context_new _glfw.wl.xkb.context_new
|
||||||
#define xkb_context_unref _glfw.wl.xkb.context_unref
|
#define xkb_context_unref _glfw.wl.xkb.context_unref
|
||||||
#define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string
|
#define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string
|
||||||
@ -128,8 +128,8 @@ typedef xkb_layout_index_t (* PFN_xkb_state_key_get_layout)(struct xkb_state*,xk
|
|||||||
#define xkb_state_unref _glfw.wl.xkb.state_unref
|
#define xkb_state_unref _glfw.wl.xkb.state_unref
|
||||||
#define xkb_state_key_get_syms _glfw.wl.xkb.state_key_get_syms
|
#define xkb_state_key_get_syms _glfw.wl.xkb.state_key_get_syms
|
||||||
#define xkb_state_update_mask _glfw.wl.xkb.state_update_mask
|
#define xkb_state_update_mask _glfw.wl.xkb.state_update_mask
|
||||||
#define xkb_state_serialize_mods _glfw.wl.xkb.state_serialize_mods
|
|
||||||
#define xkb_state_key_get_layout _glfw.wl.xkb.state_key_get_layout
|
#define xkb_state_key_get_layout _glfw.wl.xkb.state_key_get_layout
|
||||||
|
#define xkb_state_mod_index_is_active _glfw.wl.xkb.state_mod_index_is_active
|
||||||
|
|
||||||
typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags);
|
typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags);
|
||||||
typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*);
|
typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*);
|
||||||
@ -283,12 +283,12 @@ typedef struct _GLFWlibraryWayland
|
|||||||
struct xkb_state* state;
|
struct xkb_state* state;
|
||||||
struct xkb_compose_state* composeState;
|
struct xkb_compose_state* composeState;
|
||||||
|
|
||||||
xkb_mod_mask_t controlMask;
|
xkb_mod_index_t controlIndex;
|
||||||
xkb_mod_mask_t altMask;
|
xkb_mod_index_t altIndex;
|
||||||
xkb_mod_mask_t shiftMask;
|
xkb_mod_index_t shiftIndex;
|
||||||
xkb_mod_mask_t superMask;
|
xkb_mod_index_t superIndex;
|
||||||
xkb_mod_mask_t capsLockMask;
|
xkb_mod_index_t capsLockIndex;
|
||||||
xkb_mod_mask_t numLockMask;
|
xkb_mod_index_t numLockIndex;
|
||||||
unsigned int modifiers;
|
unsigned int modifiers;
|
||||||
|
|
||||||
PFN_xkb_context_new context_new;
|
PFN_xkb_context_new context_new;
|
||||||
@ -302,8 +302,8 @@ typedef struct _GLFWlibraryWayland
|
|||||||
PFN_xkb_state_unref state_unref;
|
PFN_xkb_state_unref state_unref;
|
||||||
PFN_xkb_state_key_get_syms state_key_get_syms;
|
PFN_xkb_state_key_get_syms state_key_get_syms;
|
||||||
PFN_xkb_state_update_mask state_update_mask;
|
PFN_xkb_state_update_mask state_update_mask;
|
||||||
PFN_xkb_state_serialize_mods state_serialize_mods;
|
|
||||||
PFN_xkb_state_key_get_layout state_key_get_layout;
|
PFN_xkb_state_key_get_layout state_key_get_layout;
|
||||||
|
PFN_xkb_state_mod_index_is_active state_mod_index_is_active;
|
||||||
|
|
||||||
PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale;
|
PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale;
|
||||||
PFN_xkb_compose_table_unref compose_table_unref;
|
PFN_xkb_compose_table_unref compose_table_unref;
|
||||||
|
@ -1442,18 +1442,12 @@ static void keyboardHandleKeymap(void* userData,
|
|||||||
_glfw.wl.xkb.keymap = keymap;
|
_glfw.wl.xkb.keymap = keymap;
|
||||||
_glfw.wl.xkb.state = state;
|
_glfw.wl.xkb.state = state;
|
||||||
|
|
||||||
_glfw.wl.xkb.controlMask =
|
_glfw.wl.xkb.controlIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Control");
|
||||||
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Control");
|
_glfw.wl.xkb.altIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod1");
|
||||||
_glfw.wl.xkb.altMask =
|
_glfw.wl.xkb.shiftIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Shift");
|
||||||
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod1");
|
_glfw.wl.xkb.superIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod4");
|
||||||
_glfw.wl.xkb.shiftMask =
|
_glfw.wl.xkb.capsLockIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Lock");
|
||||||
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Shift");
|
_glfw.wl.xkb.numLockIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod2");
|
||||||
_glfw.wl.xkb.superMask =
|
|
||||||
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod4");
|
|
||||||
_glfw.wl.xkb.capsLockMask =
|
|
||||||
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Lock");
|
|
||||||
_glfw.wl.xkb.numLockMask =
|
|
||||||
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod2");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void keyboardHandleEnter(void* userData,
|
static void keyboardHandleEnter(void* userData,
|
||||||
@ -1607,27 +1601,49 @@ static void keyboardHandleModifiers(void* userData,
|
|||||||
0,
|
0,
|
||||||
group);
|
group);
|
||||||
|
|
||||||
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;
|
unsigned int mods = 0;
|
||||||
|
|
||||||
if (mask & _glfw.wl.xkb.controlMask)
|
if (xkb_state_mod_index_is_active(_glfw.wl.xkb.state,
|
||||||
|
_glfw.wl.xkb.controlIndex,
|
||||||
|
XKB_STATE_MODS_EFFECTIVE) == 1)
|
||||||
|
{
|
||||||
mods |= GLFW_MOD_CONTROL;
|
mods |= GLFW_MOD_CONTROL;
|
||||||
if (mask & _glfw.wl.xkb.altMask)
|
}
|
||||||
|
|
||||||
|
if (xkb_state_mod_index_is_active(_glfw.wl.xkb.state,
|
||||||
|
_glfw.wl.xkb.altIndex,
|
||||||
|
XKB_STATE_MODS_EFFECTIVE) == 1)
|
||||||
|
{
|
||||||
mods |= GLFW_MOD_ALT;
|
mods |= GLFW_MOD_ALT;
|
||||||
if (mask & _glfw.wl.xkb.shiftMask)
|
}
|
||||||
|
|
||||||
|
if (xkb_state_mod_index_is_active(_glfw.wl.xkb.state,
|
||||||
|
_glfw.wl.xkb.shiftIndex,
|
||||||
|
XKB_STATE_MODS_EFFECTIVE) == 1)
|
||||||
|
{
|
||||||
mods |= GLFW_MOD_SHIFT;
|
mods |= GLFW_MOD_SHIFT;
|
||||||
if (mask & _glfw.wl.xkb.superMask)
|
}
|
||||||
|
|
||||||
|
if (xkb_state_mod_index_is_active(_glfw.wl.xkb.state,
|
||||||
|
_glfw.wl.xkb.superIndex,
|
||||||
|
XKB_STATE_MODS_EFFECTIVE) == 1)
|
||||||
|
{
|
||||||
mods |= GLFW_MOD_SUPER;
|
mods |= GLFW_MOD_SUPER;
|
||||||
if (mask & _glfw.wl.xkb.capsLockMask)
|
}
|
||||||
|
|
||||||
|
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;
|
mods |= GLFW_MOD_CAPS_LOCK;
|
||||||
if (mask & _glfw.wl.xkb.numLockMask)
|
}
|
||||||
|
|
||||||
|
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;
|
mods |= GLFW_MOD_NUM_LOCK;
|
||||||
|
}
|
||||||
|
|
||||||
_glfw.wl.xkb.modifiers = mods;
|
_glfw.wl.xkb.modifiers = mods;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user