summaryrefslogtreecommitdiffstats
path: root/lib/Phi/X11.hs
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-07-15 02:51:50 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-07-15 02:51:50 +0200
commitc6e57070ab4ca1fdaddf816208aef24f38aecaba (patch)
tree778196ebcd31bbfd5c57c9acdfcfcd205a798920 /lib/Phi/X11.hs
parent7da8a9114eecc750a93087d0ec985641ca2a3165 (diff)
downloadphi-c6e57070ab4ca1fdaddf816208aef24f38aecaba.tar
phi-c6e57070ab4ca1fdaddf816208aef24f38aecaba.zip
It's better not to lock in native code...
Diffstat (limited to 'lib/Phi/X11.hs')
-rw-r--r--lib/Phi/X11.hs11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/Phi/X11.hs b/lib/Phi/X11.hs
index 56293ef..4332352 100644
--- a/lib/Phi/X11.hs
+++ b/lib/Phi/X11.hs
@@ -64,10 +64,10 @@ runPhiX :: PhiConfig -> PhiState -> PhiX a -> IO (a, PhiState)
runPhiX config st (PhiX a) = runPhiReader config $ runStateT a st
withDisplayX :: Widget.Display -> (Display -> PhiX a) -> PhiX a
-withDisplayX (Widget.Display disp) f = do
- liftIO $ lockDisplay disp
+withDisplayX (Widget.Display dispvar) f = do
+ disp <- liftIO $ takeMVar dispvar
a <- f disp
- liftIO $ unlockDisplay disp
+ liftIO $ putMVar dispvar disp
return a
defaultXConfig = XConfig { phiXScreenInfo = getScreenInfo
@@ -76,10 +76,9 @@ defaultXConfig = XConfig { phiXScreenInfo = getScreenInfo
runPhi :: XConfig -> Panel.PanelConfig -> [Widget.Widget] -> IO ()
runPhi xconfig config widgets = do
- initThreads
phi <- initPhi
disp <- openDisplay []
-
+
atoms <- initAtoms disp
selectInput disp (defaultRootWindow disp) $ propertyChangeMask.|.structureNotifyMask
@@ -89,7 +88,7 @@ runPhi xconfig config widgets = do
screens <- liftIO $ phiXScreenInfo xconfig disp
- let dispvar = Widget.Display disp
+ dispvar <- liftM Widget.Display $ liftIO $ newMVar disp
widgetStates <- liftIO $ mapM (Widget.createWidgetState phi dispvar) widgets
withDisplayX dispvar $ \disp -> do