Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quasar-wayland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Nolte
quasar-wayland
Commits
c1b6b413
Commit
c1b6b413
authored
2 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Implement server registry
parent
9b8e6ec9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Quasar/Wayland/Protocol/Core.hs
+17
-3
17 additions, 3 deletions
src/Quasar/Wayland/Protocol/Core.hs
src/Quasar/Wayland/Server/Registry.hs
+42
-7
42 additions, 7 deletions
src/Quasar/Wayland/Server/Registry.hs
with
59 additions
and
10 deletions
src/Quasar/Wayland/Protocol/Core.hs
+
17
−
3
View file @
c1b6b413
...
...
@@ -47,6 +47,7 @@ module Quasar.Wayland.Protocol.Core (
newObject
,
newObjectFromId
,
bindNewObject
,
bindObjectFromId
,
getObject
,
getNullableObject
,
lookupObject
,
...
...
@@ -641,9 +642,22 @@ bindNewObject
->
Version
->
Maybe
(
MessageHandler
'Client
i
)
->
STM
(
Object
'Client
i
,
GenericNewId
)
bindNewObject
protocol
version
messageHandler
=
runProtocolM
protocol
do
(
object
,
NewId
(
ObjectId
newId
))
<-
newObject
messageHandler
pure
(
object
,
GenericNewId
(
interfaceName
@
i
)
version
newId
)
bindNewObject
protocol
version
messageHandler
=
runProtocolM
protocol
do
(
object
,
NewId
(
ObjectId
newId
))
<-
newObject
messageHandler
pure
(
object
,
GenericNewId
(
interfaceName
@
i
)
version
newId
)
-- | Create an object from a received id.
-- object).
--
-- For implementing wl_registry.bind (which is low-level protocol functionality, but which depends on generated code).
bindObjectFromId
::
forall
i
.
IsInterfaceSide
'Server
i
=>
Maybe
(
MessageHandler
'Server
i
)
->
GenericNewId
->
ProtocolM
'Server
(
Object
'Server
i
)
bindObjectFromId
messageHandler
(
GenericNewId
interface
version
value
)
=
newObjectFromId
messageHandler
(
NewId
(
ObjectId
value
))
fromSomeObject
...
...
This diff is collapsed.
Click to expand it.
src/Quasar/Wayland/Server/Registry.hs
+
42
−
7
View file @
c1b6b413
module
Quasar.Wayland.Server.Registry
(
Registry
,
Global
,
newRegistry
,
addRegistryConnection
,
createGlobal
,
maxVersion
,
)
where
import
Data.Foldable
(
toList
)
import
Data.HashMap.Strict
qualified
as
HM
import
Data.Sequence
(
Seq
)
import
Data.Sequence
qualified
as
Seq
import
Quasar.Prelude
import
Quasar.Wayland.Protocol
import
Quasar.Wayland.Protocol.Core
import
Quasar.Wayland.Protocol.Generated
-- TODO: send registry messages
-- TODO: remove
c
onnection when registry is destroyed
-- TODO: remove
RegistryC
onnection when registry
protocol connection
is destroyed
data
Registry
=
Registry
{
connections
::
TVar
[
RegistryConnection
],
singletons
::
Seq
Global
,
globalsVar
::
TVar
(
HM
.
HashMap
Word32
Global
)
}
newRegistry
::
MonadIO
m
=>
m
Registry
newRegistry
=
do
newRegistry
::
MonadIO
m
=>
[
Global
]
->
m
Registry
newRegistry
singletons
=
do
connections
<-
newTVarIO
mempty
globalsVar
<-
newTVarIO
mempty
pure
Registry
{
connections
,
globalsVar
}
pure
Registry
{
connections
,
singletons
=
Seq
.
fromList
singletons
,
globalsVar
}
data
RegistryConnection
=
RegistryConnection
{
registry
::
Registry
,
wlRegistry
::
Object
'Server
Interface_wl_registry
}
createGlobal
::
forall
i
.
IsInterfaceSide
'Server
i
=>
Version
->
(
Object
'Server
i
->
STM
()
)
->
Global
createGlobal
supportedVersion
bindFn
=
Global
{
interface
=
interfaceName
@
i
,
version
=
min
supportedVersion
(
interfaceVersion
@
i
),
bindObject
}
where
bindObject
::
GenericNewId
->
ProtocolM
'Server
()
bindObject
newId
=
do
object
<-
bindObjectFromId
Nothing
newId
liftSTM
$
bindFn
object
addRegistryConnection
::
Registry
->
Object
'Server
Interface_wl_registry
->
STM
()
addRegistryConnection
registry
wlRegistry
=
do
setMessageHandler
wlRegistry
messageHandler
modifyTVar
registry
.
connections
(
connection
:
)
forM_
(
zip
[
0
..
]
(
toList
registry
.
singletons
))
(
sendGlobal
wlRegistry
)
where
connection
=
RegistryConnection
{
registry
,
wlRegistry
}
messageHandler
::
RequestHandler_wl_registry
messageHandler
=
RequestHandler_wl_registry
{
bind
=
\
name
id
->
traceM
"wl_registry.bind not implemented"
bind
=
bindHandler
registry
(
objectProtocol
wlRegistry
)
}
sendGlobal
::
Object
'Server
Interface_wl_registry
->
(
Word32
,
Global
)
->
STM
()
sendGlobal
wlRegistry
(
name
,
global
)
=
wlRegistry
.
global
name
global
.
interface
global
.
version
bindHandler
::
Registry
->
ProtocolHandle
'Server
->
Word32
->
GenericNewId
->
STM
()
bindHandler
registry
protocolHandle
name
newId
=
do
case
Seq
.
lookup
(
fromIntegral
name
)
registry
.
singletons
of
Just
global
->
runProtocolM
protocolHandle
(
global
.
bindObject
newId
)
Nothing
->
traceM
$
"Invalid global "
<>
show
name
-- TODO dynamic globals
data
Global
=
Global
{
name
::
Word32
,
interface
::
WlString
,
version
::
Word32
version
::
Word32
,
bindObject
::
GenericNewId
->
ProtocolM
'Server
()
}
maxVersion
::
Version
maxVersion
=
maxBound
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment