mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-07-30 03:31:51 -07:00
X.C.Desktop: Add type signatures
When we applied hlint hints inbd5b969d9b
, the definition of desktopLayoutModifiers got (via the hint to eta reduce) changed from desktopLayoutModifiers layout = avoidStruts layout to desktopLayoutModifiers = avoidStruts While the former is general enough to infer the type signature LayoutClass l a => l a -> ModifiedLayout AvoidStruts l a the latter just sees the usage site of , layoutHook = desktopLayoutModifiers $ layoutHook def in the desktopConfig function and thus—through the magic of MonomorphismRestriction—infers the specialized type Choose Tall (Choose (Mirror Tall) Full) Window -> ModifiedLayout AvoidStruts (Choose Tall (Choose (Mirror Tall) Full)) Window This obviously completely falls apart once someone wants to change the layout and still uses desktopLayoutModifiers (unaware that it is just avoidStruts at the moment). The easy fix is to give things type signatures, so nothing needs to be inferred. The _actual_ solution would be, in my opinion, to completely deprecate X.C.Desktop and remove it in a future release, as well as to completely rewrite the provided Example.hs. This needs more deliberation though. Fixes: https://github.com/xmonad/xmonad-contrib/issues/560 Related:bd5b969d9b
This commit is contained in:
@@ -57,6 +57,7 @@ module XMonad.Config.Desktop (
|
|||||||
import XMonad
|
import XMonad
|
||||||
import XMonad.Hooks.ManageDocks
|
import XMonad.Hooks.ManageDocks
|
||||||
import XMonad.Hooks.EwmhDesktops
|
import XMonad.Hooks.EwmhDesktops
|
||||||
|
import XMonad.Layout.LayoutModifier (ModifiedLayout)
|
||||||
import XMonad.Util.Cursor
|
import XMonad.Util.Cursor
|
||||||
import qualified XMonad.StackSet as W
|
import qualified XMonad.StackSet as W
|
||||||
|
|
||||||
@@ -165,19 +166,22 @@ import qualified Data.Map as M
|
|||||||
-- > adjustEventInput
|
-- > adjustEventInput
|
||||||
--
|
--
|
||||||
|
|
||||||
|
desktopConfig :: XConfig (ModifiedLayout AvoidStruts
|
||||||
|
(Choose Tall (Choose (Mirror Tall) Full)))
|
||||||
desktopConfig = docks $ ewmh def
|
desktopConfig = docks $ ewmh def
|
||||||
{ startupHook = setDefaultCursor xC_left_ptr <+> startupHook def
|
{ startupHook = setDefaultCursor xC_left_ptr <+> startupHook def
|
||||||
, layoutHook = desktopLayoutModifiers $ layoutHook def
|
, layoutHook = desktopLayoutModifiers $ layoutHook def
|
||||||
, logHook = desktopLogHook <+> logHook def
|
, logHook = desktopLogHook <+> logHook def
|
||||||
, keys = desktopKeys <+> keys def }
|
, keys = desktopKeys <+> keys def }
|
||||||
|
|
||||||
|
desktopKeys :: XConfig l -> M.Map (KeyMask, KeySym) (X ())
|
||||||
desktopKeys XConfig{modMask = modm} = M.fromList
|
desktopKeys XConfig{modMask = modm} = M.fromList
|
||||||
[ ((modm, xK_b), sendMessage ToggleStruts) ]
|
[ ((modm, xK_b), sendMessage ToggleStruts) ]
|
||||||
|
|
||||||
|
desktopLayoutModifiers :: LayoutClass l a => l a -> ModifiedLayout AvoidStruts l a
|
||||||
desktopLayoutModifiers = avoidStruts
|
desktopLayoutModifiers = avoidStruts
|
||||||
|
|
||||||
-- | 'logHook' preserving old 'ewmh' behavior to switch workspace and focus to
|
-- | 'logHook' preserving old 'ewmh' behavior to switch workspace and focus to
|
||||||
-- activated window.
|
-- activated window.
|
||||||
desktopLogHook :: X ()
|
desktopLogHook :: X ()
|
||||||
desktopLogHook = activateLogHook (reader W.focusWindow >>= doF)
|
desktopLogHook = activateLogHook (reader W.focusWindow >>= doF)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user