summaryrefslogtreecommitdiffstats
path: root/lib/Phi/Widgets
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-07-18 20:57:19 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-07-18 20:57:19 +0200
commit581e1f9c63101fd2a00711748415997b0c20b793 (patch)
treeab2ee291354819727939593655e0a53383870b03 /lib/Phi/Widgets
parent4cc0f0f2ee44aa5c65b8b7f759620b5de0c874a3 (diff)
downloadphi-581e1f9c63101fd2a00711748415997b0c20b793.tar
phi-581e1f9c63101fd2a00711748415997b0c20b793.zip
Make minSize depend on the screen if necessary
Diffstat (limited to 'lib/Phi/Widgets')
-rw-r--r--lib/Phi/Widgets/AlphaBox.hs6
-rw-r--r--lib/Phi/Widgets/Clock.hs2
-rw-r--r--lib/Phi/Widgets/Systray.hs31
-rw-r--r--lib/Phi/Widgets/Taskbar.hs33
4 files changed, 43 insertions, 29 deletions
diff --git a/lib/Phi/Widgets/AlphaBox.hs b/lib/Phi/Widgets/AlphaBox.hs
index 3ed31d0..c09b911 100644
--- a/lib/Phi/Widgets/AlphaBox.hs
+++ b/lib/Phi/Widgets/AlphaBox.hs
@@ -20,12 +20,12 @@ instance WidgetClass AlphaBox where
type WidgetData AlphaBox = AlphaBoxState
initWidget (AlphaBox _ widgets) phi disp = liftM AlphaBoxState $ mapM (createWidgetState phi disp) widgets
- minSize (AlphaBox _ _) (AlphaBoxState widgetStates) height =
- sum (map (\(WidgetState {stateWidget = w, statePrivateData = priv}) -> minSize w priv height) widgetStates)
+ minSize (AlphaBox _ _) (AlphaBoxState widgetStates) height screen =
+ sum (map (\(WidgetState {stateWidget = w, statePrivateData = priv}) -> minSize w priv height screen) widgetStates)
weight (AlphaBox _ widgets) = sum (map (\(Widget w) -> weight w) widgets)
- layout (AlphaBox _ _) (AlphaBoxState widgetStates) width height = AlphaBoxState $ layoutWidgets widgetStates 0 0 width height
+ layout (AlphaBox _ _) (AlphaBoxState widgetStates) width height screen = AlphaBoxState $ layoutWidgets widgetStates 0 0 width height screen
render (AlphaBox alpha _) (AlphaBoxState widgetStates) w h screen = do
renderWithSimilarSurface ContentColorAlpha w h $ \surface -> do
diff --git a/lib/Phi/Widgets/Clock.hs b/lib/Phi/Widgets/Clock.hs
index 492d807..1f00bd0 100644
--- a/lib/Phi/Widgets/Clock.hs
+++ b/lib/Phi/Widgets/Clock.hs
@@ -55,7 +55,7 @@ instance WidgetClass Clock where
return $ ClockState time
- minSize (Clock config) _ _ = clockSize config
+ minSize (Clock config) _ _ _ = clockSize config
render (Clock config) (ClockState time) w h _ = do
time <- liftIO getZonedTime
diff --git a/lib/Phi/Widgets/Systray.hs b/lib/Phi/Widgets/Systray.hs
index 26ff0a4..e1ab198 100644
--- a/lib/Phi/Widgets/Systray.hs
+++ b/lib/Phi/Widgets/Systray.hs
@@ -24,7 +24,7 @@ import Phi.X11.Atoms
data SystrayIconState = SystrayIconState deriving Show
-data SystrayState = SystrayState [SystrayIconState] deriving Show
+data SystrayState = SystrayState Rectangle [SystrayIconState] deriving Show
data Systray = Systray deriving Show
@@ -35,13 +35,18 @@ instance WidgetClass Systray where
initWidget (Systray) phi dispvar = do
forkIO $ systrayRunner phi dispvar
- return $ SystrayState []
+ return $ SystrayState (head . getScreens $ dispvar) []
- minSize _ (SystrayState icons) height = (length icons)*height
+ minSize _ (SystrayState systrayScreen icons) height screen = case True of
+ _ | screen == systrayScreen -> (length icons)*height
+ | otherwise -> 0
+
weight _ = 0
- render Systray (SystrayState icons) w h screen = do
- return ()
+ render Systray (SystrayState systrayScreen icons) w h screen = case True of
+ _ | screen == systrayScreen -> do
+ return ()
+ | otherwise -> return ()
systrayRunner :: Phi -> Display -> IO ()
@@ -117,21 +122,27 @@ handleEvent ClientMessageEvent { ev_message_type = message_type, ev_data = messa
case messageData of
(_:opcode:iconID:_) -> do
case True of
- _ | opcode == sYSTEM_TRAY_REQUEST_DOCK -> do
- return ()
+ _ | opcode == sYSTEM_TRAY_REQUEST_DOCK ->
+ when (iconID /= 0) $ addIcon phi dispvar $ fromIntegral iconID
- | opcode == sYSTEM_TRAY_BEGIN_MESSAGE || opcode == sYSTEM_TRAY_CANCEL_MESSAGE -> do
+ | opcode == sYSTEM_TRAY_BEGIN_MESSAGE || opcode == sYSTEM_TRAY_CANCEL_MESSAGE ->
return ()
| otherwise -> do
+ putStrLn "Phi: unknown tray message"
return ()
_ ->
return ()
-
-
+
handleEvent _ _ _ _ = return ()
+
+addIcon :: Phi -> Display -> Window -> IO ()
+addIcon phi display window = do
+ return ()
+
+
systray :: Widget
systray = Widget $ Systray
diff --git a/lib/Phi/Widgets/Taskbar.hs b/lib/Phi/Widgets/Taskbar.hs
index e1d0ed9..f8b61f0 100644
--- a/lib/Phi/Widgets/Taskbar.hs
+++ b/lib/Phi/Widgets/Taskbar.hs
@@ -170,7 +170,7 @@ instance WidgetClass Taskbar where
return $ TaskbarState 0 0 (-1) [] M.empty M.empty M.empty M.empty
- minSize _ _ _ = 0
+ minSize _ _ _ _ = 0
weight _ = 1
render (Taskbar config) TaskbarState { taskbarActiveWindow = activeWindow
@@ -182,21 +182,24 @@ instance WidgetClass Taskbar where
, taskbarWindowScaledIcons = windowScaledIcons
, taskbarWindowScreens = windowScreens
} w h screen = do
- let screenWindows = filter ((== Just screen) . flip M.lookup windowScreens) windows
+ let screenWindows = filter ((== Just screen) . flip M.lookup windowScreens) windows
desktopNumbers = take desktopCount [0..]
- desktops = map (\desktop -> (desktop, filter (fromMaybe False . fmap (windowOnDesktop desktop) . flip M.lookup windowStates) screenWindows)) desktopNumbers
- windowCount = sum $ map (length . snd) $ desktops
- dstyle d = fmap (if d == currentDesktop then snd else fst) $ desktopStyle config
- dlabelwidth d = fromMaybe 0 $ fmap desktopLabelWidth $ dstyle d
- gap d ds = if null (snd $ desktops !! d) then 0 else desktopLabelGap ds
- dleftwidth d = fromMaybe 0 $ fmap (\ds@DesktopStyle {desktopBorder = border}
- -> (borderLeft $ margin border) + (borderWidth border) + (borderLeft $ padding border)
- + dlabelwidth d + gap d ds) $ dstyle d
- dwidth d = fromMaybe 0 $ fmap (\ds@DesktopStyle {desktopBorder = border}
- -> (borderH $ margin border) + 2*(borderWidth border) + (borderH $ padding border)
- + dlabelwidth d + gap d ds) $ dstyle d
- desktopsWidth = sum $ map dwidth desktopNumbers
- windowWidth = if windowCount == 0 then 0 else min (taskMaxSize config) ((w - desktopsWidth) `div` windowCount)
+ desktops = map (\desktop -> (desktop, filter (fromMaybe False . fmap (windowOnDesktop desktop) . flip M.lookup windowStates) screenWindows)) desktopNumbers
+
+ windowCount = sum $ map (length . snd) $ desktops
+
+ dstyle d = fmap (if d == currentDesktop then snd else fst) $ desktopStyle config
+ dlabelwidth d = fromMaybe 0 $ fmap desktopLabelWidth $ dstyle d
+ gap d ds = if null (snd $ desktops !! d) then 0 else desktopLabelGap ds
+ dleftwidth d = fromMaybe 0 $ fmap (\ds@DesktopStyle {desktopBorder = border}
+ -> (borderLeft $ margin border) + (borderWidth border) + (borderLeft $ padding border)
+ + dlabelwidth d + gap d ds) $ dstyle d
+ dwidth d = fromMaybe 0 $ fmap (\ds@DesktopStyle {desktopBorder = border}
+ -> (borderH $ margin border) + 2*(borderWidth border) + (borderH $ padding border)
+ + dlabelwidth d + gap d ds) $ dstyle d
+
+ 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