mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
This removes the emptyLayoutMod method from the LayoutModifier class, and change the Stack parameter to redoLayout to a Maybe Stack one. It also changes all affected code. This should should be a refactoring without any change in program behaviour.
58 lines
1.8 KiB
Haskell
58 lines
1.8 KiB
Haskell
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, TypeSynonymInstances #-}
|
|
|
|
-----------------------------------------------------------------------------
|
|
-- |
|
|
-- Module : XMonad.Layout.LayoutHints
|
|
-- Copyright : (c) David Roundy <droundy@darcs.net>
|
|
-- License : BSD
|
|
--
|
|
-- Maintainer : none
|
|
-- Stability : unstable
|
|
-- Portability : portable
|
|
--
|
|
-- Make layouts respect size hints.
|
|
-----------------------------------------------------------------------------
|
|
|
|
module XMonad.Layout.LayoutHints
|
|
( -- * usage
|
|
-- $usage
|
|
layoutHints
|
|
, LayoutHints
|
|
) where
|
|
|
|
import XMonad hiding ( trace )
|
|
import XMonad.Layout.LayoutModifier
|
|
import XMonad.Layout.Decoration ( isInStack )
|
|
|
|
-- $usage
|
|
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
|
--
|
|
-- > import XMonad.Layout.LayoutHints
|
|
--
|
|
-- Then edit your @layoutHook@ by adding the LayoutHints layout modifier
|
|
-- to some layout:
|
|
--
|
|
-- > myLayouts = layoutHints (Tall 1 (3/100) (1/2)) ||| Full ||| etc..
|
|
-- > main = xmonad defaultConfig { layoutHook = myLayouts }
|
|
--
|
|
-- For more detailed instructions on editing the layoutHook see:
|
|
--
|
|
-- "XMonad.Doc.Extending#Editing_the_layout_hook"
|
|
|
|
layoutHints :: (LayoutClass l a) => l a -> ModifiedLayout LayoutHints l a
|
|
layoutHints = ModifiedLayout LayoutHints
|
|
|
|
data LayoutHints a = LayoutHints deriving (Read, Show)
|
|
|
|
instance LayoutModifier LayoutHints Window where
|
|
modifierDescription _ = "Hinted"
|
|
redoLayout _ _ Nothing xs = return (xs, Nothing)
|
|
redoLayout _ _ (Just s) xs = do
|
|
xs' <- mapM applyHint xs
|
|
return (xs', Nothing)
|
|
where
|
|
applyHint (w,r@(Rectangle a b c d)) = do
|
|
adj <- mkAdjust w
|
|
let (c',d') = adj (c,d)
|
|
return (w, if isInStack s w then Rectangle a b c' d' else r)
|