change window title on function flip

This commit is contained in:
nek0 2019-02-04 20:33:45 +01:00
parent 0a731e2100
commit 5b398dea23
3 changed files with 18 additions and 6 deletions

View file

@ -2,6 +2,8 @@ module Events where
import qualified SDL import qualified SDL
import qualified Data.Text as T
import Linear import Linear
import Control.Concurrent.MVar import Control.Concurrent.MVar
@ -31,12 +33,20 @@ handlePayload run state (SDL.KeyboardEvent (SDL.KeyboardEventData _ SDL.Pressed
return () return ()
| SDL.keysymKeycode sym == SDL.KeycodeF12 || SDL.keysymKeycode sym == SDL.KeycodeF = | SDL.keysymKeycode sym == SDL.KeycodeF12 || SDL.keysymKeycode sym == SDL.KeycodeF =
modifyMVar_ state $ \st -> do modifyMVar_ state $ \st -> do
return st let st2 = st
{ stPresentationWindow = { stPresentationWindow =
if length (stWindows st) > 1 && stPresentationWindow st == 0 if length (stWindows st) > 1 && stPresentationWindow st == 0
then 1 then 1
else 0 else 0
} }
mapM_ (\(ident, win) -> do
let title = "Ibis - " `T.append` stFilename st2
if ident == stPresentationWindow st2
then SDL.windowTitle win SDL.$= title
else SDL.windowTitle win SDL.$= title `T.append` " - Notes"
)
(stWindows st2)
return st2
-- catch all other events -- catch all other events
handlePayload _ _ _ = return () handlePayload _ _ _ = return ()

View file

@ -102,6 +102,7 @@ main = do
state <- newMVar ( state <- newMVar (
State State
1 1
(optFile opts)
(last $ map fst wins) (last $ map fst wins)
time time
wins wins

View file

@ -20,6 +20,7 @@ data Options = Options
data State = State data State = State
{ stCurrentPage :: Word { stCurrentPage :: Word
, stFilename :: T.Text
, stPresentationWindow :: Word , stPresentationWindow :: Word
, stStartTime :: UTCTime , stStartTime :: UTCTime
, stWindows :: [(Word, SDL.Window)] , stWindows :: [(Word, SDL.Window)]