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
fc07fe9e
Commit
fc07fe9e
authored
2 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Fix warnings
parent
ba39db41
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Quasar/Wayland/Connection.hs
+8
-11
8 additions, 11 deletions
src/Quasar/Wayland/Connection.hs
src/Quasar/Wayland/Protocol/Core.hs
+3
-4
3 additions, 4 deletions
src/Quasar/Wayland/Protocol/Core.hs
src/Quasar/Wayland/Protocol/TH.hs
+3
-3
3 additions, 3 deletions
src/Quasar/Wayland/Protocol/TH.hs
with
14 additions
and
18 deletions
src/Quasar/Wayland/Connection.hs
+
8
−
11
View file @
fc07fe9e
...
...
@@ -9,15 +9,11 @@ module Quasar.Wayland.Connection (
import
Control.Monad.Catch
import
Data.Bits
((
.&.
))
import
Data.ByteString
qualified
as
BS
import
Data.ByteString.Internal
(
createUptoN
)
import
Data.ByteString.Lazy
qualified
as
BSL
import
Foreign.Storable
(
sizeOf
)
import
Language.C.Inline
qualified
as
C
import
Language.C.Inline.Unsafe
qualified
as
CU
import
Network.Socket
(
Socket
)
import
Network.Socket
qualified
as
Socket
import
Network.Socket.ByteString
qualified
as
Socket
import
Network.Socket.ByteString.Lazy
qualified
as
SocketL
import
Quasar
import
Quasar.Prelude
import
Quasar.Wayland.Protocol
...
...
@@ -69,7 +65,7 @@ newWaylandConnection initializeProtocolAction socket = do
t1
<-
connectionThread
connection
$
sendThread
connection
t2
<-
connectionThread
connection
$
receiveThread
connection
registerDisposeActionIO
do
registerDisposeActionIO
_
do
await
$
isDisposed
t1
await
$
isDisposed
t2
closeConnection
connection
...
...
@@ -77,10 +73,11 @@ newWaylandConnection initializeProtocolAction socket = do
pure
(
result
,
connection
)
connectionThread
::
(
MonadIO
m
,
MonadQuasar
m
)
=>
WaylandConnection
s
->
IO
()
->
m
(
Async
()
)
connectionThread
connection
work
=
asyncWithUnmask'
\
unmask
->
work
`
catch
`
traceAndDisposeConnection
connectionThread
connection
work
=
asyncWithUnmask'
\
unmask
->
unmask
work
`
catch
`
traceAndDisposeConnection
where
traceAndDisposeConnection
::
SomeException
->
IO
()
traceAndDisposeConnection
(
isCancelAsync
->
True
)
=
pure
()
-- TODO this logs- and then discard exceptions. Ensure this is the desired behavior?
traceAndDisposeConnection
ex
=
traceIO
(
displayException
ex
)
>>
disposeEventuallyIO_
connection
sendThread
::
WaylandConnection
s
->
IO
()
...
...
@@ -102,14 +99,14 @@ sendThread connection = mask_ $ forever do
sent
<-
sendMsg
connection
.
socket
chunks
(
Socket
.
encodeCmsg
<$>
fds
)
mempty
let
nowRemaining
=
remaining
-
sent
when
(
nowRemaining
>
0
)
do
send
nowRemaining
(
drop
sent
chunks
)
[]
send
nowRemaining
(
drop
L
sent
chunks
)
[]
drop
::
Int
->
[
BS
.
ByteString
]
->
[
BS
.
ByteString
]
drop
_
[]
=
[]
drop
amount
(
chunk
:
chunks
)
=
drop
L
::
Int
->
[
BS
.
ByteString
]
->
[
BS
.
ByteString
]
drop
L
_
[]
=
[]
drop
L
amount
(
chunk
:
chunks
)
=
if
(
amount
<
BS
.
length
chunk
)
then
(
BS
.
drop
amount
chunk
:
chunks
)
else
drop
(
amount
-
BS
.
length
chunk
)
chunks
else
drop
L
(
amount
-
BS
.
length
chunk
)
chunks
receiveThread
::
IsSide
s
=>
WaylandConnection
s
->
IO
()
...
...
This diff is collapsed.
Click to expand it.
src/Quasar/Wayland/Protocol/Core.hs
+
3
−
4
View file @
fc07fe9e
...
...
@@ -612,7 +612,7 @@ bindNewObject protocol version messageHandler = runProtocolM protocol do
fromSomeObject
::
forall
s
i
m
.
IsInterfaceSide
s
i
::
forall
s
i
.
IsInterfaceSide
s
i
=>
SomeObject
s
->
Either
String
(
Object
s
i
)
fromSomeObject
(
SomeObject
someObject
)
=
case
cast
someObject
of
...
...
@@ -657,13 +657,13 @@ getNullableObject oId = Just <$> getObject oId
-- | Handle a wl_display.error message. Because this is part of the core protocol but generated from the xml it has to
-- be called from the client module.
handleWlDisplayError
::
ProtocolHandle
'Client
->
GenericObjectId
->
Word32
->
WlString
->
STM
()
handleWlDisplayError
_protocol
oId
code
message
=
throwM
$
ServerError
code
(
toString
message
)
handleWlDisplayError
_protocol
_
oId
code
message
=
throwM
$
ServerError
code
(
toString
message
)
-- | Handle a wl_display.delete_id message. Because this is part of the core protocol but generated from the xml it has
-- to be called from the client module.
handleWlDisplayDeleteId
::
ProtocolHandle
'Client
->
Word32
->
STM
()
handleWlDisplayDeleteId
protocol
oId
=
runProtocolM
protocol
do
-- TODO
call destructor
-- TODO
mark as deleted
modifyProtocolVar
(
.
objectsVar
)
$
HM
.
delete
(
GenericObjectId
oId
)
...
...
@@ -711,7 +711,6 @@ sendMessage object message = do
traceM
$
"-> "
<>
showObjectMessage
object
message
sendRawMessage
(
putHeader
opcode
(
8
+
bodyLength
)
>>
putBody
)
fds
where
oId
=
genericObjectId
object
(
GenericObjectId
objectIdWord
)
=
genericObjectId
object
putHeader
::
Opcode
->
Int
->
Put
putHeader
opcode
msgSize
=
do
...
...
This diff is collapsed.
Click to expand it.
src/Quasar/Wayland/Protocol/TH.hs
+
3
−
3
View file @
fc07fe9e
...
...
@@ -122,7 +122,7 @@ generateWaylandProcol protocolFile = do
generateWaylandProcols
::
[
FilePath
]
->
Q
[
Dec
]
generateWaylandProcols
protocolFiles
=
do
mapM
addDependentFile
protocolFiles
mapM
_
addDependentFile
protocolFiles
xmls
<-
mapM
(
liftIO
.
BS
.
readFile
)
protocolFiles
protocol
<-
mconcat
<$>
mapM
parseProtocol
xmls
(
public
,
internals
)
<-
unzip
<$>
mapM
interfaceDecs
protocol
.
interfaces
...
...
@@ -603,8 +603,8 @@ parseEvent :: MonadFail m => String -> (Opcode, Element) -> m EventSpec
parseEvent
x
y
=
EventSpec
<$>
parseMessage
False
x
y
parseMessage
::
MonadFail
m
=>
Bool
->
String
->
(
Opcode
,
Element
)
->
m
MessageSpec
parseMessage
isRequest
interface
(
opcode
,
element
)
=
do
let
isEvent
=
not
isRequest
parseMessage
_
isRequest
interface
(
opcode
,
element
)
=
do
--
let isEvent = not isRequest
name
<-
getAttr
"name"
element
...
...
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