@@ -46,6 +46,7 @@ void CPasswordInputField::configure(const std::unordered_map<std::string, std::a
4646 dots.textFormat = std::any_cast<Hyprlang::STRING >(props.at (" dots_text_format" ));
4747 fadeOnEmpty = std::any_cast<Hyprlang::INT >(props.at (" fade_on_empty" ));
4848 fadeTimeoutMs = std::any_cast<Hyprlang::INT >(props.at (" fade_timeout" ));
49+ autoSubmitAfter = std::any_cast<Hyprlang::INT >(props.at (" auto_submit_after" ));
4950 hiddenInputState.enabled = std::any_cast<Hyprlang::INT >(props.at (" hide_input" ));
5051 rounding = std::any_cast<Hyprlang::INT >(props.at (" rounding" ));
5152 configPlaceholderText = std::any_cast<Hyprlang::STRING >(props.at (" placeholder_text" ));
@@ -107,6 +108,12 @@ void CPasswordInputField::reset() {
107108 fade.fadeOutTimer .reset ();
108109 }
109110
111+ if (autoSubmitTimer) {
112+ autoSubmitTimer->cancel ();
113+ autoSubmitTimer.reset ();
114+ pendingAutoSubmitBuffer.clear ();
115+ }
116+
110117 if (g_pHyprlock->isTerminating ())
111118 return ;
112119
@@ -130,6 +137,29 @@ void CPasswordInputField::onFadeOutTimer() {
130137 g_pHyprlock->renderOutput (outputStringPort);
131138}
132139
140+ static void autoSubmitCallback (AWP <CPasswordInputField> ref) {
141+ if (const auto PP = ref.lock (); PP )
142+ PP ->onAutoSubmitTimer ();
143+ }
144+
145+ void CPasswordInputField::onAutoSubmitTimer () {
146+ autoSubmitTimer.reset ();
147+
148+ if (g_pAuth->checkWaiting ()) {
149+ pendingAutoSubmitBuffer.clear ();
150+ return ;
151+ }
152+
153+ if (g_pHyprlock->getPasswordBuffer () != pendingAutoSubmitBuffer) {
154+ pendingAutoSubmitBuffer.clear ();
155+ return ;
156+ }
157+
158+ pendingAutoSubmitBuffer.clear ();
159+ g_pAuth->submitInput (g_pHyprlock->getPasswordBuffer ());
160+ g_pHyprlock->renderAllOutputs ();
161+ }
162+
133163void CPasswordInputField::updateFade () {
134164 if (!fadeOnEmpty) {
135165 fade.a ->setValueAndWarp (1.0 );
@@ -173,6 +203,24 @@ void CPasswordInputField::updateDots() {
173203 *dots.currentAmount = passwordLength;
174204}
175205
206+ void CPasswordInputField::updateAutoSubmit () {
207+ if (autoSubmitAfter <= 0 )
208+ return ;
209+
210+ const auto & passwordBuffer = g_pHyprlock->getPasswordBuffer ();
211+
212+ if (autoSubmitTimer && (checkWaiting || passwordLength != (size_t )autoSubmitAfter || passwordBuffer != pendingAutoSubmitBuffer)) {
213+ autoSubmitTimer->cancel ();
214+ autoSubmitTimer.reset ();
215+ pendingAutoSubmitBuffer.clear ();
216+ }
217+
218+ if (passwordLength == (size_t )autoSubmitAfter && !checkWaiting && !autoSubmitTimer) {
219+ pendingAutoSubmitBuffer = passwordBuffer;
220+ autoSubmitTimer = g_pHyprlock->addTimer (std::chrono::milliseconds (1 ), [REF = m_self](auto , auto ) { autoSubmitCallback (REF ); }, nullptr );
221+ }
222+ }
223+
176224bool CPasswordInputField::draw (const SRenderData& data) {
177225 if (firstRender || redrawShadow) {
178226 firstRender = false ;
@@ -186,6 +234,7 @@ bool CPasswordInputField::draw(const SRenderData& data) {
186234 checkWaiting = g_pAuth->checkWaiting ();
187235 displayFail = g_pAuth->m_bDisplayFailText ;
188236
237+ updateAutoSubmit ();
189238 updateFade ();
190239 updateDots ();
191240 updateColors ();
0 commit comments