Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/shell/lockscreen/lock_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,28 @@ LockSurface::LockSurface(WaylandConnection& connection, ConfigService* config) :
})
);

m_loginContentRow->addChild(
ui::button({
.out = &m_passwordRevealButton,
.text = "",
.glyph = "eye",
.glyphSize = 16.0F,
.variant = ButtonVariant::Ghost,
.onClick =
[this]() {
if (m_passwordField == nullptr) {
return;
}
m_passwordRevealed = !m_passwordRevealed;
m_passwordField->setPasswordMode(!m_passwordRevealed);
if (m_passwordRevealButton != nullptr) {
m_passwordRevealButton->setGlyph(m_passwordRevealed ? "eye-off" : "eye");
}
},
.configure = [](Button& button) { button.setZIndex(2); },
})
);

m_loginContentRow->addChild(
ui::button({
.out = &m_loginButton,
Expand Down Expand Up @@ -630,6 +652,16 @@ void LockSurface::setLockedState(bool locked) {
}
m_locked = locked;
if (m_locked) {
// Never carry a revealed password across lock cycles.
if (m_passwordRevealed) {
m_passwordRevealed = false;
if (m_passwordField != nullptr) {
m_passwordField->setPasswordMode(true);
}
if (m_passwordRevealButton != nullptr) {
m_passwordRevealButton->setGlyph("eye");
}
}
focusPasswordField();
} else {
m_inputDispatcher.setFocus(nullptr);
Expand Down Expand Up @@ -926,6 +958,9 @@ void LockSurface::layoutScene(std::uint32_t width, std::uint32_t height) {
m_widgetLayer->setVisible(false);
m_loginPanel->setVisible(false);
m_passwordField->setVisible(false);
if (m_passwordRevealButton != nullptr) {
m_passwordRevealButton->setVisible(false);
}
m_loginButton->setVisible(false);
if (m_infoRow != nullptr) {
m_infoRow->setVisible(false);
Expand All @@ -951,6 +986,9 @@ void LockSurface::layoutScene(std::uint32_t width, std::uint32_t height) {
m_loginPanel->setVisible(loginVisible);
m_loginContentRow->setVisible(loginVisible);
m_passwordField->setVisible(loginVisible);
if (m_passwordRevealButton != nullptr) {
m_passwordRevealButton->setVisible(loginVisible);
}
m_loginButton->setVisible(loginVisible && loginStyle.showLoginButton);

const bool regular = loginVisible && loginStyle.layout == lockscreen_login_box::LayoutMode::Regular;
Expand Down Expand Up @@ -1218,6 +1256,12 @@ void LockSurface::layoutScene(std::uint32_t width, std::uint32_t height) {
m_loginButton->setGlyphSize(sessionGlyphSize);
}

if (m_passwordRevealButton != nullptr) {
m_passwordRevealButton->setRadius(Style::scaledRadius(loginStyle.inputRadius));
m_passwordRevealButton->setSize(controlHeight, controlHeight);
m_passwordRevealButton->setGlyphSize(sessionGlyphSize);
}

m_loginPanel->arrange(renderer, LayoutRect{panelX, panelY, panelWidth, panelHeight});

// Auth panel: sibling above/below the login box (flips below when near the top edge).
Expand Down Expand Up @@ -1264,6 +1308,9 @@ void LockSurface::layoutScene(std::uint32_t width, std::uint32_t height) {
void LockSurface::updateCopy() {
m_passwordField->setValue(m_password);
m_passwordField->setEnabled(!m_authenticating);
if (m_passwordRevealButton != nullptr) {
m_passwordRevealButton->setEnabled(!m_authenticating);
}
if (m_loginButton != nullptr) {
m_loginButton->setEnabled(!m_authenticating);
}
Expand Down
2 changes: 2 additions & 0 deletions src/shell/lockscreen/lock_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ class LockSurface : public Surface {
Label* m_authLabel = nullptr;
Flex* m_loginContentRow = nullptr;
Input* m_passwordField = nullptr;
Button* m_passwordRevealButton = nullptr;
bool m_passwordRevealed = false;
Button* m_loginButton = nullptr;
Button* m_layoutChip = nullptr;
Flex* m_sessionRow = nullptr;
Expand Down