mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-14 03:35:54 -07:00
Extended decoration theme to contain extra static text that always appears in the title bar
This commit is contained in:
@@ -77,6 +77,7 @@ data Theme =
|
|||||||
, fontName :: String -- ^ Font name
|
, fontName :: String -- ^ Font name
|
||||||
, decoWidth :: Dimension -- ^ Maximum width of the decorations (if supported by the 'DecorationStyle')
|
, decoWidth :: Dimension -- ^ Maximum width of the decorations (if supported by the 'DecorationStyle')
|
||||||
, decoHeight :: Dimension -- ^ Height of the decorations
|
, decoHeight :: Dimension -- ^ Height of the decorations
|
||||||
|
, windowTitleAddons :: [(String, Align)] -- ^ Extra text to appear in a window's title bar
|
||||||
} deriving (Show, Read)
|
} deriving (Show, Read)
|
||||||
|
|
||||||
-- | The default xmonad 'Theme'.
|
-- | The default xmonad 'Theme'.
|
||||||
@@ -94,6 +95,7 @@ defaultTheme =
|
|||||||
, fontName = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*"
|
, fontName = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*"
|
||||||
, decoWidth = 200
|
, decoWidth = 200
|
||||||
, decoHeight = 20
|
, decoHeight = 20
|
||||||
|
, windowTitleAddons = []
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | A 'Decoration' layout modifier will handle 'SetTheme', a message
|
-- | A 'Decoration' layout modifier will handle 'SetTheme', a message
|
||||||
@@ -374,7 +376,9 @@ updateDeco sh t fs ((w,_),(Just dw,Just (Rectangle _ _ wh ht))) = do
|
|||||||
let s = shrinkIt sh
|
let s = shrinkIt sh
|
||||||
name <- shrinkWhile s (\n -> do size <- io $ textWidthXMF dpy fs n
|
name <- shrinkWhile s (\n -> do size <- io $ textWidthXMF dpy fs n
|
||||||
return $ size > fromIntegral wh - fromIntegral (ht `div` 2)) (show nw)
|
return $ size > fromIntegral wh - fromIntegral (ht `div` 2)) (show nw)
|
||||||
paintAndWrite dw fs wh ht 1 bc borderc tc bc [AlignCenter] [name]
|
let als = AlignCenter : map snd (windowTitleAddons t)
|
||||||
|
strs = name : map fst (windowTitleAddons t)
|
||||||
|
paintAndWrite dw fs wh ht 1 bc borderc tc bc als strs
|
||||||
updateDeco _ _ _ (_,(Just w,Nothing)) = hideWindow w
|
updateDeco _ _ _ (_,(Just w,Nothing)) = hideWindow w
|
||||||
updateDeco _ _ _ _ = return ()
|
updateDeco _ _ _ _ = return ()
|
||||||
|
|
||||||
|
@@ -144,6 +144,7 @@ textExtentsXMF (Xft xftfont) _ = io $ do
|
|||||||
|
|
||||||
-- | String position
|
-- | String position
|
||||||
data Align = AlignCenter | AlignRight | AlignLeft | AlignRightOffset Int
|
data Align = AlignCenter | AlignRight | AlignLeft | AlignRightOffset Int
|
||||||
|
deriving (Show, Read)
|
||||||
|
|
||||||
-- | Return the string x and y 'Position' in a 'Rectangle', given a
|
-- | Return the string x and y 'Position' in a 'Rectangle', given a
|
||||||
-- 'FontStruct' and the 'Align'ment
|
-- 'FontStruct' and the 'Align'ment
|
||||||
|
Reference in New Issue
Block a user