diff options
author | Jan Vornberger <jan.vornberger@informatik.uni-oldenburg.de> | 2009-09-30 17:53:43 +0200 |
---|---|---|
committer | Jan Vornberger <jan.vornberger@informatik.uni-oldenburg.de> | 2009-09-30 17:53:43 +0200 |
commit | 38b76e9c25a1203b82af19b13c6275003fa12ac3 (patch) | |
tree | b82227ed9e1028701beb4142145b43ee7702762e /XMonad/Actions | |
parent | c291f252c6659a13b3075d711ff3e86ac559e757 (diff) | |
download | XMonadContrib-38b76e9c25a1203b82af19b13c6275003fa12ac3.tar.gz XMonadContrib-38b76e9c25a1203b82af19b13c6275003fa12ac3.tar.xz XMonadContrib-38b76e9c25a1203b82af19b13c6275003fa12ac3.zip |
WindowMenu based on GridSelect that displays actions for the focused window (re-recorded from Bluetile repo).
Ignore-this: b12a06c0321f3e9689ab8109a1fac0ac
darcs-hash:20090930155343-594c5-99907dad481917c83083ce8d30f6debb64f8938d.gz
Diffstat (limited to 'XMonad/Actions')
-rw-r--r-- | XMonad/Actions/WindowMenu.hs | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/XMonad/Actions/WindowMenu.hs b/XMonad/Actions/WindowMenu.hs new file mode 100644 index 0000000..6183c35 --- /dev/null +++ b/XMonad/Actions/WindowMenu.hs @@ -0,0 +1,75 @@ +---------------------------------------------------------------------------- +-- | +-- Module : XMonad.Actions.WindowMenu +-- Copyright : (c) Jan Vornberger 2009 +-- License : BSD3-style (see LICENSE) +-- +-- Maintainer : jan.vornberger@informatik.uni-oldenburg.de +-- Stability : unstable +-- Portability : not portable +-- +-- Uses XMonad.Actions.GridSelect to display a number of actions related to +-- window management in the center of the focused window. Actions include: Closing, +-- maximizing, minimizing and shifting the window to another workspace. +-- +----------------------------------------------------------------------------- + +module XMonad.Actions.WindowMenu ( + -- * Usage + -- $usage + windowMenu + ) where + +import XMonad +import qualified XMonad.StackSet as W +import XMonad.Actions.GridSelect +import XMonad.Layout.Maximize +import XMonad.Layout.Minimize + +-- $usage +-- +-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: +-- +-- > import XMonad.Actions.WindowMenu +-- +-- Then add a keybinding, e.g. +-- +-- > , ((modMask x, xK_o ), windowMenu) + +simpleColorizer :: (Monad m) => t -> t -> t1 -> Bool -> m (t, [Char]) +simpleColorizer nBC _ _ False = return (nBC, "black") +simpleColorizer _ fBC _ True = return (fBC, "black") + +windowMenu :: X () +windowMenu = withFocused $ \w -> do + nBC <- asks (normalBorderColor . config) + fBC <- asks (focusedBorderColor . config) + tags <- asks (workspaces . config) + Rectangle x y wh ht <- getSize w + Rectangle sx sy swh sht <- gets $ screenRect . W.screenDetail . W.current . windowset + let originFractX = (fromIntegral x - fromIntegral sx + (fromIntegral wh / 2)) + / fromIntegral swh + originFractY = (fromIntegral y -fromIntegral sy + (fromIntegral ht / 2)) + / fromIntegral sht + colorizer = simpleColorizer nBC fBC + gsConfig = buildDefaultGSConfig colorizer + gsConfig' = gsConfig { gs_originFractX = originFractX, + gs_originFractY = originFractY } + actions = [ ("Cancel menu", return ()) + , ("Close" , kill) + , ("Maximize" , sendMessage $ maximizeRestore w) + , ("Minimize" , sendMessage $ MinimizeWin w) + ] ++ + [ ("Move to " ++ tag, windows $ W.shift tag) + | tag <- tags ] + runSelectedAction gsConfig' actions + +getSize :: Window -> X (Rectangle) +getSize w = do + d <- asks display + wa <- io $ getWindowAttributes d w + let x = fromIntegral $ wa_x wa + y = fromIntegral $ wa_y wa + wh = fromIntegral $ wa_width wa + ht = fromIntegral $ wa_height wa + return (Rectangle x y wh ht) |