summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-07-22 11:42:22 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-07-22 11:42:22 +0200
commit906dc08d3e415835422daf1dcdf03a2b6edda1c3 (patch)
treeaeab4adfa15f149b1eebcc897e0d93c2e2f49912
parent227cf56f443d1ce45fce2e13a4daf442a29bc862 (diff)
downloadphi-906dc08d3e415835422daf1dcdf03a2b6edda1c3.tar
phi-906dc08d3e415835422daf1dcdf03a2b6edda1c3.zip
Fix crash when no root pixmap is set
-rw-r--r--lib/Phi/X11.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/Phi/X11.hs b/lib/Phi/X11.hs
index f0cf62c..23c6c62 100644
--- a/lib/Phi/X11.hs
+++ b/lib/Phi/X11.hs
@@ -252,6 +252,7 @@ updateRootImage disp = do
rootwin = defaultRootWindow disp
pixmap <- liftM (fromIntegral . fromMaybe 0 . listToMaybe . join . catMaybes) $ forM [atom_XROOTPMAP_ID atoms, atom_XROOTMAP_ID atoms] $
\atom -> liftIO $ getWindowProperty32 disp atom rootwin
+
(_, _, _, rootWidth, rootHeight, _, _) <- liftIO $ getGeometry disp rootwin
-- update surface size
@@ -264,13 +265,15 @@ updateRootImage disp = do
modify $ \state -> state { phiRootImage = newBg }
bg <- gets phiRootImage
- rootSurface <- liftIO $ Util.createXlibSurface disp pixmap visual (fromIntegral rootWidth) (fromIntegral rootHeight)
-
- renderWith bg $ withPatternForSurface rootSurface $ \pattern -> do
- setSource pattern
- paint
- surfaceFinish rootSurface
+ 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
createPanel :: Display -> Window -> [Widget.WidgetState] -> Rectangle -> PhiX PanelState