summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-07-22 22:36:43 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-07-22 22:36:43 +0200
commitde1dc32b330d7362a18bdb61e11a146e0f316602 (patch)
tree1f2087deb27d93cb53cd9f32c1973bf2f62f578a
parent906dc08d3e415835422daf1dcdf03a2b6edda1c3 (diff)
downloadphi-de1dc32b330d7362a18bdb61e11a146e0f316602.tar
phi-de1dc32b330d7362a18bdb61e11a146e0f316602.zip
Fix background update race, speed up rendering!
-rw-r--r--lib/Phi/X11.hs46
1 files changed, 28 insertions, 18 deletions
diff --git a/lib/Phi/X11.hs b/lib/Phi/X11.hs
index 23c6c62..d7159dd 100644
--- a/lib/Phi/X11.hs
+++ b/lib/Phi/X11.hs
@@ -208,18 +208,23 @@ updatePanels dispvar = do
let screen = defaultScreen disp
visual = defaultVisual disp screen
- buffer <- liftIO $ withDimension area $ Util.createXlibSurface disp pixmap visual
+ xbuffer <- liftIO $ withDimension area $ Util.createXlibSurface disp pixmap visual
- renderWith buffer $ do
- withPatternForSurface rootImage $ \pattern -> do
- save
- translate (-(fromIntegral $ rect_x area)) (-(fromIntegral $ rect_y area))
- setSource pattern
- paint
- restore
- Widget.renderWidgets layoutedWidgets $ panelScreenArea panel
+ liftIO $ (withDimension area $ withSimilarSurface xbuffer ContentColor) $ \buffer -> do
+ renderWith buffer $ do
+ withPatternForSurface rootImage $ \pattern -> do
+ save
+ translate (-(fromIntegral $ rect_x area)) (-(fromIntegral $ rect_y area))
+ setSource pattern
+ paint
+ restore
+ Widget.renderWidgets layoutedWidgets $ panelScreenArea panel
+ renderWith xbuffer $ do
+ withPatternForSurface buffer $ \pattern -> do
+ setSource pattern
+ paint
- surfaceFinish buffer
+ surfaceFinish xbuffer
-- copy buffer to window
liftIO $ do
@@ -266,14 +271,19 @@ updateRootImage disp = do
bg <- gets phiRootImage
- when (pixmap /= 0) $ do
- rootSurface <- liftIO $ Util.createXlibSurface disp pixmap visual (fromIntegral rootWidth) (fromIntegral rootHeight)
-
- renderWith bg $ withPatternForSurface rootSurface $ \pattern -> do
- setSource pattern
- paint
-
- surfaceFinish rootSurface
+ case pixmap of
+ 0 -> do
+ renderWith bg $ do
+ setSourceRGB 0 0 0
+ paint
+ _ -> do
+ rootSurface <- liftIO $ Util.createXlibSurface disp pixmap visual (fromIntegral rootWidth) (fromIntegral rootHeight)
+
+ renderWith bg $ withPatternForSurface rootSurface $ \pattern -> do
+ setSource pattern
+ paint
+
+ surfaceFinish rootSurface
createPanel :: Display -> Window -> [Widget.WidgetState] -> Rectangle -> PhiX PanelState