Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.
Merged
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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
)

require (
github.com/ebitengine/purego v0.8.2 // indirect
github.com/yalue/native_endian v1.0.2 // indirect
golang.org/x/text v0.23.0 // indirect
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc h1:7D+Bh06CRPCJO3gr2F7h1sriovOZ8BMhca2Rg85c2nk=
github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ebitengine/purego v0.7.1 h1:6/55d26lG3o9VCZX8lping+bZcmShseiqlh2bnUDiPA=
github.com/ebitengine/purego v0.7.1/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
github.com/ebitengine/purego v0.8.2 h1:jPPGWs2sZ1UgOSgD2bClL0MJIqu58nOmIcBuXr62z1I=
github.com/ebitengine/purego v0.8.2/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/msteinert/pam v1.2.0 h1:mYfjlvN2KYs2Pb9G6nb/1f/nPfAttT/Jee5Sq9r3bGE=
Expand Down
61 changes: 44 additions & 17 deletions internal/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package internal
import (
"os/exec"
"sync"
"time"

"github.com/BurntSushi/xgb"
"github.com/BurntSushi/xgb/xproto"
Expand Down Expand Up @@ -179,16 +180,14 @@ type outputInfo struct {

// RegistryHandler handles Wayland registry events
type RegistryHandler struct {
wl.OutputGeometryHandler
wl.OutputModeHandler

registry *wl.Registry
compositor *wl.Compositor
lockManager *ext.SessionLockManager
seat *wl.Seat
shm *wl.Shm
outputs map[uint32]*wl.Output
outputGeometries map[*wl.Output]outputInfo
locker *WaylandLocker
}

// Media file extension maps
Expand All @@ -209,29 +208,57 @@ type handlerFunc func(wl.OutputGeometryEvent)
// outputModeHandlerFunc is a function type for handling output mode events
type outputModeHandlerFunc func(ev wl.OutputModeEvent)

// WaylandLocker represents a Wayland-based screen locker
type WaylandLocker struct {
// Wayland connection and display
display *wl.Display
registry *wl.Registry
registryHandler *RegistryHandler
compositor *wl.Compositor
lockManager *ext.SessionLockManager
lock *ext.SessionLock
keyboard *wl.Keyboard
seat *wl.Seat
shm *wl.Shm
securePassword *SecurePassword
surfaces map[*wl.Output]struct {
seat *wl.Seat
keyboard *wl.Keyboard
pointer *wl.Pointer
output *wl.Output
lock *ext.SessionLock
lockSurface *wl.Surface
lockManager *ext.SessionLockManager

// Session lock surfaces
surfaces map[*wl.Output]struct {
wlSurface *wl.Surface
lockSurface *ext.SessionLockSurface
}
redrawCh chan int
outputs map[uint32]*wl.Output
mediaPlayer *MediaPlayer
outputs map[uint32]*wl.Output

// State
mu sync.Mutex
done chan struct{}
config Configuration
helper *LockHelper
lockActive bool
redrawCh chan int
securePassword *SecurePassword
countdownActive bool
lockoutManager *LockoutManager // Use the shared lockout manager
mu sync.Mutex
countdownTimer *time.Timer
lockActive bool
mediaPlayer *MediaPlayer
lockoutManager *LockoutManager

// Keymap data
keymapData []byte
keymapFormat uint32
keymapSize uint32
xkbContext uintptr
xkbState uintptr
xkbKeymap uintptr

// Configuration
config Configuration
helper *LockHelper
}

// updatePasswordDisplay updates the password display
func (l *WaylandLocker) updatePasswordDisplay() {
select {
case l.redrawCh <- l.securePassword.Length():
default:
}
}
Loading