diff options
Diffstat (limited to 'src/Rahm/Desktop/Keys')
| -rw-r--r-- | src/Rahm/Desktop/Keys/Wml.hs | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/src/Rahm/Desktop/Keys/Wml.hs b/src/Rahm/Desktop/Keys/Wml.hs index e7a7cb9..8abb17b 100644 --- a/src/Rahm/Desktop/Keys/Wml.hs +++ b/src/Rahm/Desktop/Keys/Wml.hs @@ -18,7 +18,7 @@ module Rahm.Desktop.Keys.Wml readNextWorkspace, readNextLocationSet, moveLocationToWorkspace, - moveLocationToWorkspaceFn, + moveWindowToWorkspaceFn, gotoWorkspaceFn, readMacroString, justWorkspace, @@ -96,6 +96,7 @@ import qualified Rahm.Desktop.StackSet as W focusWindow, getLocationWorkspace, greedyView, + shiftWin, integrate', screens, sink, @@ -131,6 +132,7 @@ import XMonad Typeable, Window, WorkspaceId, + WindowSet, X, asks, directories, @@ -209,7 +211,8 @@ instance ExtensionClass MaybeMacros where data Workspace = forall a. (Typeable a) => Workspace - { moveLocationToWorkspaceFn :: Location -> X (), + { + moveWindowToWorkspaceFn :: Window -> X (WindowSet -> WindowSet), gotoWorkspaceFn :: X (), workspaceName :: Maybe String, extraWorkspaceData :: a @@ -247,7 +250,7 @@ readMacroString = do justWorkspace :: String -> Workspace justWorkspace s = Workspace - { moveLocationToWorkspaceFn = flip moveLocationToWorkspace s, + { moveWindowToWorkspaceFn = return . W.shiftWin s, gotoWorkspaceFn = gotoWorkspace s, workspaceName = Just s, extraWorkspaceData = () @@ -256,7 +259,7 @@ justWorkspace s = justWorkspaceWithPreferredWindow :: Window -> String -> Workspace justWorkspaceWithPreferredWindow w s = Workspace - { moveLocationToWorkspaceFn = flip moveLocationToWorkspace s, + { moveWindowToWorkspaceFn = return . W.shiftWin s, gotoWorkspaceFn = do windows $ \ws' -> let ws = W.greedyView s ws' @@ -271,7 +274,7 @@ justWorkspaceWithPreferredWindow w s = blackHoleWorkspace :: Workspace blackHoleWorkspace = Workspace - { moveLocationToWorkspaceFn = mapM_ killWindow . locationWindow, + { moveWindowToWorkspaceFn = \w -> killWindow w >> return id, gotoWorkspaceFn = confirmPrompt def "Do you want to exit xmonad" $ io exitSuccess, workspaceName = Nothing, @@ -281,14 +284,10 @@ blackHoleWorkspace = alternateWorkspace :: Workspace alternateWorkspace = Workspace - { moveLocationToWorkspaceFn = \l@(Location _ maybeWin) -> do - logs Info "Moving Location: %s" (show l) - case maybeWin of - Nothing -> return () - Just win -> do - alter <- getAlternateWorkspace win - logs Info "Moving %s to %s" (show win) (show alter) - mapM_ (moveLocationToWorkspace l) alter, + { moveWindowToWorkspaceFn = \win -> do + alter <- getAlternateWorkspace win + return $ \ss -> + maybe ss (\a -> W.shiftWin a win ss) alter, gotoWorkspaceFn = do (Location _ maybeWin) <- getCurrentLocation case maybeWin of @@ -304,18 +303,17 @@ newtype FloatWorkspace = FloatWorkspace Workspace floatWorkspace :: Workspace -> Workspace floatWorkspace ws@Workspace {extraWorkspaceData = d} = Workspace - { moveLocationToWorkspaceFn = \location -> do - forM_ (locationWindow location) $ \win -> do - case cast d of - Just (FloatWorkspace ws') -> do - windows $ W.sink win - moveLocationToWorkspaceFn ws' location - Nothing -> do - windows $ \ss -> - if win `Map.member` W.floating ss - then ss -- win is already floating - else W.float win (W.RationalRect (1 / 8) (1 / 8) (6 / 8) (6 / 8)) ss - moveLocationToWorkspaceFn ws location, + { moveWindowToWorkspaceFn = \win -> do + case cast d of + Just (FloatWorkspace ws') -> do + movefn <- moveWindowToWorkspaceFn ws' win + return $ W.sink win . movefn + Nothing ->do + movefn <- moveWindowToWorkspaceFn ws win + return $ \ss -> do + if win `Map.member` W.floating ss + then movefn ss + else movefn $ W.float win (W.RationalRect (1 / 8) (1 / 8) (6 / 8) (6 / 8)) ss, gotoWorkspaceFn = gotoWorkspaceFn ws, workspaceName = workspaceName ws, extraWorkspaceData = FloatWorkspace ws |