Skip to content

Commit

Permalink
Add proxy example
Browse files Browse the repository at this point in the history
  • Loading branch information
queezle42 committed May 15, 2024
1 parent 4bdaa9a commit 8642e32
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
58 changes: 58 additions & 0 deletions examples/Proxy.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module Main (main) where

import Control.Concurrent
import Quasar
import Quasar.Prelude
import Quasar.Wayland.Client
import Quasar.Wayland.Client.XdgShell
import Quasar.Wayland.Server
import Quasar.Wayland.Server.DummyOutput
import Quasar.Wayland.Server.Registry
import Quasar.Wayland.Server.XdgShell
import Quasar.Wayland.Shared.FnWindowManager
import Quasar.Wayland.Shared.WindowApi (WindowProperties(..), toWindowFactory)
import Quasar.Wayland.Shared.WindowMultiplexer
import Quasar.Wayland.Skia
import Quasar.Wayland.Skia.GL

main :: IO ()
main = runQuasarAndExit do
client <- connectWaylandClient
traceIO "Connected"

quasar <- askQuasar
liftIO $ runInBoundThread do

skia <- liftIO $ initializeSkia @GL

--clientDmabuf <- atomically $ getClientDmabufSingleton client
--(dmabufFormats, dmabufModifiers) <- awaitSupportedFormats clientDmabuf

wlClientWM <- atomicallyC $ getClientWindowManager @(Skia GL) client

let muxWM = WindowMultiplexerFactory [toWindowFactory (mapWindowManager wlClientWM), toWindowFactory wlClientWM]

registry <- newRegistry [
compositorGlobal @(Skia GL),
subcompositorGlobal @(Skia GL),
dummyOutputGlobal,
xdgShellGlobal muxWM,
skiaDmabufGlobal skia
]
server <- newWaylandServer registry
runQuasarIO quasar do
listenAt "example.socket" server

sleepForever

mapWindowManager :: IsWindowManager (Skia GL) w a => a -> FnWindowManager (Skia GL)
mapWindowManager upstream = fnWindowManager {
newWindowFn = \props cfg req -> fnWindowManager.newWindowFn (mapProperties props) cfg req
}
where
fnWindowManager = toFnWindowManager upstream

mapProperties :: WindowProperties -> WindowProperties
mapProperties properties = properties {
title = properties.title <> " (proxy)"
}
10 changes: 10 additions & 0 deletions examples/quasar-wayland-examples.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,13 @@ executable example-client
quasar-wayland,
quasar-wayland-skia,
main-is: Client.hs

executable example-proxy
import: shared-executable-properties
build-depends:
base,
quasar,
quasar-timer,
quasar-wayland,
quasar-wayland-skia,
main-is: Proxy.hs

0 comments on commit 8642e32

Please sign in to comment.