aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Actions/CopyWindow.hs
diff options
context:
space:
mode:
authorIvan N. Veselov <veselov@gmail.com>2008-04-08 21:51:11 +0200
committerIvan N. Veselov <veselov@gmail.com>2008-04-08 21:51:11 +0200
commit219295d64e15758d47f06eb6da5734687081c829 (patch)
tree535a2042798b6d1c085486b68bb871304c76ef4c /XMonad/Actions/CopyWindow.hs
parentd118496fa75c8a3556d5f9ba206ca13393efcc3b (diff)
downloadXMonadContrib-219295d64e15758d47f06eb6da5734687081c829.tar.gz
XMonadContrib-219295d64e15758d47f06eb6da5734687081c829.tar.xz
XMonadContrib-219295d64e15758d47f06eb6da5734687081c829.zip
XMonad.Actions.CopyWindow: added copyToAll and killAllOtherCopies functions
darcs-hash:20080408195111-98257-fa939d0b1d9fad8212e9051443451f133488bbc5.gz
Diffstat (limited to 'XMonad/Actions/CopyWindow.hs')
-rw-r--r--XMonad/Actions/CopyWindow.hs39
1 files changed, 35 insertions, 4 deletions
diff --git a/XMonad/Actions/CopyWindow.hs b/XMonad/Actions/CopyWindow.hs
index 1104bcf..1fcbdb3 100644
--- a/XMonad/Actions/CopyWindow.hs
+++ b/XMonad/Actions/CopyWindow.hs
@@ -2,7 +2,7 @@
-----------------------------------------------------------------------------
-- |
-- Module : XMonad.Actions.CopyWindow
--- Copyright : (c) David Roundy <droundy@darcs.net>
+-- Copyright : (c) David Roundy <droundy@darcs.net>, Ivan Veselov <veselov@gmail.com>
-- License : BSD3-style (see LICENSE)
--
-- Maintainer : David Roundy <droundy@darcs.net>
@@ -17,12 +17,12 @@
module XMonad.Actions.CopyWindow (
-- * Usage
-- $usage
- copy, copyWindow, kill1
+ copy, copyToAll, copyWindow, killAllOtherCopies, kill1
) where
-import Prelude hiding ( filter )
+import Prelude hiding (filter)
import qualified Data.List as L
-import XMonad hiding (modify)
+import XMonad hiding (modify, workspaces)
import XMonad.StackSet
-- $usage
@@ -50,6 +50,17 @@ import XMonad.StackSet
--
-- > , ((modMask x .|. shiftMask, xK_c ), kill1) -- @@ Close the focused window
--
+-- Another possibility which this extension provides is 'making window
+-- always visible' (i.e. always on current workspace), similar to corresponding
+-- metacity functionality. This behaviour is emulated through copying given
+-- window to all the workspaces and then removing it when it's unneeded on
+-- all workspaces any more.
+--
+-- Here is the example of keybindings which provide these actions:
+--
+-- > , ((modMask x, xK_v )", windows copyToAll) -- @@ Make focused window always visible
+-- > , ((modMask x .|. shiftMask, xK_v ), killAllOtherCopies) -- @@ Toggle window state back
+--
-- For detailed instructions on editing your key bindings, see
-- "XMonad.Doc.Extending#Editing_key_bindings".
@@ -58,6 +69,10 @@ copy :: WorkspaceId -> WindowSet -> WindowSet
copy n s | Just w <- peek s = copyWindow w n s
| otherwise = s
+-- | copyToAll. Copy the focused window to all of workspaces.
+copyToAll :: WindowSet -> WindowSet
+copyToAll s = foldr ($) s $ map (copy . tag) (workspaces s)
+
-- | copyWindow. Copy a window to a new workspace
copyWindow :: Window -> WorkspaceId -> WindowSet -> WindowSet
copyWindow w n = copy'
@@ -83,3 +98,19 @@ kill1 = do ss <- gets windowset
then windows $ delete'' w
else kill
where delete'' w = modify Nothing (filter (/= w))
+
+-- | Kill all other copies of focused window (if they're present)
+-- 'All other' means here 'copies, which are not on current workspace'
+--
+-- Consider calling this function after copyToAll
+--
+killAllOtherCopies :: X ()
+killAllOtherCopies = do ss <- gets windowset
+ whenJust (peek ss) $ \w -> windows $
+ view (tag (workspace (current ss))) .
+ delFromAllButCurrent w
+ where
+ delFromAllButCurrent w ss = foldr ($) ss $
+ map (delWinFromWorkspace w . tag) $
+ hidden ss ++ map workspace (visible ss)
+ delWinFromWorkspace w wid ss = modify Nothing (filter (/= w)) $ view wid ss