From 5ec14af63aa33027efb643e6a832a579b983fc11 Mon Sep 17 00:00:00 2001 From: mail Date: Thu, 27 Dec 2007 19:26:35 +0100 Subject: Add support for cycling through screens to CycleWS darcs-hash:20071227182635-c9905-de6cc264b94f665c46400199836e8ce9ec7b146c.gz --- XMonad/Actions/CycleWS.hs | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'XMonad/Actions/CycleWS.hs') diff --git a/XMonad/Actions/CycleWS.hs b/XMonad/Actions/CycleWS.hs index 6e4e822..864d8ed 100644 --- a/XMonad/Actions/CycleWS.hs +++ b/XMonad/Actions/CycleWS.hs @@ -10,7 +10,7 @@ -- Portability : unportable -- -- Provides bindings to cycle forward or backward through the list --- of workspaces, and to move windows there. +-- of workspaces, and to move windows there, and to cycle between the screens. -- ----------------------------------------------------------------------------- @@ -22,9 +22,11 @@ module XMonad.Actions.CycleWS ( shiftToNext, shiftToPrev, toggleWS, + nextScreen, + prevScreen ) where -import Data.List ( findIndex ) +import Data.List ( findIndex, sortBy ) import Data.Maybe ( fromMaybe ) import XMonad hiding (workspaces) @@ -36,16 +38,18 @@ import XMonad.Util.WorkspaceCompare -- -- > import XMonad.Actions.CycleWS -- --- > , ((modMask x, xK_Right), nextWS) --- > , ((modMask x, xK_Left), prevWS) --- > , ((modMask x .|. shiftMask, xK_Right), shiftToNext) --- > , ((modMask x .|. shiftMask, xK_Left), shiftToPrev) +-- > , ((modMask x, xK_Down), nextWS) +-- > , ((modMask x, xK_Up), prevWS) +-- > , ((modMask x .|. shiftMask, xK_Down), shiftToNext) +-- > , ((modMask x .|. shiftMask, xK_Up), shiftToPrev) +-- > , ((modMask x, xK_Right), nextScreen) +-- > , ((modMask x, xK_Left), prevScreen) -- > , ((modMask x, xK_t), toggleWS) -- -- If you want to follow the moved window, you can use both actions: -- --- > , ((modMask x .|. shiftMask, xK_Right), shiftToNext >> nextWS) --- > , ((modMask x .|. shiftMask, xK_Left), shiftToPrev >> prevWS) +-- > , ((modMask x .|. shiftMask, xK_Down), shiftToNext >> nextWS) +-- > , ((modMask x .|. shiftMask, xK_Up), shiftToPrev >> prevWS) -- -- For detailed instructions on editing your key bindings, see -- "XMonad.Doc.Extending#Editing_key_bindings". @@ -88,3 +92,24 @@ wsBy d = do findWsIndex :: WindowSpace -> [WindowSpace] -> Maybe Int findWsIndex ws wss = findIndex ((== tag ws) . tag) wss + +-- | View next screen +nextScreen :: X () +nextScreen = switchScreen 1 + +-- | View prev screen +prevScreen :: X () +prevScreen = switchScreen (-1) + +switchScreen :: Int -> X () +switchScreen d = do s <- screenBy d + mws <- screenWorkspace s + case mws of + Nothing -> return () + Just ws -> windows (view ws) + +screenBy :: Int -> X (ScreenId) +screenBy d = do ws <- gets windowset + --let ss = sortBy screen (screens ws) + let now = screen (current ws) + return $ (now + fromIntegral d) `mod` fromIntegral (length (screens ws)) -- cgit v1.2.3