aboutsummaryrefslogtreecommitdiffstats
path: root/Maximize.hs
diff options
context:
space:
mode:
authorJamie Webb <gentoo-haskell@vcs.intern>2007-10-04 08:12:02 +0200
committerJamie Webb <gentoo-haskell@vcs.intern>2007-10-04 08:12:02 +0200
commit4a7fbb95609ed14c39961b79e7579822e916995c (patch)
tree47aa38d212007a87a6efc5b6240b417c73f720e7 /Maximize.hs
parent73472e541d5268d46341264bbd0ef05fd1951cac (diff)
downloadXMonadContrib-4a7fbb95609ed14c39961b79e7579822e916995c.tar.gz
XMonadContrib-4a7fbb95609ed14c39961b79e7579822e916995c.tar.xz
XMonadContrib-4a7fbb95609ed14c39961b79e7579822e916995c.zip
Maximize layout modifier
darcs-hash:20071004061202-74a73-0a04ff619bbda89563c2511bd4b43120d6e70a99.gz
Diffstat (limited to 'Maximize.hs')
-rw-r--r--Maximize.hs72
1 files changed, 72 insertions, 0 deletions
diff --git a/Maximize.hs b/Maximize.hs
new file mode 100644
index 0000000..2322c54
--- /dev/null
+++ b/Maximize.hs
@@ -0,0 +1,72 @@
+{-# LANGUAGE FlexibleInstances #-}
+
+-----------------------------------------------------------------------------
+-- |
+-- Module : XMonadContrib.Maximize
+-- Copyright : (c) 2007 James Webb
+-- License : BSD3-style (see LICENSE)
+--
+-- Maintainer : xmonad#jwebb,sygneca,com
+-- Stability : unstable
+-- Portability : unportable
+--
+-- Temporarily yanks the focused window out of the layout to mostly fill
+-- the screen.
+--
+-----------------------------------------------------------------------------
+
+module XMonadContrib.Maximize (
+ -- * Usage
+ -- $usage
+ maximize,
+ maximizeRestore
+ ) where
+
+import Graphics.X11.Xlib
+import XMonad
+import XMonadContrib.LayoutModifier
+import Data.List ( partition )
+
+-- $usage
+-- You can use this module with the following in your Config.hs file:
+--
+-- > import XMonadContrib.Maximize
+--
+-- > defaultLayouts = ...
+-- > , Layout $ maximize $ myLayout ...
+-- > ...
+--
+-- > keys = ...
+-- > , ((modMask, xK_backslash), withFocused (sendMessage . maximizeRestore))
+-- > ...
+
+-- %import XMonadContrib.Maximize
+-- %layout , Layout $ maximize $ myLayout
+
+data Maximize a = Maximize (Maybe Window) deriving ( Read, Show )
+maximize :: LayoutClass l Window => l Window -> ModifiedLayout Maximize l Window
+maximize = ModifiedLayout $ Maximize Nothing
+
+data MaximizeRestore = MaximizeRestore Window deriving ( Typeable, Eq )
+instance Message MaximizeRestore
+maximizeRestore :: Window -> MaximizeRestore
+maximizeRestore = MaximizeRestore
+
+instance LayoutModifier Maximize Window where
+ modifierDescription (Maximize _) = "Maximize"
+ redoLayout (Maximize mw) rect _ wrs = case mw of
+ Just win ->
+ return (maxed ++ rest, Nothing)
+ where
+ maxed = map (\(w, _) -> (w, maxRect)) toMax
+ (toMax, rest) = partition (\(w, _) -> w == win) wrs
+ maxRect = Rectangle (rect_x rect + 50) (rect_y rect + 50)
+ (rect_width rect - 100) (rect_height rect - 100)
+ Nothing -> return (wrs, Nothing)
+ handleMess (Maximize mw) m = case fromMessage m of
+ Just (MaximizeRestore w) -> case mw of
+ Just _ -> return $ Just $ Maximize Nothing
+ Nothing -> return $ Just $ Maximize $ Just w
+ _ -> return Nothing
+
+-- vim: sw=4:et