summaryrefslogtreecommitdiffstats
path: root/lib/Phi/X11.hs
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-08-21 21:39:26 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-08-21 21:39:26 +0200
commit8222c6041d2e2ed5258aa0f9188d2011a17285c9 (patch)
tree263f36b511eadacb15cdd775377aafbb495d9632 /lib/Phi/X11.hs
parent42c14fa1ca9d47ae32766aaa2aa995c684b7e9cb (diff)
downloadphi-8222c6041d2e2ed5258aa0f9188d2011a17285c9.tar
phi-8222c6041d2e2ed5258aa0f9188d2011a17285c9.zip
Add a lot of caching framework
Diffstat (limited to 'lib/Phi/X11.hs')
-rw-r--r--lib/Phi/X11.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Phi/X11.hs b/lib/Phi/X11.hs
index 110e9d4..818a9db 100644
--- a/lib/Phi/X11.hs
+++ b/lib/Phi/X11.hs
@@ -18,7 +18,7 @@ import Data.Char
import Control.Concurrent
import Control.Concurrent.MVar
-import Control.Monad.State
+import Control.Monad.State.Strict
import Control.Monad.Reader
import Control.Monad.Trans
@@ -51,7 +51,7 @@ data PanelState w s c = (Widget.Widget w s c) => PanelState { panelWindow
, panelScreenArea :: !Rectangle
, panelWidget :: !w
, panelWidgetState :: !s
- , panelWidgetCache :: !(Maybe c)
+ , panelWidgetCache :: !c
}
data PhiConfig = PhiConfig { phiPhi :: !Phi
@@ -205,7 +205,8 @@ updatePanels dispvar = do
area = panelArea panel
let layoutedWidget = (withDimension area $ Widget.layout (panelWidget panel) (panelWidgetState panel)) $ panelScreenArea panel
- panelSurfaces <- liftIO $ (withDimension area $ Widget.render (panelWidget panel) layoutedWidget 0 0) (panelScreenArea panel)
+ (panelSurfaces, cache') <- liftIO $ flip runStateT (panelWidgetCache panel) $
+ (withDimension area $ Widget.render (panelWidget panel) layoutedWidget 0 0) (panelScreenArea panel)
Widget.withDisplay dispvar $ \disp -> do
let screen = defaultScreen disp
@@ -239,7 +240,7 @@ updatePanels dispvar = do
(withDimension area $ clearArea disp (panelWindow panel) 0 0) True
sync disp False
- return $ panel { panelWidgetState = layoutedWidget }
+ return $ panel { panelWidgetState = layoutedWidget, panelWidgetCache = cache' }
modify $ \state -> state { phiPanels = panels' }
@@ -311,7 +312,7 @@ createPanel disp win w s screenRect = do
, panelScreenArea = screenRect
, panelWidget = w
, panelWidgetState = s
- , panelWidgetCache = Nothing
+ , panelWidgetCache = initCache w
}
createPanelWindow :: Display -> Rectangle -> PhiX w s c Window