summaryrefslogtreecommitdiffstats
path: root/lib/Phi/X11.hs
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-07-14 06:16:04 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-07-14 06:16:04 +0200
commite4314c03faa77d71ad69ec37b83e2634e1a2a9c9 (patch)
tree8978ab9aca61cc8160156404168322113a24dadd /lib/Phi/X11.hs
parentd519f6781677aae2217aa895b25cbff61e1d0dbb (diff)
downloadphi-e4314c03faa77d71ad69ec37b83e2634e1a2a9c9.tar
phi-e4314c03faa77d71ad69ec37b83e2634e1a2a9c9.zip
Some more restructuring, WIP
Diffstat (limited to 'lib/Phi/X11.hs')
-rw-r--r--lib/Phi/X11.hs39
1 files changed, 20 insertions, 19 deletions
diff --git a/lib/Phi/X11.hs b/lib/Phi/X11.hs
index b79001c..548027c 100644
--- a/lib/Phi/X11.hs
+++ b/lib/Phi/X11.hs
@@ -2,7 +2,7 @@
module Phi.X11 ( XConfig(..)
, defaultXConfig
- , initPhi
+ , initPhiX
) where
import Graphics.X11.Xlib
@@ -20,6 +20,7 @@ import Control.Monad.State
import Control.Monad.Reader
import Control.Monad.Trans
+import Phi.Phi
import qualified Phi.Types as Phi
import qualified Phi.Panel as Panel
import qualified Phi.Widget as Widget
@@ -54,17 +55,17 @@ newtype PhiReader a = PhiReader (ReaderT PhiConfig IO a)
runPhiReader :: PhiConfig -> PhiReader a -> IO a
runPhiReader config (PhiReader a) = runReaderT a config
-newtype Phi a = Phi (StateT PhiState PhiReader a)
- deriving (Monad, MonadState PhiState, MonadReader PhiConfig, MonadIO)
+newtype PhiX a = PhiX (StateT PhiState PhiReader a)
+ deriving (Monad, MonadState PhiState, MonadReader PhiConfig, MonadIO)
-runPhi :: PhiConfig -> PhiState -> Phi a -> IO (a, PhiState)
-runPhi config st (Phi a) = runPhiReader config $ runStateT a st
+runPhiX :: PhiConfig -> PhiState -> PhiX a -> IO (a, PhiState)
+runPhiX config st (PhiX a) = runPhiReader config $ runStateT a st
-liftIOContToPhi :: ((a -> IO (b, PhiState)) -> IO (b, PhiState)) -> (a -> Phi b) -> Phi b
-liftIOContToPhi f c = do
+liftIOContToPhiX :: ((a -> IO (b, PhiState)) -> IO (b, PhiState)) -> (a -> PhiX b) -> PhiX b
+liftIOContToPhiX f c = do
config <- ask
state <- get
- (a, state') <- liftIO $ f $ runPhi config state . c
+ (a, state') <- liftIO $ f $ runPhiX config state . c
put state'
return a
@@ -73,13 +74,13 @@ defaultXConfig = XConfig { phiXScreenInfo = getScreenInfo
}
-initPhi :: XConfig -> Panel.PanelConfig -> [Widget.Widget] -> IO ()
-initPhi xconfig config widgets = do
+initPhiX :: Phi -> XConfig -> Panel.PanelConfig -> [Widget.Widget] -> IO ()
+initPhiX phi xconfig config widgets = do
disp <- openDisplay []
atoms <- initAtoms disp
selectInput disp (defaultRootWindow disp) $ propertyChangeMask.|.structureNotifyMask
- runPhi PhiConfig { phiXConfig = xconfig, phiPanelConfig = config, phiDisplay = disp, phiAtoms = atoms } PhiState { phiRootPixmap = 0, phiPanels = [] } $ do
+ runPhiX PhiConfig { phiXConfig = xconfig, phiPanelConfig = config, phiDisplay = disp, phiAtoms = atoms } PhiState { phiRootPixmap = 0, phiPanels = [] } $ do
updateRootPixmap
screens <- liftIO $ phiXScreenInfo xconfig disp
@@ -92,7 +93,7 @@ initPhi xconfig config widgets = do
updatePanels True
- liftIOContToPhi allocaXEvent $ \xevent -> do
+ liftIOContToPhiX allocaXEvent $ \xevent -> do
forever $ do
liftIO $ nextEvent disp xevent
event <- liftIO $ getEvent xevent
@@ -104,7 +105,7 @@ initPhi xconfig config widgets = do
return ()
-updatePanels :: Bool -> Phi ()
+updatePanels :: Bool -> PhiX ()
updatePanels redraw = do
disp <- asks phiDisplay
@@ -134,7 +135,7 @@ updatePanels redraw = do
modify $ \state -> state { phiPanels = panels' }
-handlePropertyUpdate :: Event -> Phi ()
+handlePropertyUpdate :: Event -> PhiX ()
handlePropertyUpdate PropertyEvent { ev_atom = atom } = do
atoms <- asks phiAtoms
panels <- gets phiPanels
@@ -144,7 +145,7 @@ handlePropertyUpdate PropertyEvent { ev_atom = atom } = do
updatePanels True
-updateRootPixmap :: Phi ()
+updateRootPixmap :: PhiX ()
updateRootPixmap = do
disp <- asks phiDisplay
atoms <- asks phiAtoms
@@ -155,7 +156,7 @@ updateRootPixmap = do
modify $ \state -> state { phiRootPixmap = pixmap }
-createPanel :: [Widget.Widget] -> Rectangle -> Phi PanelState
+createPanel :: [Widget.Widget] -> Rectangle -> PhiX PanelState
createPanel widgets screenRect = do
config <- asks phiPanelConfig
disp <- asks phiDisplay
@@ -173,7 +174,7 @@ createPanel widgets screenRect = do
return PanelState { panelWindow = win, panelGC = gc, panelPixmap = pixmap, panelSurface = surface, panelArea = rect, panelScreenArea = screenRect, panelWidgetStates = map Widget.createWidgetState widgets }
-createPanelWindow :: Rectangle -> Phi Window
+createPanelWindow :: Rectangle -> PhiX Window
createPanelWindow rect = do
disp <- asks phiDisplay
let screen = defaultScreen disp
@@ -191,7 +192,7 @@ createPanelWindow rect = do
withRectangle rect (createWindow disp rootwin) 0 depth inputOutput visual mask attr
-setPanelProperties :: PanelState -> Phi ()
+setPanelProperties :: PanelState -> PhiX ()
setPanelProperties panel = do
disp <- asks phiDisplay
atoms <- asks phiAtoms
@@ -223,7 +224,7 @@ setPanelProperties panel = do
setStruts panel
-setStruts :: PanelState -> Phi ()
+setStruts :: PanelState -> PhiX ()
setStruts panel = do
atoms <- asks phiAtoms
disp <- asks phiDisplay