summaryrefslogtreecommitdiffstats
path: root/lib/Phi/Widgets/Taskbar.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Phi/Widgets/Taskbar.hs')
-rw-r--r--lib/Phi/Widgets/Taskbar.hs75
1 files changed, 42 insertions, 33 deletions
diff --git a/lib/Phi/Widgets/Taskbar.hs b/lib/Phi/Widgets/Taskbar.hs
index c17ac36..fbf7da8 100644
--- a/lib/Phi/Widgets/Taskbar.hs
+++ b/lib/Phi/Widgets/Taskbar.hs
@@ -166,7 +166,7 @@ data TaskbarMessage = WindowListUpdate ![Xlib.Window] !(M.Map Window WindowState
instance Show (IORef a) where
show _ = "IORef <?>"
-instance Widget Taskbar TaskbarState where
+instance Widget Taskbar TaskbarState () where
initWidget (Taskbar _) phi dispvar = do
phi' <- dupPhi phi
forkIO $ taskbarRunner phi' dispvar
@@ -204,41 +204,50 @@ instance Widget Taskbar TaskbarState where
desktopsWidth = sum $ map dwidth desktopNumbers
windowWidth = if windowCount == 0 then 0 else min (taskMaxSize config) ((w - desktopsWidth) `div` windowCount)
-
- flip (flip foldM_ 0) desktops $ \nwindows (desktop, desktopWindows) -> do
- let dstyle' = dstyle desktop
- dx = dleftwidth desktop + (sum $ map dwidth $ take desktop [0..]) + nwindows*windowWidth
-
- case dstyle' of
- Just ds -> do
- let (r, g, b, a) = desktopColor ds
- save
- drawBorder (desktopBorder ds) (dx - dleftwidth desktop) 0 (dwidth desktop + windowWidth * length desktopWindows) h
- clip
-
- setSourceRGBA r g b a
- renderText (desktopFont ds) (fromIntegral (dx - dlabelwidth desktop - gap desktop ds)) 0 (dlabelwidth desktop) h $ show (desktop+1)
-
- restore
-
- forM_ (zip [0..] desktopWindows) $ \(i, window) -> do
- let style = (if window == activeWindow then activeTaskStyle else normalTaskStyle) config
- h' = h - (borderV $ margin $ desktopBorder ds) - 2*(borderWidth $ desktopBorder ds) - (borderV $ padding $ desktopBorder ds)
- mstate = M.lookup window windowStates
- micons = M.lookup window windowIcons
- mscaledIconRef = M.lookup window windowScaledIcons
- x = dx + i*windowWidth
- y = (borderTop $ margin $ desktopBorder ds) + (borderWidth $ desktopBorder ds) + (borderTop $ padding $ desktopBorder ds)
+
+ surface <- createImageSurface FormatARGB32 w h
+ renderWith surface $ do
+ setOperator OperatorClear
+ paint
+
+ setOperator OperatorOver
+
+ flip (flip foldM_ 0) desktops $ \nwindows (desktop, desktopWindows) -> do
+ let dstyle' = dstyle desktop
+ dx = dleftwidth desktop + (sum $ map dwidth $ take desktop [0..]) + nwindows*windowWidth
+
+ case dstyle' of
+ Just ds -> do
+ let (r, g, b, a) = desktopColor ds
+ save
+ drawBorder (desktopBorder ds) (dx - dleftwidth desktop) 0 (dwidth desktop + windowWidth * length desktopWindows) h
+ clip
- case (mstate, micons, mscaledIconRef) of
- (Just state, Just icons, Just scaledIconRef) ->
- renderTask state icons scaledIconRef style x y windowWidth h'
-
- _ -> return ()
+ setSourceRGBA r g b a
+ renderText (desktopFont ds) (fromIntegral (dx - dlabelwidth desktop - gap desktop ds)) 0 (dlabelwidth desktop) h $ show (desktop+1)
+
+ restore
+
+ forM_ (zip [0..] desktopWindows) $ \(i, window) -> do
+ let style = (if window == activeWindow then activeTaskStyle else normalTaskStyle) config
+ h' = h - (borderV $ margin $ desktopBorder ds) - 2*(borderWidth $ desktopBorder ds) - (borderV $ padding $ desktopBorder ds)
+ mstate = M.lookup window windowStates
+ micons = M.lookup window windowIcons
+ mscaledIconRef = M.lookup window windowScaledIcons
+ x = dx + i*windowWidth
+ y = (borderTop $ margin $ desktopBorder ds) + (borderWidth $ desktopBorder ds) + (borderTop $ padding $ desktopBorder ds)
+
+ case (mstate, micons, mscaledIconRef) of
+ (Just state, Just icons, Just scaledIconRef) ->
+ renderTask state icons scaledIconRef style x y windowWidth h'
+
+ _ -> return ()
- _ -> return ()
+ _ -> return ()
- return $ nwindows + length desktopWindows
+ return $ nwindows + length desktopWindows
+
+ return [(True, SurfaceSlice 0 surface)]
handleMessage _ priv m = case (fromMessage m) of