change window title on function flip
This commit is contained in:
parent
0a731e2100
commit
5b398dea23
3 changed files with 18 additions and 6 deletions
|
@ -2,6 +2,8 @@ module Events where
|
|||
|
||||
import qualified SDL
|
||||
|
||||
import qualified Data.Text as T
|
||||
|
||||
import Linear
|
||||
|
||||
import Control.Concurrent.MVar
|
||||
|
@ -31,12 +33,20 @@ handlePayload run state (SDL.KeyboardEvent (SDL.KeyboardEventData _ SDL.Pressed
|
|||
return ()
|
||||
| SDL.keysymKeycode sym == SDL.KeycodeF12 || SDL.keysymKeycode sym == SDL.KeycodeF =
|
||||
modifyMVar_ state $ \st -> do
|
||||
return st
|
||||
{ stPresentationWindow =
|
||||
if length (stWindows st) > 1 && stPresentationWindow st == 0
|
||||
then 1
|
||||
else 0
|
||||
}
|
||||
let st2 = st
|
||||
{ stPresentationWindow =
|
||||
if length (stWindows st) > 1 && stPresentationWindow st == 0
|
||||
then 1
|
||||
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
|
||||
handlePayload _ _ _ = return ()
|
||||
|
|
|
@ -102,6 +102,7 @@ main = do
|
|||
state <- newMVar (
|
||||
State
|
||||
1
|
||||
(optFile opts)
|
||||
(last $ map fst wins)
|
||||
time
|
||||
wins
|
||||
|
|
|
@ -20,6 +20,7 @@ data Options = Options
|
|||
|
||||
data State = State
|
||||
{ stCurrentPage :: Word
|
||||
, stFilename :: T.Text
|
||||
, stPresentationWindow :: Word
|
||||
, stStartTime :: UTCTime
|
||||
, stWindows :: [(Word, SDL.Window)]
|
||||
|
|
Loading…
Reference in a new issue