diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-07-15 09:17:57 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-07-15 09:17:57 +0200 |
commit | 465d7579868b66d7076446744f1d80d2b272aca8 (patch) | |
tree | 61cefdcf7fc85e17c8ab2e7175478aa290ecf3fc /lib/Phi/X11.hs | |
parent | c6e57070ab4ca1fdaddf816208aef24f38aecaba (diff) | |
download | phi-465d7579868b66d7076446744f1d80d2b272aca8.tar phi-465d7579868b66d7076446744f1d80d2b272aca8.zip |
Some more work on the taskbar
Diffstat (limited to 'lib/Phi/X11.hs')
-rw-r--r-- | lib/Phi/X11.hs | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/Phi/X11.hs b/lib/Phi/X11.hs index 4332352..8d037a8 100644 --- a/lib/Phi/X11.hs +++ b/lib/Phi/X11.hs @@ -31,6 +31,7 @@ import qualified Phi.Widget as Widget import Phi.X11.Atoms import qualified Phi.Bindings.Util as Util + data XConfig = XConfig { phiXScreenInfo :: !(Display -> IO [Rectangle]) } @@ -63,13 +64,6 @@ newtype PhiX a = PhiX (StateT PhiState PhiReader a) 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 dispvar) f = do - disp <- liftIO $ takeMVar dispvar - a <- f disp - liftIO $ putMVar dispvar disp - return a - defaultXConfig = XConfig { phiXScreenInfo = getScreenInfo } @@ -88,10 +82,11 @@ runPhi xconfig config widgets = do screens <- liftIO $ phiXScreenInfo xconfig disp - dispvar <- liftM Widget.Display $ liftIO $ newMVar disp + dispmvar <- liftIO $ newMVar disp + let dispvar = Widget.Display dispmvar atoms widgetStates <- liftIO $ mapM (Widget.createWidgetState phi dispvar) widgets - withDisplayX dispvar $ \disp -> do + Widget.withDisplay dispvar $ \disp -> do panels <- mapM (createPanel disp widgetStates) screens forM_ panels $ \panel -> do @@ -105,7 +100,7 @@ runPhi xconfig config widgets = do liftIO $ forkIO $ receiveEvents phi dispvar forever $ do - message <- liftIO $ receiveMessage phi + message <- receiveMessage phi handleMessage dispvar message return () @@ -120,13 +115,13 @@ handleMessage dispvar m = do modify $ \state@PhiState {phiPanels = panels} -> state {phiPanels = map (handlePanel m) panels} case (fromMessage m) of - Just Repaint -> withDisplayX dispvar $ \disp -> + Just Repaint -> Widget.withDisplay dispvar $ \disp -> updatePanels disp True _ -> case (fromMessage m) of - Just ExposeEvent {} -> withDisplayX dispvar $ \disp -> + Just ExposeEvent {} -> Widget.withDisplay dispvar $ \disp -> updatePanels disp False - Just event@PropertyEvent {} -> withDisplayX dispvar $ \disp -> + Just event@PropertyEvent {} -> Widget.withDisplay dispvar $ \disp -> handlePropertyUpdate disp event _ -> return () @@ -206,8 +201,8 @@ updateRootImage disp = do let screen = defaultScreen disp visual = defaultVisual disp screen rootwin = defaultRootWindow disp - pixmap <- liftM (fromMaybe 0 . listToMaybe . join . catMaybes) $ forM [atom_XROOTPMAP_ID atoms, atom_XROOTMAP_ID atoms] $ - \atom -> liftIO $ rawGetWindowProperty 32 disp atom rootwin + 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 |