mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
X.U.Hacks: Clean up tray padding hooks a bit
Un-export trivial/useless definitions and adapt the generic versions of trayerPaddingXmobarEventHook to be more generally useful. Related: https://github.com/xmonad/xmonad-contrib/pull/643#issuecomment-962661655
This commit is contained in:
parent
d71856431a
commit
54095f5420
@ -105,11 +105,10 @@
|
|||||||
|
|
||||||
* `XMonad.Util.Hacks`
|
* `XMonad.Util.Hacks`
|
||||||
|
|
||||||
- Added `trayerQuery` for easily querying trayer and
|
- Added `trayerPaddingXmobarEventHook` (plus generic variants for other
|
||||||
`trayerPaddingXmobarEventHook` (as well as a variant to specify a
|
trays/panels) to communicate trayer resize events to XMobar so that
|
||||||
different X property) to communicate trayer resize events to
|
padding space may be reserved on xmobar for the tray. Requires `xmobar`
|
||||||
XMobar so that padding space may be reserved on xmobar for the
|
version 0.40 or higher.
|
||||||
tray. Requires `xmobar` version 0.40 or higher.
|
|
||||||
|
|
||||||
* `XMonad.Layout.VoidBorders`
|
* `XMonad.Layout.VoidBorders`
|
||||||
|
|
||||||
|
@ -32,21 +32,20 @@ module XMonad.Util.Hacks (
|
|||||||
|
|
||||||
-- * Stacking trays (trayer) above panels (xmobar)
|
-- * Stacking trays (trayer) above panels (xmobar)
|
||||||
-- $raiseTrayer
|
-- $raiseTrayer
|
||||||
trayerQuery,
|
|
||||||
trayerAboveXmobarEventHook,
|
trayerAboveXmobarEventHook,
|
||||||
trayAbovePanelEventHook,
|
trayAbovePanelEventHook,
|
||||||
|
|
||||||
-- * Inform xmobar when trays (e.g., trayer) change width
|
-- * Inform xmobar when trays (e.g. trayer) change width
|
||||||
-- $padTrayer
|
-- $padTrayer
|
||||||
trayPaddingXmobarDefProp,
|
|
||||||
trayerPaddingXmobarEventHook,
|
trayerPaddingXmobarEventHook,
|
||||||
trayerPaddingXmobarEventHook',
|
trayPaddingXmobarEventHook,
|
||||||
|
trayPaddingEventHook,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
import XMonad.Hooks.StatusBar (xmonadPropLog')
|
import XMonad.Hooks.StatusBar (xmonadPropLog')
|
||||||
import XMonad.Prelude (All (All), filterM, when)
|
import XMonad.Prelude (All (All), fi, filterM, when)
|
||||||
import System.Posix.Env (putEnv)
|
import System.Posix.Env (putEnv)
|
||||||
|
|
||||||
|
|
||||||
@ -134,13 +133,9 @@ javaHack conf = conf
|
|||||||
--
|
--
|
||||||
-- > handleEventHook = … <> Hacks.trayerAboveXmobarEventHook
|
-- > handleEventHook = … <> Hacks.trayerAboveXmobarEventHook
|
||||||
|
|
||||||
-- | A 'Query' to identify the trayer window.
|
|
||||||
trayerQuery :: Query Bool
|
|
||||||
trayerQuery = className =? "trayer"
|
|
||||||
|
|
||||||
-- | Like 'trayAbovePanelEventHook', but specialised for trayer/xmobar.
|
-- | Like 'trayAbovePanelEventHook', but specialised for trayer/xmobar.
|
||||||
trayerAboveXmobarEventHook :: Event -> X All
|
trayerAboveXmobarEventHook :: Event -> X All
|
||||||
trayerAboveXmobarEventHook = trayAbovePanelEventHook trayerQuery (appName =? "xmobar")
|
trayerAboveXmobarEventHook = trayAbovePanelEventHook (className =? "trayer") (appName =? "xmobar")
|
||||||
|
|
||||||
-- | Whenever a tray window lowers itself to the bottom of the stack, look for
|
-- | Whenever a tray window lowers itself to the bottom of the stack, look for
|
||||||
-- any panels above it and lower these.
|
-- any panels above it and lower these.
|
||||||
@ -187,45 +182,31 @@ trayAbovePanelEventHook _ _ _ = mempty
|
|||||||
--
|
--
|
||||||
-- > _XMONAD_TRAYPAD(UTF8_STRING) = "<hspace=53/>"
|
-- > _XMONAD_TRAYPAD(UTF8_STRING) = "<hspace=53/>"
|
||||||
|
|
||||||
-- | 'trayPaddingXmobarDefProp' is default property name,
|
-- | A simple trayer/xmobar-specific event hook that watches for trayer window
|
||||||
-- @"_XMONAD_TRAYPAD"@, to use with 'xmonadPropLog''
|
-- resize changes and updates the _XMONAD_TRAYPAD property with xmobar markup
|
||||||
trayPaddingXmobarDefProp :: String
|
-- that leaves a gap for the trayer.
|
||||||
trayPaddingXmobarDefProp = "_XMONAD_TRAYPAD"
|
|
||||||
|
|
||||||
-- | A simple trayer-specific event hook that watches for trayer window
|
|
||||||
-- resize changes and update the value in the property specified by
|
|
||||||
-- 'trayPaddingXmobarDefProp'.
|
|
||||||
trayerPaddingXmobarEventHook :: Event -> X All -- ^ event hook
|
trayerPaddingXmobarEventHook :: Event -> X All -- ^ event hook
|
||||||
trayerPaddingXmobarEventHook = trayerPaddingXmobarEventHook' trayPaddingXmobarDefProp
|
trayerPaddingXmobarEventHook = trayPaddingXmobarEventHook (className =? "trayer") "_XMONAD_TRAYPAD"
|
||||||
|
|
||||||
-- | A more generic version of 'trayerPaddingXmobarEventHook' that
|
-- | A generic version of 'trayerPaddingXmobarEventHook' that
|
||||||
-- allows the user to specify the property to use with 'xmonadPropLog''
|
-- allows the user to specify how to identify a tray window and the property
|
||||||
-- when 'trayPaddingXmobarDefProp' is not desired. This is still a
|
-- to use with 'xmonadPropLog''. This is useful for other trays like
|
||||||
-- trayer-specific hook.
|
-- stalonetray and also when space for more than one tray-like window needs to
|
||||||
trayerPaddingXmobarEventHook'
|
-- be reserved.
|
||||||
:: String -- ^ 'xmonadPropLog'' string to use
|
|
||||||
-> Event -> X All -- ^ event hook result
|
|
||||||
trayerPaddingXmobarEventHook' s = trayPaddingXmobarEventHook (trayDefaultAction s) trayerQuery
|
|
||||||
|
|
||||||
-- | A fully generic tray resize hook. This function is not
|
|
||||||
-- trayer-specific; note the prefix is @tray@, not @trayer@. Both the
|
|
||||||
-- action to take and the tray identification query are given as
|
|
||||||
-- arguments.
|
|
||||||
trayPaddingXmobarEventHook
|
trayPaddingXmobarEventHook
|
||||||
:: (Int -> X()) -- ^ action to take when query succeeds, pixels to action
|
:: Query Bool -- ^ query to identify the tray window
|
||||||
-> Query Bool -- ^ query to identify the tray window
|
-> String -- ^ 'xmonadPropLog'' property to use
|
||||||
-> Event -> X All -- ^ event hook result
|
-> Event -> X All -- ^ resulting event hook
|
||||||
trayPaddingXmobarEventHook action trayQ ConfigureEvent{ ev_window = w, ev_width = wa } = do
|
trayPaddingXmobarEventHook trayQ prop = trayPaddingEventHook trayQ hspaceLog
|
||||||
whenX (runQuery trayQ w) $ action (fromIntegral wa)
|
where hspaceLog width = xmonadPropLog' prop ("<hspace=" ++ show width ++ "/>")
|
||||||
return (All True)
|
|
||||||
trayPaddingXmobarEventHook _ _ _ = return (All True)
|
|
||||||
|
|
||||||
-- | The default tray action that is used by both
|
-- | A fully generic tray resize hook that invokes a callback whenever a
|
||||||
-- 'trayerPaddingXmobarEventHook' and 'trayerPaddingXmobarEventHook''.
|
-- tray-like window changes width.
|
||||||
-- This action places @\<hspace=pixels\/\>@ on the specified
|
trayPaddingEventHook
|
||||||
-- 'xmonadPropLog'' property.
|
:: Query Bool -- ^ query to identify the tray window
|
||||||
trayDefaultAction
|
-> (Int -> X ()) -- ^ action to perform when tray width changes
|
||||||
:: String -- ^ 'xmonadPropLog'' property to use
|
-> Event -> X All -- ^ resulting event hook
|
||||||
-> Int -- ^ new tray width in pixels
|
trayPaddingEventHook trayQ widthChanged ConfigureEvent{ ev_window = w, ev_width = wa } = do
|
||||||
-> X () -- ^ resultant update
|
whenX (runQuery trayQ w) $ widthChanged (fi wa)
|
||||||
trayDefaultAction xPropLog n = xmonadPropLog' xPropLog ("<hspace=" ++ show n ++ "/>")
|
mempty
|
||||||
|
trayPaddingEventHook _ _ _ = mempty
|
||||||
|
Loading…
x
Reference in New Issue
Block a user