mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-06 15:01:53 -07:00
fix: handle const (0,0)
from passing def
as keybinding action
Before https://github.com/xmonad/xmonad/commit/383ffb7 this would bind all unbound keys to toggle struts; after it, it would bind no keys at all. With this commit, it will check for this case and use the default keybinding instead. Users who intend no key to be bound should probably use `withSB` instead, especially in light of aforementioned commit.
This commit is contained in:
@@ -156,7 +156,8 @@ import XMonad.Hooks.StatusBar
|
|||||||
-- You should use this function only when the default 'dzen' function does not
|
-- You should use this function only when the default 'dzen' function does not
|
||||||
-- serve your purpose.
|
-- serve your purpose.
|
||||||
--
|
--
|
||||||
dzenWithFlags :: LayoutClass l Window
|
dzenWithFlags :: (LayoutClass l Window
|
||||||
|
,Read (l Window))
|
||||||
=> String -- ^ Flags to give to @dzen@
|
=> String -- ^ Flags to give to @dzen@
|
||||||
-> XConfig l -- ^ The base config
|
-> XConfig l -- ^ The base config
|
||||||
-> IO (XConfig (ModifiedLayout AvoidStruts l))
|
-> IO (XConfig (ModifiedLayout AvoidStruts l))
|
||||||
@@ -170,7 +171,8 @@ dzenWithFlags flags = statusBar ("dzen2 " ++ flags) dzenPP toggleStrutsKey
|
|||||||
--
|
--
|
||||||
-- This works pretty much the same as the 'xmobar' function.
|
-- This works pretty much the same as the 'xmobar' function.
|
||||||
--
|
--
|
||||||
dzen :: LayoutClass l Window
|
dzen :: (LayoutClass l Window
|
||||||
|
,Read (l Window))
|
||||||
=> XConfig l -- ^ The base config
|
=> XConfig l -- ^ The base config
|
||||||
-> IO (XConfig (ModifiedLayout AvoidStruts l))
|
-> IO (XConfig (ModifiedLayout AvoidStruts l))
|
||||||
dzen = dzenWithFlags flags
|
dzen = dzenWithFlags flags
|
||||||
@@ -181,7 +183,8 @@ dzen = dzenWithFlags flags
|
|||||||
|
|
||||||
-- | This function works like 'xmobarProp', but uses pipes instead of
|
-- | This function works like 'xmobarProp', but uses pipes instead of
|
||||||
-- property-based logging.
|
-- property-based logging.
|
||||||
xmobar :: LayoutClass l Window
|
xmobar :: (LayoutClass l Window
|
||||||
|
,Read (l Window))
|
||||||
=> XConfig l -- ^ The base config
|
=> XConfig l -- ^ The base config
|
||||||
-> IO (XConfig (ModifiedLayout AvoidStruts l))
|
-> IO (XConfig (ModifiedLayout AvoidStruts l))
|
||||||
xmobar = statusBar "xmobar" xmobarPP toggleStrutsKey
|
xmobar = statusBar "xmobar" xmobarPP toggleStrutsKey
|
||||||
@@ -189,7 +192,8 @@ xmobar = statusBar "xmobar" xmobarPP toggleStrutsKey
|
|||||||
-- | Like 'statusBarProp', but uses pipes instead of property-based logging.
|
-- | Like 'statusBarProp', but uses pipes instead of property-based logging.
|
||||||
-- Only use this function if your status bar does not support reading from a
|
-- Only use this function if your status bar does not support reading from a
|
||||||
-- property of the root window.
|
-- property of the root window.
|
||||||
statusBar :: LayoutClass l Window
|
statusBar :: (LayoutClass l Window
|
||||||
|
,Read (l Window))
|
||||||
=> String -- ^ The command line to launch the status bar
|
=> String -- ^ The command line to launch the status bar
|
||||||
-> PP -- ^ The pretty printing options
|
-> PP -- ^ The pretty printing options
|
||||||
-> (XConfig Layout -> (KeyMask, KeySym))
|
-> (XConfig Layout -> (KeyMask, KeySym))
|
||||||
@@ -258,7 +262,8 @@ dynamicLogXinerama = withWindowSet $ io . putStrLn . pprWindowSetXinerama
|
|||||||
-- The binding uses the "XMonad.Hooks.ManageDocks" module to automatically
|
-- The binding uses the "XMonad.Hooks.ManageDocks" module to automatically
|
||||||
-- handle screen placement for xmobar, and enables 'mod-b' for toggling
|
-- handle screen placement for xmobar, and enables 'mod-b' for toggling
|
||||||
-- the menu bar.
|
-- the menu bar.
|
||||||
xmobarProp :: LayoutClass l Window
|
xmobarProp :: (LayoutClass l Window
|
||||||
|
,Read (l Window))
|
||||||
=> XConfig l -- ^ The base config
|
=> XConfig l -- ^ The base config
|
||||||
-> XConfig (ModifiedLayout AvoidStruts l)
|
-> XConfig (ModifiedLayout AvoidStruts l)
|
||||||
xmobarProp =
|
xmobarProp =
|
||||||
|
@@ -275,7 +275,8 @@ withSB (StatusBarConfig lh sh ch) conf = conf
|
|||||||
-- Using this function multiple times to combine status bars may result in
|
-- Using this function multiple times to combine status bars may result in
|
||||||
-- only one status bar working properly. See the section on using multiple
|
-- only one status bar working properly. See the section on using multiple
|
||||||
-- status bars for more details.
|
-- status bars for more details.
|
||||||
withEasySB :: LayoutClass l Window
|
withEasySB :: (LayoutClass l Window
|
||||||
|
,Read (l Window))
|
||||||
=> StatusBarConfig -- ^ The status bar config
|
=> StatusBarConfig -- ^ The status bar config
|
||||||
-> (XConfig Layout -> (KeyMask, KeySym))
|
-> (XConfig Layout -> (KeyMask, KeySym))
|
||||||
-- ^ The key binding
|
-- ^ The key binding
|
||||||
@@ -285,7 +286,18 @@ withEasySB sb k conf = docks . withSB sb $ conf
|
|||||||
{ layoutHook = avoidStruts (layoutHook conf)
|
{ layoutHook = avoidStruts (layoutHook conf)
|
||||||
, keys = (<>) <$> keys' <*> keys conf
|
, keys = (<>) <$> keys' <*> keys conf
|
||||||
}
|
}
|
||||||
where keys' = (`M.singleton` sendMessage ToggleStruts) . k
|
where
|
||||||
|
-- This usually means the user passed 'def' for the keybinding
|
||||||
|
-- function, and is otherwise meaningless to harmful depending on
|
||||||
|
-- whether 383ffb7 has been applied to xmonad or not. So do what
|
||||||
|
-- they probably intend.
|
||||||
|
--
|
||||||
|
-- A user who wants no keybinding function should probably use
|
||||||
|
-- 'withSB' instead, especially since NoSymbol didn't do anything
|
||||||
|
-- sane before 383ffb7. ++bsa
|
||||||
|
k' | k conf {layoutHook = Layout (layoutHook conf)} == (0,0) = defToggleStrutsKey
|
||||||
|
| otherwise = k
|
||||||
|
keys' = (`M.singleton` sendMessage ToggleStruts) . k'
|
||||||
|
|
||||||
-- | Default @mod-b@ key binding for 'withEasySB'
|
-- | Default @mod-b@ key binding for 'withEasySB'
|
||||||
defToggleStrutsKey :: XConfig t -> (KeyMask, KeySym)
|
defToggleStrutsKey :: XConfig t -> (KeyMask, KeySym)
|
||||||
|
Reference in New Issue
Block a user