mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-11-16 23:05:58 +01:00
parent
94ac7fef1a
commit
4acf8981b3
2 changed files with 21 additions and 6 deletions
|
@ -563,10 +563,7 @@ static void handleKeyboardKeymap(void* data, wl_keyboard* wl_keyboard, uint form
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleKeyboardKey(void* data, struct wl_keyboard* keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) {
|
static void handleKeyboardKey(void* data, struct wl_keyboard* keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) {
|
||||||
if (state != WL_KEYBOARD_KEY_STATE_PRESSED)
|
g_pHyprlock->onKey(key, state == WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||||
return;
|
|
||||||
|
|
||||||
g_pHyprlock->onKey(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleKeyboardEnter(void* data, wl_keyboard* wl_keyboard, uint serial, wl_surface* surface, wl_array* keys) {
|
static void handleKeyboardEnter(void* data, wl_keyboard* wl_keyboard, uint serial, wl_surface* surface, wl_array* keys) {
|
||||||
|
@ -653,9 +650,25 @@ std::optional<std::string> CHyprlock::passwordLastFailReason() {
|
||||||
return m_sPasswordState.lastFailReason;
|
return m_sPasswordState.lastFailReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprlock::onKey(uint32_t key) {
|
void CHyprlock::onKey(uint32_t key, bool down) {
|
||||||
const auto SYM = xkb_state_key_get_one_sym(m_pXKBState, key + 8);
|
const auto SYM = xkb_state_key_get_one_sym(m_pXKBState, key + 8);
|
||||||
|
|
||||||
|
if (down && std::find(m_vPressedKeys.begin(), m_vPressedKeys.end(), SYM) != m_vPressedKeys.end()) {
|
||||||
|
Debug::log(ERR, "Invalid key down event (key already pressed?)");
|
||||||
|
return;
|
||||||
|
} else if (!down && std::find(m_vPressedKeys.begin(), m_vPressedKeys.end(), SYM) == m_vPressedKeys.end()) {
|
||||||
|
Debug::log(ERR, "Invalid key down event (stray release event?)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (down)
|
||||||
|
m_vPressedKeys.push_back(SYM);
|
||||||
|
else
|
||||||
|
std::erase(m_vPressedKeys, SYM);
|
||||||
|
|
||||||
|
if (!down) // we dont care about up events
|
||||||
|
return;
|
||||||
|
|
||||||
if (m_sPasswordState.result) {
|
if (m_sPasswordState.result) {
|
||||||
for (auto& o : m_vOutputs) {
|
for (auto& o : m_vOutputs) {
|
||||||
o->sessionLockSurface->render();
|
o->sessionLockSurface->render();
|
||||||
|
|
|
@ -46,7 +46,7 @@ class CHyprlock {
|
||||||
void spawnAsync(const std::string& cmd);
|
void spawnAsync(const std::string& cmd);
|
||||||
std::string spawnSync(const std::string& cmd);
|
std::string spawnSync(const std::string& cmd);
|
||||||
|
|
||||||
void onKey(uint32_t key);
|
void onKey(uint32_t key, bool down);
|
||||||
void onPasswordCheckTimer();
|
void onPasswordCheckTimer();
|
||||||
bool passwordCheckWaiting();
|
bool passwordCheckWaiting();
|
||||||
std::optional<std::string> passwordLastFailReason();
|
std::optional<std::string> passwordLastFailReason();
|
||||||
|
@ -128,6 +128,8 @@ class CHyprlock {
|
||||||
} m_sLoopState;
|
} m_sLoopState;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<CTimer>> m_vTimers;
|
std::vector<std::shared_ptr<CTimer>> m_vTimers;
|
||||||
|
|
||||||
|
std::vector<uint32_t> m_vPressedKeys;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CHyprlock> g_pHyprlock;
|
inline std::unique_ptr<CHyprlock> g_pHyprlock;
|
Loading…
Reference in a new issue