mirror of
https://github.com/xmonad/xmonad.git
synced 2025-05-19 08:30:21 -07:00
use new StackSet api
This commit is contained in:
parent
436fbd7865
commit
78407a3c26
25
Main.hs
25
Main.hs
@ -144,7 +144,10 @@ handle e = trace (eventName e)
|
||||
-- | refresh. Refresh the currently focused window. Resizes to full
|
||||
-- screen and raises the window.
|
||||
refresh :: W ()
|
||||
refresh = whenJust W.peek $ \w -> withScreen $ \(d,sw,sh) -> io $ do
|
||||
refresh = do
|
||||
ws <- gets workspace
|
||||
whenJust (W.peek ws) $ \w ->
|
||||
withScreen $ \(d,sw,sh) -> io $ do
|
||||
moveResizeWindow d w 0 0 (fromIntegral sw) (fromIntegral sh) -- fullscreen
|
||||
raiseWindow d w
|
||||
|
||||
@ -167,7 +170,8 @@ windows f = modifyWorkspace f >> refresh
|
||||
-- | manage. Add a new window to be managed in the current workspace. Bring it into focus.
|
||||
-- If the window is already under management, it is just raised.
|
||||
manage :: Window -> W ()
|
||||
manage w = do withDisplay $ \d -> io $ mapWindow d w
|
||||
manage w = do
|
||||
withDisplay $ io . flip mapWindow w
|
||||
windows $ W.push w
|
||||
|
||||
-- | unmanage. A window no longer exists, remove it from the window
|
||||
@ -186,14 +190,17 @@ focus = windows . W.rotate
|
||||
|
||||
-- | Kill the currently focused client
|
||||
kill :: W ()
|
||||
kill = withDisplay $ \d -> whenJust W.peek $ io_ . killClient d
|
||||
kill = withDisplay $ \d -> do
|
||||
ws <- gets workspace
|
||||
whenJust (W.peek ws) $ io_ . killClient d
|
||||
|
||||
-- | tag. Move a window to a new workspace
|
||||
tag :: Int -> W ()
|
||||
tag o = do
|
||||
ws <- gets workspace
|
||||
when (n /= W.cursor ws) $
|
||||
whenJust W.peek $ \w -> do
|
||||
let m = W.current ws
|
||||
when (n /= m) $
|
||||
whenJust (W.peek ws) $ \w -> do
|
||||
hide w
|
||||
windows $ W.shift n
|
||||
where n = o-1
|
||||
@ -202,9 +209,11 @@ tag o = do
|
||||
view :: Int -> W ()
|
||||
view o = do
|
||||
ws <- gets workspace
|
||||
when (n /= W.cursor ws) $
|
||||
whenJust (flip W.index n) $ \new -> do
|
||||
mapM_ hide (W.stack ws)
|
||||
let m = W.current ws
|
||||
when (n /= m) $
|
||||
whenJust (W.index n ws) $ \new ->
|
||||
whenJust (W.index m ws) $ \old -> do
|
||||
mapM_ hide old
|
||||
mapM_ reveal new
|
||||
windows $ W.view n
|
||||
where n = o-1
|
||||
|
11
WMonad.hs
11
WMonad.hs
@ -16,7 +16,7 @@
|
||||
|
||||
module WMonad where
|
||||
|
||||
import StackSet
|
||||
import StackSet (StackSet)
|
||||
|
||||
import Control.Monad.State
|
||||
import System.IO
|
||||
@ -87,11 +87,6 @@ modifyWorkspace f = do
|
||||
trace (show ws) -- log state changes to stderr
|
||||
|
||||
-- | Run a side effecting action with the current workspace. Like 'when' but
|
||||
-- for (WorkSpace -> Maybe a).
|
||||
whenJust :: (WorkSpace -> Maybe a) -> (a -> W ()) -> W ()
|
||||
whenJust mg f = do
|
||||
ws <- gets workspace
|
||||
case mg ws of
|
||||
Nothing -> return ()
|
||||
Just w -> f w
|
||||
whenJust :: Maybe a -> (a -> W ()) -> W ()
|
||||
whenJust mg f = maybe (return ()) f mg
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user