diff options
Diffstat (limited to 'src/Rahm/Desktop/SwapMaster.hs')
| -rw-r--r-- | src/Rahm/Desktop/SwapMaster.hs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/Rahm/Desktop/SwapMaster.hs b/src/Rahm/Desktop/SwapMaster.hs index cd47c01..7a86146 100644 --- a/src/Rahm/Desktop/SwapMaster.hs +++ b/src/Rahm/Desktop/SwapMaster.hs @@ -1,20 +1,19 @@ {- Swap window with the master, but save it. -} module Rahm.Desktop.SwapMaster (swapMaster) where -import qualified Rahm.Desktop.StackSet as W - -import Control.Monad.Trans.Maybe -import XMonad (Window, ExtensionClass(..), X(..), windows, windowset) import Control.Monad (void) +import Control.Monad.State (gets) import Control.Monad.Trans (lift) +import Control.Monad.Trans.Maybe import Data.Maybe (fromMaybe) -import Control.Monad.State (gets) - +import qualified Rahm.Desktop.StackSet as W +import XMonad (ExtensionClass (..), Window, X (..), windows, windowset) import qualified XMonad.Util.ExtensibleState as XS -newtype LastWindow = LastWindow { - lastWindow :: Maybe Window - } deriving (Show, Read) +newtype LastWindow = LastWindow + { lastWindow :: Maybe Window + } + deriving (Show, Read) instance ExtensionClass LastWindow where initialValue = LastWindow Nothing @@ -23,17 +22,18 @@ hoist :: (Monad m) => Maybe a -> MaybeT m a hoist = MaybeT . return swapMaster :: X () -swapMaster = void $ runMaybeT $ do +swapMaster = void $ + runMaybeT $ do ss <- gets windowset focused <- hoist $ W.peek ss master <- hoist $ W.masterWindow ss if focused == master - then do - lw <- MaybeT $ lastWindow <$> XS.get - lift $ windows (W.swapWindows [(focused, lw)]) - else lift $ windows (W.swapWindows [(focused, master)]) + then do + lw <- MaybeT $ lastWindow <$> XS.get + lift $ windows (W.swapWindows [(focused, lw)]) + else lift $ windows (W.swapWindows [(focused, master)]) lift $ do XS.put (LastWindow $ Just master) |