Skip to content
Closed
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
10 changes: 9 additions & 1 deletion bin/omarchy-hyprland-monitor-clamshell
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,22 @@ dpms_internal() {

enable_internal() {
local changed=0
local locked_state=0

if [[ -f $CLAMSHELL_FLAG ]]; then
rm -f "$CLAMSHELL_FLAG"
changed=1
fi

if (( changed )); then
hyprctl reload >/dev/null 2>&1 || true
# Reload under ext-session-lock drops keyboard focus on the lock surface
# (#7811). Re-enable the internal panel in place instead.
omarchy-hyprland-session-locked || locked_state=$?
if (( locked_state == 0 || locked_state == 2 )); then
enable_internal_output
else
hyprctl reload >/dev/null 2>&1 || true
fi
fi

[[ -f $MANUAL_DISABLE_FLAG ]] && omarchy-hyprland-monitor-external-active && return 0
Expand Down
1 change: 1 addition & 0 deletions shell/plugins/lock/LockView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ Item {
verticalAlignment: TextInput.AlignVCenter
horizontalAlignment: TextInput.AlignHCenter
activeFocusOnPress: true
focus: true
clip: true
enabled: root.inputEnabled && !root.authenticatingPassword
readOnly: root.authenticatingPassword
Expand Down
14 changes: 13 additions & 1 deletion shell/plugins/lock/Service.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ Item {

for (var i = 0; i < screens.length; i++) {
var screen = screens[i]
if (screen && screen.name && screen.width > 0 && screen.height > 0) count += 1
// Quickshell's placeholder "FALLBACK" screen is not a real connector.
// Locking against it, then watching it disappear, leaves a secure lock
// with no keyboard focus on the panel that comes back (#7811).
if (!screen || !screen.name || screen.name === "FALLBACK") continue
if (screen.width > 0 && screen.height > 0) count += 1
}

return count
Expand All @@ -64,6 +68,12 @@ Item {
return realScreenCount() > 0
}

function forceLockPasswordFocus() {
if (!lockRequested) return
if (lockView && typeof lockView.forcePasswordFocus === "function")
Qt.callLater(function() { lockView.forcePasswordFocus() })
}

function queueSessionLock() {
pendingSessionLock = true
if (!sessionLockStabilizeTimer.running) logEvent("lock-pending: screen-stabilizing")
Expand Down Expand Up @@ -190,6 +200,7 @@ Item {
root.monitorDpmsKnown = false
if (!wakeProcess.running) wakeProcess.running = true
if (lockRequested) armBlankTimer()
forceLockPasswordFocus()
}

function runBlank() {
Expand Down Expand Up @@ -571,6 +582,7 @@ Item {
// A monitor still coming up has no workspace, so cannot answer yet.
strandedLockRetryTimer.rearm()
root.checkStrandedLock()
root.forceLockPasswordFocus()
}
}

Expand Down
45 changes: 45 additions & 0 deletions test/shell.d/lock-focus-after-lid-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

clamshell="$ROOT/bin/omarchy-hyprland-monitor-clamshell"
service="$ROOT/shell/plugins/lock/Service.qml"
lock_view="$ROOT/shell/plugins/lock/LockView.qml"

grep -F 'omarchy-hyprland-session-locked' "$clamshell" >/dev/null ||
fail "clamshell enable_internal consults the session-lock probe"
grep -F 'enable_internal_output' "$clamshell" >/dev/null ||
fail "clamshell can re-enable the internal panel without reload"
# The locked branch must call enable_internal_output; the unlocked branch keeps reload.
awk '
/enable_internal\(\)/ { in_fn=1 }
in_fn {
print
if (/^}$/) exit
}
' "$clamshell" >"$TMPDIR/enable-internal.txt"
grep -F 'omarchy-hyprland-session-locked' "$TMPDIR/enable-internal.txt" >/dev/null ||
fail "enable_internal checks session lock before reload"
grep -F 'hyprctl reload' "$TMPDIR/enable-internal.txt" >/dev/null ||
fail "enable_internal still reloads when unlocked"
grep -F 'enable_internal_output' "$TMPDIR/enable-internal.txt" >/dev/null ||
fail "enable_internal re-enables in place when locked"
pass "clamshell skips hyprctl reload while the session is locked"

grep -F 'screen.name === "FALLBACK"' "$service" >/dev/null ||
fail "hasRealScreen rejects the Quickshell FALLBACK placeholder"
pass "lock acquire ignores the FALLBACK placeholder screen"

grep -F 'forceLockPasswordFocus' "$service" >/dev/null ||
fail "lock service exposes forceLockPasswordFocus"
grep -F 'forceLockPasswordFocus()' "$service" >/dev/null ||
fail "lock service calls forceLockPasswordFocus"
grep -F 'root.forceLockPasswordFocus()' "$service" >/dev/null ||
fail "onScreensChanged restores password focus"
pass "lock restores password focus after wake and screen changes"

grep -E 'focus: true' "$lock_view" >/dev/null ||
fail "password field requests focus on creation"
pass "password field focuses without requiring a click"