-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add client output wrapper as a proof-of-concept for global enumeration
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
module Quasar.Wayland.Client.Output ( | ||
Output(..), | ||
getOutputs, | ||
) where | ||
|
||
import Quasar.Observable.Core | ||
import Quasar.Observable.List (ObservableList) | ||
import Quasar.Observable.List qualified as ObservableList | ||
import Quasar.Observable.ObservableVar | ||
import Quasar.Prelude | ||
import Quasar.Wayland.Client | ||
import Quasar.Wayland.Client.Registry | ||
import Quasar.Wayland.Protocol | ||
import Quasar.Wayland.Protocol.Generated | ||
|
||
data Output = Output { | ||
wlOutput :: Object 'Client Interface_wl_output, | ||
name :: Observable NoLoad '[] String, | ||
description :: Observable NoLoad '[] String | ||
} | ||
|
||
getOutputs :: WaylandClient -> STMc NoRetry '[] (ObservableList NoLoad '[] Output) | ||
getOutputs client = getClientComponent (newOutputList client) client | ||
|
||
newOutputList :: WaylandClient -> STMc NoRetry '[] (ObservableList NoLoad '[] Output) | ||
newOutputList client = ObservableList.cache (traverseGlobals client.registry 4 initializeOutput finalizeOutput) | ||
|
||
initializeOutput :: | ||
NewObject 'Client Interface_wl_output -> | ||
STMc NoRetry '[] Output | ||
initializeOutput wlOutput = do | ||
-- TODO abort if version == 1, mode handling is broken | ||
|
||
nameVar <- newObservableVar "" | ||
descriptionVar <- newObservableVar "" | ||
|
||
setEventHandler wlOutput EventHandler_wl_output { | ||
geometry = \_x _y _physical_width _physical_height _subpixel _make _model _transform -> pure (), | ||
mode = \_flags _width _height _refresh -> pure (), | ||
done = pure (), | ||
scale = \_factor -> pure (), | ||
name = \name -> writeObservableVar nameVar (toString name), | ||
description = \description -> writeObservableVar nameVar (toString description) | ||
} | ||
|
||
pure Output { | ||
wlOutput, | ||
name = toObservable nameVar, | ||
description = toObservable descriptionVar | ||
} | ||
|
||
finalizeOutput :: Output -> STMc NoRetry '[] () | ||
finalizeOutput output = tryCall output.wlOutput.release |