mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
cleanup - use currentTag
This commit is contained in:
parent
bd2b5379ab
commit
f3b6b2707a
@ -77,7 +77,7 @@ copyToAll s = foldr copy s $ map tag (workspaces s)
|
|||||||
copyWindow :: (Eq a, Eq i, Eq s) => a -> i -> StackSet i l a s sd -> StackSet i l a s sd
|
copyWindow :: (Eq a, Eq i, Eq s) => a -> i -> StackSet i l a s sd -> StackSet i l a s sd
|
||||||
copyWindow w n = copy'
|
copyWindow w n = copy'
|
||||||
where copy' s = if n `tagMember` s
|
where copy' s = if n `tagMember` s
|
||||||
then view (tag (workspace (current s))) $ insertUp' w $ view n s
|
then view (currentTag s) $ insertUp' w $ view n s
|
||||||
else s
|
else s
|
||||||
insertUp' a s = modify (Just $ Stack a [] [])
|
insertUp' a s = modify (Just $ Stack a [] [])
|
||||||
(\(Stack t l r) -> if a `elem` t:l++r
|
(\(Stack t l r) -> if a `elem` t:l++r
|
||||||
@ -107,7 +107,7 @@ kill1 = do ss <- gets windowset
|
|||||||
killAllOtherCopies :: X ()
|
killAllOtherCopies :: X ()
|
||||||
killAllOtherCopies = do ss <- gets windowset
|
killAllOtherCopies = do ss <- gets windowset
|
||||||
whenJust (peek ss) $ \w -> windows $
|
whenJust (peek ss) $ \w -> windows $
|
||||||
view (tag (workspace (current ss))) .
|
view (currentTag ss) .
|
||||||
delFromAllButCurrent w
|
delFromAllButCurrent w
|
||||||
where
|
where
|
||||||
delFromAllButCurrent w ss = foldr ($) ss $
|
delFromAllButCurrent w ss = foldr ($) ss $
|
||||||
|
@ -217,7 +217,7 @@ findWorkspace s dir t n = findWorkspaceGen s (wsTypeToPred t) (maybeNegate dir n
|
|||||||
maybeNegate Prev d = (-d)
|
maybeNegate Prev d = (-d)
|
||||||
|
|
||||||
findWorkspaceGen :: X WorkspaceSort -> X (WindowSpace -> Bool) -> Int -> X WorkspaceId
|
findWorkspaceGen :: X WorkspaceSort -> X (WindowSpace -> Bool) -> Int -> X WorkspaceId
|
||||||
findWorkspaceGen _ _ 0 = (tag . workspace . current) `fmap` gets windowset
|
findWorkspaceGen _ _ 0 = gets (currentTag . windowset)
|
||||||
findWorkspaceGen sortX wsPredX d = do
|
findWorkspaceGen sortX wsPredX d = do
|
||||||
wsPred <- wsPredX
|
wsPred <- wsPredX
|
||||||
sort <- sortX
|
sort <- sortX
|
||||||
|
@ -36,7 +36,7 @@ import Data.List (find)
|
|||||||
|
|
||||||
-- | Uses supplied function to decide which action to run depending on current workspace name.
|
-- | Uses supplied function to decide which action to run depending on current workspace name.
|
||||||
chooseAction :: (String->X()) -> X()
|
chooseAction :: (String->X()) -> X()
|
||||||
chooseAction f = withWindowSet (f . S.tag . S.workspace . S.current)
|
chooseAction f = withWindowSet (f . S.currentTag)
|
||||||
|
|
||||||
-- | If current workspace is listed, run appropriate action (only the first match counts!)
|
-- | If current workspace is listed, run appropriate action (only the first match counts!)
|
||||||
-- If it isn't listed, then run default action (marked with empty string, \"\"), or do nothing if default isn't supplied.
|
-- If it isn't listed, then run default action (marked with empty string, \"\"), or do nothing if default isn't supplied.
|
||||||
|
@ -48,7 +48,7 @@ import XMonad.Util.WorkspaceCompare
|
|||||||
-- | Swaps the currently focused workspace with the given workspace tag, via
|
-- | Swaps the currently focused workspace with the given workspace tag, via
|
||||||
-- @swapWorkspaces@.
|
-- @swapWorkspaces@.
|
||||||
swapWithCurrent :: Eq i => i -> StackSet i l a s sd -> StackSet i l a s sd
|
swapWithCurrent :: Eq i => i -> StackSet i l a s sd -> StackSet i l a s sd
|
||||||
swapWithCurrent t s = swapWorkspaces t (tag $ workspace $ current s) s
|
swapWithCurrent t s = swapWorkspaces t (currentTag s) s
|
||||||
|
|
||||||
-- | Say @swapTo Next@ or @swapTo Prev@ to move your current workspace.
|
-- | Say @swapTo Next@ or @swapTo Prev@ to move your current workspace.
|
||||||
-- This is an @X ()@ so can be hooked up to your keybindings directly.
|
-- This is an @X ()@ so can be hooked up to your keybindings directly.
|
||||||
|
@ -120,7 +120,7 @@ wsToList ws = crs ++ cls
|
|||||||
wsToListGlobal :: (Ord i) => StackSet i l a s sd -> [a]
|
wsToListGlobal :: (Ord i) => StackSet i l a s sd -> [a]
|
||||||
wsToListGlobal ws = concat ([crs] ++ rws ++ lws ++ [cls])
|
wsToListGlobal ws = concat ([crs] ++ rws ++ lws ++ [cls])
|
||||||
where
|
where
|
||||||
curtag = tag . workspace . current $ ws
|
curtag = currentTag ws
|
||||||
(crs, cls) = (cms down, cms (reverse . up))
|
(crs, cls) = (cms down, cms (reverse . up))
|
||||||
cms f = maybe [] f (stack . workspace . current $ ws)
|
cms f = maybe [] f (stack . workspace . current $ ws)
|
||||||
(lws, rws) = (mws (<), mws (>))
|
(lws, rws) = (mws (<), mws (>))
|
||||||
@ -149,8 +149,7 @@ withTagged t f = withTagged' t (mapM_ f)
|
|||||||
withTaggedGlobal t f = withTaggedGlobal' t (mapM_ f)
|
withTaggedGlobal t f = withTaggedGlobal' t (mapM_ f)
|
||||||
|
|
||||||
withTagged' :: String -> ([Window] -> X ()) -> X ()
|
withTagged' :: String -> ([Window] -> X ()) -> X ()
|
||||||
withTagged' t m = gets windowset >>=
|
withTagged' t m = gets windowset >>= filterM (hasTag t) . index >>= m
|
||||||
filterM (hasTag t) . integrate' . stack . workspace . current >>= m
|
|
||||||
|
|
||||||
withTaggedGlobal' :: String -> ([Window] -> X ()) -> X ()
|
withTaggedGlobal' :: String -> ([Window] -> X ()) -> X ()
|
||||||
withTaggedGlobal' t m = gets windowset >>=
|
withTaggedGlobal' t m = gets windowset >>=
|
||||||
@ -160,7 +159,7 @@ withFocusedP :: (Window -> WindowSet -> WindowSet) -> X ()
|
|||||||
withFocusedP f = withFocused $ windows . f
|
withFocusedP f = withFocused $ windows . f
|
||||||
|
|
||||||
shiftHere :: (Ord a, Eq s, Eq i) => a -> StackSet i l a s sd -> StackSet i l a s sd
|
shiftHere :: (Ord a, Eq s, Eq i) => a -> StackSet i l a s sd -> StackSet i l a s sd
|
||||||
shiftHere w s = shiftWin (tag . workspace . current $ s) w s
|
shiftHere w s = shiftWin (currentTag s) w s
|
||||||
|
|
||||||
shiftToScreen :: (Ord a, Eq s, Eq i) => s -> a -> StackSet i l a s sd -> StackSet i l a s sd
|
shiftToScreen :: (Ord a, Eq s, Eq i) => s -> a -> StackSet i l a s sd -> StackSet i l a s sd
|
||||||
shiftToScreen sid w s = case filter (\m -> sid /= screen m) ((current s):(visible s)) of
|
shiftToScreen sid w s = case filter (\m -> sid /= screen m) ((current s):(visible s)) of
|
||||||
|
@ -57,7 +57,7 @@ bringMenu = actionMenu bringWindow
|
|||||||
|
|
||||||
-- | Brings the specified window into the current workspace.
|
-- | Brings the specified window into the current workspace.
|
||||||
bringWindow :: Window -> X.WindowSet -> X.WindowSet
|
bringWindow :: Window -> X.WindowSet -> X.WindowSet
|
||||||
bringWindow w ws = W.shiftWin (W.tag . W.workspace . W.current $ ws) w ws
|
bringWindow w ws = W.shiftWin (W.currentTag ws) w ws
|
||||||
|
|
||||||
-- | Calls dmenuMap to grab the appropriate Window, and hands it off to action
|
-- | Calls dmenuMap to grab the appropriate Window, and hands it off to action
|
||||||
-- if found.
|
-- if found.
|
||||||
|
@ -153,7 +153,7 @@ currentPosition posRef = do
|
|||||||
currentWindow <- gets (W.peek . windowset)
|
currentWindow <- gets (W.peek . windowset)
|
||||||
currentRect <- maybe (Rectangle 0 0 0 0) snd <$> windowRect (fromMaybe root currentWindow)
|
currentRect <- maybe (Rectangle 0 0 0 0) snd <$> windowRect (fromMaybe root currentWindow)
|
||||||
|
|
||||||
wsid <- gets (W.tag . W.workspace . W.current . windowset)
|
wsid <- gets (W.currentTag . windowset)
|
||||||
mp <- M.lookup wsid <$> io (readIORef posRef)
|
mp <- M.lookup wsid <$> io (readIORef posRef)
|
||||||
|
|
||||||
return $ maybe (middleOf currentRect) (`inside` currentRect) mp
|
return $ maybe (middleOf currentRect) (`inside` currentRect) mp
|
||||||
@ -162,7 +162,7 @@ currentPosition posRef = do
|
|||||||
|
|
||||||
setPosition :: IORef WNState -> Point -> Rectangle -> X ()
|
setPosition :: IORef WNState -> Point -> Rectangle -> X ()
|
||||||
setPosition posRef oldPos newRect = do
|
setPosition posRef oldPos newRect = do
|
||||||
wsid <- gets (W.tag . W.workspace . W.current . windowset)
|
wsid <- gets (W.currentTag . windowset)
|
||||||
io $ modifyIORef posRef $ M.insert wsid (oldPos `inside` newRect)
|
io $ modifyIORef posRef $ M.insert wsid (oldPos `inside` newRect)
|
||||||
|
|
||||||
inside :: Point -> Rectangle -> Point
|
inside :: Point -> Rectangle -> Point
|
||||||
|
@ -176,7 +176,7 @@ instance UrgencyHook FocusUrgencyHook Window where
|
|||||||
s { windowset = until ((Just w ==) . W.peek)
|
s { windowset = until ((Just w ==) . W.peek)
|
||||||
W.focusUp $ windowset s }
|
W.focusUp $ windowset s }
|
||||||
| otherwise =
|
| otherwise =
|
||||||
let t = W.tag $ W.workspace $ W.current $ windowset s
|
let t = W.currentTag $ windowset s
|
||||||
in s { windowset = until ((Just w ==) . W.peek)
|
in s { windowset = until ((Just w ==) . W.peek)
|
||||||
W.focusUp $ copyWindow w t $ windowset s }
|
W.focusUp $ copyWindow w t $ windowset s }
|
||||||
has _ Nothing = False
|
has _ Nothing = False
|
||||||
|
@ -256,7 +256,7 @@ dynamicLogString pp = do
|
|||||||
pprWindowSet :: WorkspaceSort -> [Window] -> PP -> WindowSet -> String
|
pprWindowSet :: WorkspaceSort -> [Window] -> PP -> WindowSet -> String
|
||||||
pprWindowSet sort' urgents pp s = sepBy (ppWsSep pp) . map fmt . sort' $
|
pprWindowSet sort' urgents pp s = sepBy (ppWsSep pp) . map fmt . sort' $
|
||||||
map S.workspace (S.current s : S.visible s) ++ S.hidden s
|
map S.workspace (S.current s : S.visible s) ++ S.hidden s
|
||||||
where this = S.tag (S.workspace (S.current s))
|
where this = S.currentTag s
|
||||||
visibles = map (S.tag . S.workspace) (S.visible s)
|
visibles = map (S.tag . S.workspace) (S.visible s)
|
||||||
|
|
||||||
fmt w = printer pp (S.tag w)
|
fmt w = printer pp (S.tag w)
|
||||||
|
@ -29,11 +29,10 @@ module XMonad.Hooks.EventHook
|
|||||||
, HandleEvent
|
, HandleEvent
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Applicative ((<$>))
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
import XMonad.StackSet (StackSet (..), Screen (..), Workspace (..))
|
import XMonad.StackSet (Workspace (..), currentTag)
|
||||||
|
|
||||||
-- $usage
|
-- $usage
|
||||||
-- You can use this module with the following in your
|
-- You can use this module with the following in your
|
||||||
@ -89,7 +88,7 @@ instance Message EventHandleMsg
|
|||||||
instance (EventHook eh, LayoutClass l a) => LayoutClass (HandleEvent eh l) a where
|
instance (EventHook eh, LayoutClass l a) => LayoutClass (HandleEvent eh l) a where
|
||||||
runLayout (Workspace i (HandleEvent Nothing True eh l) ms) r = do
|
runLayout (Workspace i (HandleEvent Nothing True eh l) ms) r = do
|
||||||
broadcastMessage HandlerOff
|
broadcastMessage HandlerOff
|
||||||
iws <- (tag . workspace . current) <$> gets windowset
|
iws <- gets (currentTag . windowset)
|
||||||
(wrs, ml) <- runLayout (Workspace i l ms) r
|
(wrs, ml) <- runLayout (Workspace i l ms) r
|
||||||
return (wrs, Just $ HandleEvent (Just iws) True eh (fromMaybe l ml))
|
return (wrs, Just $ HandleEvent (Just iws) True eh (fromMaybe l ml))
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ ewmhDesktopsLogHookCustom f = withWindowSet $ \s -> do
|
|||||||
setDesktopNames (map W.tag ws)
|
setDesktopNames (map W.tag ws)
|
||||||
|
|
||||||
-- Current desktop
|
-- Current desktop
|
||||||
let curr = fromJust $ elemIndex (W.tag (W.workspace (W.current s))) $ map W.tag ws
|
let curr = fromJust $ elemIndex (W.currentTag s) $ map W.tag ws
|
||||||
|
|
||||||
setCurrentDesktop curr
|
setCurrentDesktop curr
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ doShow (SWN False _ _ ) _ wrs = return (wrs, Nothing)
|
|||||||
flashName :: SWNConfig -> Rectangle -> [(a, Rectangle)] -> X ([(a, Rectangle)], Maybe (ShowWName a))
|
flashName :: SWNConfig -> Rectangle -> [(a, Rectangle)] -> X ([(a, Rectangle)], Maybe (ShowWName a))
|
||||||
flashName c (Rectangle _ _ wh ht) wrs = do
|
flashName c (Rectangle _ _ wh ht) wrs = do
|
||||||
d <- asks display
|
d <- asks display
|
||||||
n <- withWindowSet (return . S.tag . S.workspace . S.current)
|
n <- withWindowSet (return . S.currentTag)
|
||||||
f <- initXMF (swn_font c)
|
f <- initXMF (swn_font c)
|
||||||
width <- textWidthXMF d f n
|
width <- textWidthXMF d f n
|
||||||
(as,ds) <- textExtentsXMF f n
|
(as,ds) <- textExtentsXMF f n
|
||||||
|
@ -37,7 +37,7 @@ import XMonad.Util.Run ( runProcessWithInput )
|
|||||||
import XMonad.Prompt ( XPConfig )
|
import XMonad.Prompt ( XPConfig )
|
||||||
import XMonad.Prompt.Directory ( directoryPrompt )
|
import XMonad.Prompt.Directory ( directoryPrompt )
|
||||||
import XMonad.Layout.LayoutModifier
|
import XMonad.Layout.LayoutModifier
|
||||||
import XMonad.StackSet ( tag, current, workspace )
|
import XMonad.StackSet ( tag, currentTag )
|
||||||
|
|
||||||
-- $usage
|
-- $usage
|
||||||
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
||||||
@ -69,7 +69,7 @@ instance Message Chdir
|
|||||||
data WorkspaceDir a = WorkspaceDir String deriving ( Read, Show )
|
data WorkspaceDir a = WorkspaceDir String deriving ( Read, Show )
|
||||||
|
|
||||||
instance LayoutModifier WorkspaceDir Window where
|
instance LayoutModifier WorkspaceDir Window where
|
||||||
modifyLayout (WorkspaceDir d) w r = do tc <- gets (tag.workspace.current.windowset)
|
modifyLayout (WorkspaceDir d) w r = do tc <- gets (currentTag.windowset)
|
||||||
when (tc == tag w) $ scd d
|
when (tc == tag w) $ scd d
|
||||||
runLayout w r
|
runLayout w r
|
||||||
handleMess (WorkspaceDir _) m
|
handleMess (WorkspaceDir _) m
|
||||||
|
Loading…
x
Reference in New Issue
Block a user