From 4d15f94cd5d9a5405bda3ce58eb7ca6122f47742 Mon Sep 17 00:00:00 2001 From: Roman Cheplyaka Date: Fri, 26 Dec 2008 23:08:51 +0100 Subject: X.L.Monitor: changes in message passing - transform mbName (Maybe String) to name (String) - slghtly change semantics of messages, document it darcs-hash:20081226220851-3ebed-4d064ed9c6f1ada44dc76851c2bfa34d5d75b484.gz --- XMonad/Layout/Monitor.hs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'XMonad/Layout/Monitor.hs') diff --git a/XMonad/Layout/Monitor.hs b/XMonad/Layout/Monitor.hs index 519ffcd..f5d7de9 100644 --- a/XMonad/Layout/Monitor.hs +++ b/XMonad/Layout/Monitor.hs @@ -59,7 +59,7 @@ import Control.Monad -- > -- Cairo-clock creates 2 windows with the same classname, thus also using title -- > prop = ClassName "Cairo-clock" `And` Title "MacSlow's Cairo-Clock" -- > -- rectangle 150x150 in lower right corner, assuming 1280x800 resolution --- > , rect = (Rectangle (1280-150) (800-150) 150 150) +-- > , rect = Rectangle (1280-150) (800-150) 150 150 -- > -- avoid flickering -- > , persistent = True -- > -- make the window transparent @@ -67,7 +67,7 @@ import Control.Monad -- > -- hide on start -- > , visible = False -- > -- assign it a name to be able to toggle it independently of others --- > , mbName = Just "clock" +-- > , name = "clock" -- > } -- -- Add ManageHook to de-manage monitor windows and apply opacity settings. @@ -89,12 +89,12 @@ import Control.Monad -- Screenshot: data Monitor a = Monitor - { prop :: Property -- ^ property which uniquely identifies monitor window - , rect :: Rectangle -- ^ specifies where to put monitor - , visible :: Bool -- ^ is it visible by default? - , mbName :: (Maybe String) -- ^ name of monitor (useful when we have many of them) - , persistent :: Bool -- ^ is it shown on all layouts? - , opacity :: Integer -- ^ opacity level + { prop :: Property -- ^ property which uniquely identifies monitor window + , rect :: Rectangle -- ^ specifies where to put monitor + , visible :: Bool -- ^ is it visible by default? + , name :: String -- ^ name of monitor (useful when we have many of them) + , persistent :: Bool -- ^ is it shown on all layouts? + , opacity :: Integer -- ^ opacity level } deriving (Read, Show) -- | Template for 'Monitor' record. At least 'prop' and 'rect' should be @@ -104,11 +104,13 @@ monitor = Monitor { prop = Const False , rect = Rectangle 0 0 0 0 , visible = True - , mbName = Nothing + , name = "" , persistent = False , opacity = 0xFFFFFFFF } +-- | Messages without names affect all monitors. Messages with names affect only +-- monitors whose names match. data MonitorMessage = ToggleMonitor | ShowMonitor | HideMonitor | ToggleMonitorNamed String | ShowMonitorNamed String @@ -134,13 +136,13 @@ instance LayoutModifier Monitor Window where handleMess mon mess | Just ToggleMonitor <- fromMessage mess = return $ Just $ mon { visible = not $ visible mon } | Just (ToggleMonitorNamed n) <- fromMessage mess = return $ - if mbName mon `elem` [Just n, Nothing] then Just $ mon { visible = not $ visible mon } else Nothing + if name mon == n then Just $ mon { visible = not $ visible mon } else Nothing | Just ShowMonitor <- fromMessage mess = return $ Just $ mon { visible = True } | Just (ShowMonitorNamed n) <- fromMessage mess = return $ - if mbName mon `elem` [Just n, Nothing] then Just $ mon { visible = True } else Nothing + if name mon == n then Just $ mon { visible = True } else Nothing | Just HideMonitor <- fromMessage mess = return $ Just $ mon { visible = False } | Just (HideMonitorNamed n) <- fromMessage mess = return $ - if mbName mon `elem` [Just n, Nothing] then Just $ mon { visible = False } else Nothing + if name mon == n then Just $ mon { visible = False } else Nothing | Just Hide <- fromMessage mess = do unless (persistent mon) $ withMonitor (prop mon) () hide; return Nothing | otherwise = return Nothing -- cgit v1.2.3