mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 22:05:58 +01:00
parent
b54eecbd79
commit
736a8735b3
3 changed files with 14 additions and 3 deletions
|
@ -178,13 +178,18 @@ void IKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) {
|
||||||
if (xkbState)
|
if (xkbState)
|
||||||
xkb_state_unref(xkbState);
|
xkb_state_unref(xkbState);
|
||||||
|
|
||||||
|
if (xkbSymState)
|
||||||
|
xkb_state_unref(xkbSymState);
|
||||||
|
|
||||||
xkbState = nullptr;
|
xkbState = nullptr;
|
||||||
xkbStaticState = nullptr;
|
xkbStaticState = nullptr;
|
||||||
|
xkbSymState = nullptr;
|
||||||
|
|
||||||
if (keymap) {
|
if (keymap) {
|
||||||
Debug::log(LOG, "Updating keyboard {:x}'s translation state from a provided keymap", (uintptr_t)this);
|
Debug::log(LOG, "Updating keyboard {:x}'s translation state from a provided keymap", (uintptr_t)this);
|
||||||
xkbStaticState = xkb_state_new(keymap);
|
xkbStaticState = xkb_state_new(keymap);
|
||||||
xkbState = xkb_state_new(keymap);
|
xkbState = xkb_state_new(keymap);
|
||||||
|
xkbSymState = xkb_state_new(keymap);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,6 +235,7 @@ void IKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) {
|
||||||
|
|
||||||
xkbState = xkb_state_new(KEYMAP);
|
xkbState = xkb_state_new(KEYMAP);
|
||||||
xkbStaticState = xkb_state_new(KEYMAP);
|
xkbStaticState = xkb_state_new(KEYMAP);
|
||||||
|
xkbSymState = xkb_state_new(KEYMAP);
|
||||||
|
|
||||||
xkb_keymap_unref(KEYMAP);
|
xkb_keymap_unref(KEYMAP);
|
||||||
xkb_context_unref(PCONTEXT);
|
xkb_context_unref(PCONTEXT);
|
||||||
|
@ -252,6 +258,7 @@ void IKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) {
|
||||||
|
|
||||||
xkbState = xkb_state_new(NEWKEYMAP);
|
xkbState = xkb_state_new(NEWKEYMAP);
|
||||||
xkbStaticState = xkb_state_new(NEWKEYMAP);
|
xkbStaticState = xkb_state_new(NEWKEYMAP);
|
||||||
|
xkbSymState = xkb_state_new(NEWKEYMAP);
|
||||||
|
|
||||||
xkb_keymap_unref(NEWKEYMAP);
|
xkb_keymap_unref(NEWKEYMAP);
|
||||||
xkb_context_unref(PCONTEXT);
|
xkb_context_unref(PCONTEXT);
|
||||||
|
@ -332,6 +339,9 @@ void IKeyboard::updateModifiers(uint32_t depressed, uint32_t latched, uint32_t l
|
||||||
|
|
||||||
xkb_state_update_mask(xkbState, depressed, latched, locked, 0, 0, group);
|
xkb_state_update_mask(xkbState, depressed, latched, locked, 0, 0, group);
|
||||||
|
|
||||||
|
if (xkbSymState)
|
||||||
|
xkb_state_update_mask(xkbSymState, 0, 0, 0, 0, 0, group);
|
||||||
|
|
||||||
if (!updateModifiersState())
|
if (!updateModifiersState())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,8 @@ class IKeyboard : public IHID {
|
||||||
bool keymapOverridden = false;
|
bool keymapOverridden = false;
|
||||||
|
|
||||||
xkb_layout_index_t activeLayout = 0;
|
xkb_layout_index_t activeLayout = 0;
|
||||||
xkb_state * xkbState = nullptr, *xkbStaticState /* Static state: never gets modifiers or layout changes sent, used for keybinds. */ = nullptr;
|
xkb_state * xkbState = nullptr, *xkbStaticState /* Static state: never gets modifiers or layout changes sent, used for keybinds. */ = nullptr,
|
||||||
|
*xkbSymState = nullptr /* Same as static but gets layouts */;
|
||||||
xkb_keymap* xkbKeymap = nullptr;
|
xkb_keymap* xkbKeymap = nullptr;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -376,7 +376,7 @@ bool CKeybindManager::onKeyEvent(std::any event, SP<IKeyboard> pKeyboard) {
|
||||||
|
|
||||||
const auto KEYCODE = e.keycode + 8; // Because to xkbcommon it's +8 from libinput
|
const auto KEYCODE = e.keycode + 8; // Because to xkbcommon it's +8 from libinput
|
||||||
|
|
||||||
const xkb_keysym_t keysym = xkb_state_key_get_one_sym(pKeyboard->resolveBindsBySym ? pKeyboard->xkbState : m_pXKBTranslationState, KEYCODE);
|
const xkb_keysym_t keysym = xkb_state_key_get_one_sym(pKeyboard->resolveBindsBySym ? pKeyboard->xkbSymState : m_pXKBTranslationState, KEYCODE);
|
||||||
const xkb_keysym_t internalKeysym = xkb_state_key_get_one_sym(pKeyboard->xkbState, KEYCODE);
|
const xkb_keysym_t internalKeysym = xkb_state_key_get_one_sym(pKeyboard->xkbState, KEYCODE);
|
||||||
|
|
||||||
if (handleInternalKeybinds(internalKeysym))
|
if (handleInternalKeybinds(internalKeysym))
|
||||||
|
|
Loading…
Reference in a new issue