Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.

Commit e7f5d76

Browse files
tuxxTuxx
andauthored
Feature/keyhandling (#5)
* Better keyboard handling for wayland * Handle modifiers keys like Shift & Alt * Removed debug line for printing password characters to log Fixes: #4 --------- Co-authored-by: Tuxx <[email protected]>
1 parent 7ce492a commit e7f5d76

File tree

5 files changed

+336
-85
lines changed

5 files changed

+336
-85
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
)
1414

1515
require (
16+
github.com/ebitengine/purego v0.8.2 // indirect
1617
github.com/yalue/native_endian v1.0.2 // indirect
1718
golang.org/x/text v0.23.0 // indirect
1819
)

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc h1:7D+Bh06CRPCJO3gr2F7h1sriovOZ8BMhca2Rg85c2nk=
22
github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
3+
github.com/ebitengine/purego v0.7.1 h1:6/55d26lG3o9VCZX8lping+bZcmShseiqlh2bnUDiPA=
4+
github.com/ebitengine/purego v0.7.1/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
5+
github.com/ebitengine/purego v0.8.2 h1:jPPGWs2sZ1UgOSgD2bClL0MJIqu58nOmIcBuXr62z1I=
6+
github.com/ebitengine/purego v0.8.2/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
37
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
48
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
59
github.com/msteinert/pam v1.2.0 h1:mYfjlvN2KYs2Pb9G6nb/1f/nPfAttT/Jee5Sq9r3bGE=

internal/types.go

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package internal
33
import (
44
"os/exec"
55
"sync"
6+
"time"
67

78
"github.com/BurntSushi/xgb"
89
"github.com/BurntSushi/xgb/xproto"
@@ -179,16 +180,14 @@ type outputInfo struct {
179180

180181
// RegistryHandler handles Wayland registry events
181182
type RegistryHandler struct {
182-
wl.OutputGeometryHandler
183-
wl.OutputModeHandler
184-
185183
registry *wl.Registry
186184
compositor *wl.Compositor
187185
lockManager *ext.SessionLockManager
188186
seat *wl.Seat
189187
shm *wl.Shm
190188
outputs map[uint32]*wl.Output
191189
outputGeometries map[*wl.Output]outputInfo
190+
locker *WaylandLocker
192191
}
193192

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

211+
// WaylandLocker represents a Wayland-based screen locker
212212
type WaylandLocker struct {
213+
// Wayland connection and display
213214
display *wl.Display
214215
registry *wl.Registry
215216
registryHandler *RegistryHandler
216217
compositor *wl.Compositor
217-
lockManager *ext.SessionLockManager
218-
lock *ext.SessionLock
219-
keyboard *wl.Keyboard
220-
seat *wl.Seat
221218
shm *wl.Shm
222-
securePassword *SecurePassword
223-
surfaces map[*wl.Output]struct {
219+
seat *wl.Seat
220+
keyboard *wl.Keyboard
221+
pointer *wl.Pointer
222+
output *wl.Output
223+
lock *ext.SessionLock
224+
lockSurface *wl.Surface
225+
lockManager *ext.SessionLockManager
226+
227+
// Session lock surfaces
228+
surfaces map[*wl.Output]struct {
224229
wlSurface *wl.Surface
225230
lockSurface *ext.SessionLockSurface
226231
}
227-
redrawCh chan int
228-
outputs map[uint32]*wl.Output
229-
mediaPlayer *MediaPlayer
232+
outputs map[uint32]*wl.Output
233+
234+
// State
235+
mu sync.Mutex
230236
done chan struct{}
231-
config Configuration
232-
helper *LockHelper
233-
lockActive bool
237+
redrawCh chan int
238+
securePassword *SecurePassword
234239
countdownActive bool
235-
lockoutManager *LockoutManager // Use the shared lockout manager
236-
mu sync.Mutex
240+
countdownTimer *time.Timer
241+
lockActive bool
242+
mediaPlayer *MediaPlayer
243+
lockoutManager *LockoutManager
244+
245+
// Keymap data
246+
keymapData []byte
247+
keymapFormat uint32
248+
keymapSize uint32
249+
xkbContext uintptr
250+
xkbState uintptr
251+
xkbKeymap uintptr
252+
253+
// Configuration
254+
config Configuration
255+
helper *LockHelper
256+
}
257+
258+
// updatePasswordDisplay updates the password display
259+
func (l *WaylandLocker) updatePasswordDisplay() {
260+
select {
261+
case l.redrawCh <- l.securePassword.Length():
262+
default:
263+
}
237264
}

0 commit comments

Comments
 (0)