diff options
| author | Hannes Schulze <contact@haschu.me> | 2026-04-10 17:36:15 +0200 |
|---|---|---|
| committer | Hannes Schulze <contact@haschu.me> | 2026-04-10 17:36:15 +0200 |
| commit | dab858e92dfa5705d1aef7259e03b25747372d95 (patch) | |
| tree | a08fa2d015adda6a718b4abc5ece2648a6247735 /src/Waylean.lean | |
| parent | bfe6c4cee8b5afcd4078af319ab6b96f6695408b (diff) | |
implement registry wrapper
Diffstat (limited to 'src/Waylean.lean')
| -rw-r--r-- | src/Waylean.lean | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/Waylean.lean b/src/Waylean.lean index 953096a..47f9db9 100644 --- a/src/Waylean.lean +++ b/src/Waylean.lean @@ -1,29 +1,22 @@ import Wayland +import Waylean.Registry -open Wayland Protocols +open Wayland Protocols Waylean structure State where - shmName : Option UInt32 := .none + registry : Registry.State := .new -def requireGlobal (name : String) : Option UInt32 → DisplayM State UInt32 - | .some global => pure global - | .none => DisplayM.liftIO <| throw (.userError s!"Missing required global {name}") +def zoomRegistry {α : Type} : DisplayM Registry.State α → DisplayM State α := + DisplayM.zoom (mk_lens registry) def launch : DisplayM State Unit := do _ ← DisplayM.registerSignal .SIGINT do DisplayM.liftIO (IO.println "Received SIGINT") DisplayM.requestQuit - let disp ← DisplayM.getDisplay - let registry ← disp.getRegistry - registry.listen fun - | .global name "wl_shm" _ => do - DisplayM.liftIO (IO.println s!"shm global registerd ({name})") - set ({ shmName := name } : State) - | _ => pure () - disp.sync do - DisplayM.liftIO (IO.println "Roundtrip complete") - let shmName ← (← get).shmName |> requireGlobal "wl_shm" - let shm : WlShm ← registry.bind shmName + + zoomRegistry Registry.init + DisplayM.sync do + let shm : WlShm ← zoomRegistry Registry.bindSingleton shm.release def main : IO Unit := |
