mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
add Eq superclass to DecorationStyle and change styles in order not to decorate non managed windows
This commit is contained in:
parent
651acdbc3e
commit
cf4bd0a225
@ -98,7 +98,7 @@ data Decoration ds s a =
|
|||||||
Decoration (Invisible Maybe DecorationState) s Theme (ds a)
|
Decoration (Invisible Maybe DecorationState) s Theme (ds a)
|
||||||
deriving (Show, Read)
|
deriving (Show, Read)
|
||||||
|
|
||||||
class (Read (ds a), Show (ds a)) => DecorationStyle ds a where
|
class (Read (ds a), Show (ds a), Eq a) => DecorationStyle ds a where
|
||||||
describeDeco :: ds a -> String
|
describeDeco :: ds a -> String
|
||||||
describeDeco ds = show ds
|
describeDeco ds = show ds
|
||||||
|
|
||||||
@ -120,14 +120,17 @@ class (Read (ds a), Show (ds a)) => DecorationStyle ds a where
|
|||||||
|
|
||||||
pureDecoration :: ds a -> Dimension -> Dimension -> Rectangle
|
pureDecoration :: ds a -> Dimension -> Dimension -> Rectangle
|
||||||
-> W.Stack a -> [(a,Rectangle)] -> (a,Rectangle) -> Maybe Rectangle
|
-> W.Stack a -> [(a,Rectangle)] -> (a,Rectangle) -> Maybe Rectangle
|
||||||
pureDecoration _ _ h _ _ _ (_,Rectangle x y w _) = Just $ Rectangle x y w h
|
pureDecoration _ _ ht _ s _ (w,Rectangle x y wh _) = if isInStack s w
|
||||||
|
then Just $ Rectangle x y wh ht
|
||||||
|
else Nothing
|
||||||
|
|
||||||
|
|
||||||
decorate :: ds a -> Dimension -> Dimension -> Rectangle
|
decorate :: ds a -> Dimension -> Dimension -> Rectangle
|
||||||
-> W.Stack a -> [(a,Rectangle)] -> (a,Rectangle) -> X (Maybe Rectangle)
|
-> W.Stack a -> [(a,Rectangle)] -> (a,Rectangle) -> X (Maybe Rectangle)
|
||||||
decorate ds w h r s ars ar = return $ pureDecoration ds w h r s ars ar
|
decorate ds w h r s ars ar = return $ pureDecoration ds w h r s ars ar
|
||||||
|
|
||||||
data DefaultDecoration a = DefaultDecoration deriving ( Read, Show )
|
data DefaultDecoration a = DefaultDecoration deriving ( Read, Show )
|
||||||
instance DecorationStyle DefaultDecoration a
|
instance Eq a => DecorationStyle DefaultDecoration a
|
||||||
|
|
||||||
instance (DecorationStyle ds Window, Shrinker s) => LayoutModifier (Decoration ds s) Window where
|
instance (DecorationStyle ds Window, Shrinker s) => LayoutModifier (Decoration ds s) Window where
|
||||||
redoLayout (Decoration st sh t ds) sc stack wrs
|
redoLayout (Decoration st sh t ds) sc stack wrs
|
||||||
|
@ -84,6 +84,7 @@ module XMonad.Layout.DecorationMadness
|
|||||||
, floatSimpleTabbed
|
, floatSimpleTabbed
|
||||||
, floatTabbed
|
, floatTabbed
|
||||||
, defaultTheme, shrinkText
|
, defaultTheme, shrinkText
|
||||||
|
, SimpleTabbedDecoration (..)
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.List
|
import Data.List
|
||||||
@ -146,7 +147,8 @@ instance Eq a => DecorationStyle SimpleTabbedDecoration a where
|
|||||||
decorateFirst _ = True
|
decorateFirst _ = True
|
||||||
shrink _ _ r = r
|
shrink _ _ r = r
|
||||||
decorationMouseDragHook _ _ _ = return ()
|
decorationMouseDragHook _ _ _ = return ()
|
||||||
pureDecoration _ _ ht (Rectangle x y wh _) s wrs (w,_) = Just $ Rectangle nx y nwh (fi ht)
|
pureDecoration _ _ ht (Rectangle x y wh _) s wrs (w,_) =
|
||||||
|
if isInStack s w then Just $ Rectangle nx y nwh (fi ht) else Nothing
|
||||||
where nwh = wh `div` max 1 (fi $ length wrs)
|
where nwh = wh `div` max 1 (fi $ length wrs)
|
||||||
nx = case w `elemIndex` (S.integrate s) of
|
nx = case w `elemIndex` (S.integrate s) of
|
||||||
Just i -> x + (fi nwh * fi i)
|
Just i -> x + (fi nwh * fi i)
|
||||||
@ -561,11 +563,11 @@ mirrorTallTabbed s t = decoration s t SimpleTabbed (resizeVertical (fi $ decoHei
|
|||||||
-- Here you can find a screen shot:
|
-- Here you can find a screen shot:
|
||||||
--
|
--
|
||||||
-- <http://code.haskell.org/~arossato/xmonadShots/floatSimpleSimple.png>
|
-- <http://code.haskell.org/~arossato/xmonadShots/floatSimpleSimple.png>
|
||||||
floatSimpleSimple :: ModifiedLayout (Decoration SimpleDecoration DefaultShrinker)
|
floatSimpleSimple :: Eq a => ModifiedLayout (Decoration SimpleDecoration DefaultShrinker)
|
||||||
(ModifiedLayout MouseResize (ModifiedLayout WindowArranger SimpleFloat)) a
|
(ModifiedLayout MouseResize (ModifiedLayout WindowArranger SimpleFloat)) a
|
||||||
floatSimpleSimple = simpleFloat
|
floatSimpleSimple = simpleFloat
|
||||||
|
|
||||||
floatSimple :: Shrinker s => s -> Theme ->
|
floatSimple :: (Eq a, Shrinker s) => s -> Theme ->
|
||||||
ModifiedLayout (Decoration SimpleDecoration s)
|
ModifiedLayout (Decoration SimpleDecoration s)
|
||||||
(ModifiedLayout MouseResize (ModifiedLayout WindowArranger SimpleFloat)) a
|
(ModifiedLayout MouseResize (ModifiedLayout WindowArranger SimpleFloat)) a
|
||||||
floatSimple = simpleFloat'
|
floatSimple = simpleFloat'
|
||||||
@ -575,13 +577,13 @@ floatSimple = simpleFloat'
|
|||||||
-- Here you can find a screen shot:
|
-- Here you can find a screen shot:
|
||||||
--
|
--
|
||||||
-- <http://code.haskell.org/~arossato/xmonadShots/floatSimpleDefault.png>
|
-- <http://code.haskell.org/~arossato/xmonadShots/floatSimpleDefault.png>
|
||||||
floatSimpleDefault :: ModifiedLayout (Decoration DefaultDecoration DefaultShrinker)
|
floatSimpleDefault :: Eq a => ModifiedLayout (Decoration DefaultDecoration DefaultShrinker)
|
||||||
(ModifiedLayout MouseResize (ModifiedLayout WindowArranger SimpleFloat)) a
|
(ModifiedLayout MouseResize (ModifiedLayout WindowArranger SimpleFloat)) a
|
||||||
floatSimpleDefault = decoration shrinkText defaultTheme DefaultDecoration (mouseResize $ windowArrangeAll $ SF 20)
|
floatSimpleDefault = decoration shrinkText defaultTheme DefaultDecoration (mouseResize $ windowArrangeAll $ SF 20)
|
||||||
|
|
||||||
-- | Same as 'floatSimpleDefault', but with the possibility of setting a
|
-- | Same as 'floatSimpleDefault', but with the possibility of setting a
|
||||||
-- custom shrinker and a custom theme.
|
-- custom shrinker and a custom theme.
|
||||||
floatDefault :: Shrinker s => s -> Theme ->
|
floatDefault :: (Eq a, Shrinker s) => s -> Theme ->
|
||||||
ModifiedLayout (Decoration DefaultDecoration s)
|
ModifiedLayout (Decoration DefaultDecoration s)
|
||||||
(ModifiedLayout MouseResize (ModifiedLayout WindowArranger SimpleFloat)) a
|
(ModifiedLayout MouseResize (ModifiedLayout WindowArranger SimpleFloat)) a
|
||||||
floatDefault s c = decoration s c DefaultDecoration (mouseResize $ windowArrangeAll $ SF (decoHeight c))
|
floatDefault s c = decoration s c DefaultDecoration (mouseResize $ windowArrangeAll $ SF (decoHeight c))
|
||||||
|
@ -62,7 +62,7 @@ data DwmStyle a = Dwm deriving (Show, Read)
|
|||||||
instance Eq a => DecorationStyle DwmStyle a where
|
instance Eq a => DecorationStyle DwmStyle a where
|
||||||
describeDeco _ = "DwmStyle"
|
describeDeco _ = "DwmStyle"
|
||||||
shrink _ _ r = r
|
shrink _ _ r = r
|
||||||
pureDecoration _ wh ht _ (Stack fw _ _) _ (win,Rectangle x y wid _) =
|
pureDecoration _ wh ht _ s@(Stack fw _ _) _ (w,Rectangle x y wid _) =
|
||||||
if win == fw then Nothing else Just $ Rectangle (fi nx) y nwh (fi ht)
|
if w == fw || not (isInStack s w) then Nothing else Just $ Rectangle (fi nx) y nwh (fi ht)
|
||||||
where nwh = min wid $ fi wh
|
where nwh = min wid $ fi wh
|
||||||
nx = fi x + wid - nwh
|
nx = fi x + wid - nwh
|
||||||
|
@ -53,16 +53,20 @@ import XMonad.Layout.Decoration
|
|||||||
-- > myL = dwmStyle shrinkText mySDConfig (layoutHook defaultTheme)
|
-- > myL = dwmStyle shrinkText mySDConfig (layoutHook defaultTheme)
|
||||||
|
|
||||||
-- | Add simple decorations to windows of a layout.
|
-- | Add simple decorations to windows of a layout.
|
||||||
simpleDeco :: Shrinker s => s -> Theme
|
simpleDeco :: (Eq a, Shrinker s) => s -> Theme
|
||||||
-> l a -> ModifiedLayout (Decoration SimpleDecoration s) l a
|
-> l a -> ModifiedLayout (Decoration SimpleDecoration s) l a
|
||||||
simpleDeco s c = decoration s c $ Simple True
|
simpleDeco s c = decoration s c $ Simple True
|
||||||
|
|
||||||
data SimpleDecoration a = Simple Bool deriving (Show, Read)
|
data SimpleDecoration a = Simple Bool deriving (Show, Read)
|
||||||
|
|
||||||
instance DecorationStyle SimpleDecoration a where
|
instance Eq a => DecorationStyle SimpleDecoration a where
|
||||||
describeDeco _ = "Simple"
|
describeDeco _ = "Simple"
|
||||||
shrink (Simple b) (Rectangle _ _ _ dh) r@(Rectangle x y w h) =
|
shrink (Simple b) (Rectangle _ _ _ dh) r@(Rectangle x y w h) =
|
||||||
if b then Rectangle x (y + fi dh) w (h - dh) else r
|
if b then Rectangle x (y + fi dh) w (h - dh) else r
|
||||||
pureDecoration (Simple b) wh ht _ _ _ (_,Rectangle x y wid _) =
|
pureDecoration (Simple b) wh ht _ s _ (w,Rectangle x y wid _) =
|
||||||
if b then Just $ Rectangle x y nwh ht else Just $ Rectangle x (y - fi ht) nwh ht
|
if isInStack s w
|
||||||
|
then if b
|
||||||
|
then Just $ Rectangle x y nwh ht
|
||||||
|
else Just $ Rectangle x (y - fi ht) nwh ht
|
||||||
|
else Nothing
|
||||||
where nwh = min wid wh
|
where nwh = min wid wh
|
||||||
|
@ -49,13 +49,13 @@ import XMonad.Layout.WindowArranger
|
|||||||
-- to the window's initial attributes.
|
-- to the window's initial attributes.
|
||||||
--
|
--
|
||||||
-- This version is decorated with the 'SimpleDecoration' style.
|
-- This version is decorated with the 'SimpleDecoration' style.
|
||||||
simpleFloat :: ModifiedLayout (Decoration SimpleDecoration DefaultShrinker)
|
simpleFloat :: Eq a => ModifiedLayout (Decoration SimpleDecoration DefaultShrinker)
|
||||||
(ModifiedLayout MouseResize (ModifiedLayout WindowArranger SimpleFloat)) a
|
(ModifiedLayout MouseResize (ModifiedLayout WindowArranger SimpleFloat)) a
|
||||||
simpleFloat = decoration shrinkText defaultTheme (Simple False) (mouseResize $ windowArrangeAll $ SF 20)
|
simpleFloat = decoration shrinkText defaultTheme (Simple False) (mouseResize $ windowArrangeAll $ SF 20)
|
||||||
|
|
||||||
-- | Same as 'simpleFloat', but with the possibility of setting a
|
-- | Same as 'simpleFloat', but with the possibility of setting a
|
||||||
-- custom shrinker and a custom theme.
|
-- custom shrinker and a custom theme.
|
||||||
simpleFloat' :: Shrinker s => s -> Theme ->
|
simpleFloat' :: (Eq a, Shrinker s) => s -> Theme ->
|
||||||
ModifiedLayout (Decoration SimpleDecoration s)
|
ModifiedLayout (Decoration SimpleDecoration s)
|
||||||
(ModifiedLayout MouseResize (ModifiedLayout WindowArranger SimpleFloat)) a
|
(ModifiedLayout MouseResize (ModifiedLayout WindowArranger SimpleFloat)) a
|
||||||
simpleFloat' s c = decoration s c (Simple False) (mouseResize $ windowArrangeAll $ SF (decoHeight c))
|
simpleFloat' s c = decoration s c (Simple False) (mouseResize $ windowArrangeAll $ SF (decoHeight c))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user