aboutsummaryrefslogtreecommitdiff
path: root/src/Internal/SwapMaster.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Internal/SwapMaster.hs')
-rw-r--r--src/Internal/SwapMaster.hs41
1 files changed, 0 insertions, 41 deletions
diff --git a/src/Internal/SwapMaster.hs b/src/Internal/SwapMaster.hs
deleted file mode 100644
index e7ade19..0000000
--- a/src/Internal/SwapMaster.hs
+++ /dev/null
@@ -1,41 +0,0 @@
-{- Swap window with the master, but save it. -}
-module Internal.SwapMaster (swapMaster) where
-
-import qualified XMonad.StackSet as W
-
-import Internal.Windows (mapWindows, getMaster, swapWindows)
-import Control.Monad.Trans.Maybe
-import XMonad (Window, ExtensionClass(..), X(..), windows, windowset)
-import Control.Monad (void)
-import Control.Monad.Trans (lift)
-import Data.Maybe (fromMaybe)
-import Control.Monad.State (gets)
-
-import qualified XMonad.Util.ExtensibleState as XS
-
-newtype LastWindow = LastWindow {
- lastWindow :: Maybe Window
- } deriving (Show, Read)
-
-instance ExtensionClass LastWindow where
- initialValue = LastWindow Nothing
-
-hoist :: (Monad m) => Maybe a -> MaybeT m a
-hoist = MaybeT . return
-
-swapMaster :: X ()
-swapMaster = void $ runMaybeT $ do
- ss <- gets windowset
-
- focused <- hoist $ W.peek ss
- master <- hoist $ getMaster ss
-
- if focused == master
- then do
- lw <- MaybeT $ lastWindow <$> XS.get
- lift $ windows (swapWindows focused lw)
- else lift $ windows (swapWindows focused master)
-
- lift $ do
- XS.put (LastWindow $ Just master)
- windows W.focusMaster