mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-11-16 23:05:58 +01:00
core: Make Ctrl+u clear password input (#226)
* Make Ctrl+u clear password input * Fix inconsistent indentation * Make Ctrl+Backspace clear password input
This commit is contained in:
parent
e23b43e308
commit
87fce7923f
2 changed files with 13 additions and 11 deletions
|
@ -804,14 +804,12 @@ void CHyprlock::onKey(uint32_t key, bool down) {
|
|||
|
||||
m_bCapsLock = xkb_state_mod_name_is_active(g_pHyprlock->m_pXKBState, XKB_MOD_NAME_CAPS, XKB_STATE_MODS_LOCKED);
|
||||
m_bNumLock = xkb_state_mod_name_is_active(g_pHyprlock->m_pXKBState, XKB_MOD_NAME_NUM, XKB_STATE_MODS_LOCKED);
|
||||
m_bCtrl = xkb_state_mod_name_is_active(m_pXKBState, XKB_MOD_NAME_CTRL, XKB_STATE_MODS_EFFECTIVE);
|
||||
|
||||
if (SYM == XKB_KEY_BackSpace) {
|
||||
if (m_sPasswordState.passBuffer.length() > 0) {
|
||||
// handle utf-8
|
||||
while ((m_sPasswordState.passBuffer.back() & 0xc0) == 0x80)
|
||||
m_sPasswordState.passBuffer.pop_back();
|
||||
m_sPasswordState.passBuffer = m_sPasswordState.passBuffer.substr(0, m_sPasswordState.passBuffer.length() - 1);
|
||||
}
|
||||
if (SYM == XKB_KEY_Escape || (m_bCtrl && (SYM == XKB_KEY_u || SYM == XKB_KEY_BackSpace))) {
|
||||
Debug::log(LOG, "Clearing password buffer");
|
||||
|
||||
m_sPasswordState.passBuffer = "";
|
||||
} else if (SYM == XKB_KEY_Return || SYM == XKB_KEY_KP_Enter) {
|
||||
Debug::log(LOG, "Authenticating");
|
||||
|
||||
|
@ -823,10 +821,13 @@ void CHyprlock::onKey(uint32_t key, bool down) {
|
|||
}
|
||||
|
||||
m_sPasswordState.result = g_pPassword->verify(m_sPasswordState.passBuffer);
|
||||
} else if (SYM == XKB_KEY_Escape) {
|
||||
Debug::log(LOG, "Clearing password buffer");
|
||||
|
||||
m_sPasswordState.passBuffer = "";
|
||||
} else if (SYM == XKB_KEY_BackSpace) {
|
||||
if (m_sPasswordState.passBuffer.length() > 0) {
|
||||
// handle utf-8
|
||||
while ((m_sPasswordState.passBuffer.back() & 0xc0) == 0x80)
|
||||
m_sPasswordState.passBuffer.pop_back();
|
||||
m_sPasswordState.passBuffer = m_sPasswordState.passBuffer.substr(0, m_sPasswordState.passBuffer.length() - 1);
|
||||
}
|
||||
} else if (SYM == XKB_KEY_Caps_Lock) {
|
||||
m_bCapsLock = !m_bCapsLock;
|
||||
} else if (SYM == XKB_KEY_Num_Lock) {
|
||||
|
|
|
@ -87,6 +87,7 @@ class CHyprlock {
|
|||
|
||||
bool m_bCapsLock = false;
|
||||
bool m_bNumLock = false;
|
||||
bool m_bCtrl = false;
|
||||
bool m_bFadeStarted = false;
|
||||
//
|
||||
std::chrono::system_clock::time_point m_tGraceEnds;
|
||||
|
|
Loading…
Reference in a new issue