summaryrefslogtreecommitdiff
path: root/highway/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'highway/Main.hs')
-rw-r--r--highway/Main.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/highway/Main.hs b/highway/Main.hs
index 191279a..617a0ee 100644
--- a/highway/Main.hs
+++ b/highway/Main.hs
@@ -21,7 +21,8 @@ geometry = WLOutput.Geometry { WLOutput.x = 0
}
data BindRequest
- = BindOutput WLOutput.Handle
+ = BindOutput WLOutput.Handle
+ | UnbindOutput WLOutput.Handle
deriving (Typeable, Show)
data SignalRequest
@@ -43,13 +44,13 @@ makeLenses ''State
handleRequest :: Request -> DisplayM State ()
handleRequest r
- | Just (WLOutput.ReqRelease o) <- fromRequest r = do outputs %= M.delete o
- destroyResource o
- | Just (BindOutput o) <- fromRequest r = do outputs %= M.insert o Output
+ | Just (WLOutput.ReqRelease o) <- fromRequest r = destroyResource o
+ | Just (BindOutput o) <- fromRequest r = do outs <- outputs <%= M.insert o Output
sendEvent o $ WLOutput.EvGeometry geometry
sendEvent o $ WLOutput.EvDone
- liftIO $ putStrLn $ "Created output " ++ show o
+ liftIO $ putStrLn $ "Created output, outputs: " ++ show outs
flushEvents
+ | Just (UnbindOutput o) <- fromRequest r = outputs %= M.delete o
| Just ReqSIGINT <- fromRequest r = do c <- interruptedCount <%= (+1)
liftIO $ putStrLn $ "Received SIGINT " ++ show c ++ "/3"
when (c >= 3) requestTermination
@@ -60,6 +61,6 @@ main = void $ withDisplay (State M.empty 0) $ do
socket <- bindSocket
liftIO $ putStrLn $ "Listening on socket: " ++ socket
registerSignalEvent ReqSIGINT 2
- output <- registerGlobal BindOutput 4
+ output <- registerGlobal BindOutput UnbindOutput 4
processRequests handleRequest
unregisterGlobal output