diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2024-08-05 19:07:12 +0200 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2024-08-05 19:07:12 +0200 |
| commit | 476ab3f025160b14bb2cd69969bda61b555f1a44 (patch) | |
| tree | 83f07898ce3403f36297ab16e55c8c2aa2382a56 /highway | |
| parent | 3657bbecc8c8ead40831d39b4b7069e3a4d9dcc9 (diff) | |
dispatch events
Diffstat (limited to 'highway')
| -rw-r--r-- | highway/Main.hs | 13 |
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 |
