mirror of
https://github.com/hyprwm/hyprlock.git
synced 2026-05-08 22:08:02 +02:00
when hitting tab, it shows and hides the password
This commit is contained in:
parent
8ccdf6131b
commit
3e8a2d0cde
4 changed files with 13 additions and 5 deletions
|
|
@ -655,6 +655,8 @@ void CHyprlock::handleKeySym(xkb_keysym_t sym, bool composed) {
|
|||
m_sPasswordState.passBuffer.pop_back();
|
||||
m_sPasswordState.passBuffer = m_sPasswordState.passBuffer.substr(0, m_sPasswordState.passBuffer.length() - 1);
|
||||
}
|
||||
} else if (SYM == XKB_KEY_Tab) {
|
||||
m_sPasswordState.show = !m_sPasswordState.show;
|
||||
} else if (SYM == XKB_KEY_Caps_Lock) {
|
||||
m_bCapsLock = !m_bCapsLock;
|
||||
} else if (SYM == XKB_KEY_Num_Lock) {
|
||||
|
|
@ -844,6 +846,10 @@ std::string CHyprlock::getPasswordBuffer() {
|
|||
return m_sPasswordState.passBuffer;
|
||||
}
|
||||
|
||||
bool CHyprlock::getPasswordShow() {
|
||||
return m_sPasswordState.show;
|
||||
}
|
||||
|
||||
size_t CHyprlock::getPasswordBufferDisplayLen() {
|
||||
// Counts utf-8 codepoints in the buffer. A byte is counted if it does not match 0b10xxxxxx.
|
||||
return std::count_if(m_sPasswordState.passBuffer.begin(), m_sPasswordState.passBuffer.end(), [](char c) { return (c & 0xc0) != 0x80; });
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ class CHyprlock {
|
|||
size_t getPasswordBufferLen();
|
||||
size_t getPasswordBufferDisplayLen();
|
||||
std::string getPasswordBuffer();
|
||||
bool getPasswordShow();
|
||||
|
||||
SP<CCExtSessionLockManagerV1> getSessionLockMgr();
|
||||
SP<CCExtSessionLockV1> getSessionLock();
|
||||
|
|
@ -139,6 +140,7 @@ class CHyprlock {
|
|||
} m_sLockState;
|
||||
|
||||
struct {
|
||||
bool show = false;
|
||||
std::string passBuffer = "";
|
||||
size_t failedAttempts = 0;
|
||||
bool displayFailText = false;
|
||||
|
|
|
|||
|
|
@ -232,9 +232,10 @@ bool CPasswordInputField::draw(const SRenderData& data) {
|
|||
|
||||
bool forceReload = false;
|
||||
|
||||
passwordLength = g_pHyprlock->getPasswordBufferDisplayLen();
|
||||
checkWaiting = g_pAuth->checkWaiting();
|
||||
displayFail = g_pAuth->m_bDisplayFailText;
|
||||
bool showPassword = g_pHyprlock->getPasswordShow();
|
||||
passwordLength = g_pHyprlock->getPasswordBufferDisplayLen();
|
||||
checkWaiting = g_pAuth->checkWaiting();
|
||||
displayFail = g_pAuth->m_bDisplayFailText;
|
||||
|
||||
updatePassword();
|
||||
updateFade();
|
||||
|
|
@ -286,7 +287,7 @@ bool CPasswordInputField::draw(const SRenderData& data) {
|
|||
g_pRenderer->renderRect(inputFieldBox, innerCol, ROUND);
|
||||
|
||||
if (!hiddenInputState.enabled) {
|
||||
if (!password.show) {
|
||||
if (!showPassword) {
|
||||
const int RECTPASSSIZE = std::nearbyint(inputFieldBox.h * dots.size * 0.5f) * 2.f;
|
||||
Vector2D passSize{RECTPASSSIZE, RECTPASSSIZE};
|
||||
int passSpacing = std::floor(passSize.x * dots.spacing);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ class CPasswordInputField : public IWidget {
|
|||
} dots;
|
||||
|
||||
struct {
|
||||
bool show = false;
|
||||
bool center = false;
|
||||
float size = .25;
|
||||
std::string content;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue