aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop
diff options
context:
space:
mode:
Diffstat (limited to 'src/Rahm/Desktop')
-rw-r--r--src/Rahm/Desktop/History.hs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/Rahm/Desktop/History.hs b/src/Rahm/Desktop/History.hs
index 01f3761..8b8e879 100644
--- a/src/Rahm/Desktop/History.hs
+++ b/src/Rahm/Desktop/History.hs
@@ -21,11 +21,11 @@ import qualified Data.Map as Map
import Data.Maybe (catMaybes, fromMaybe, isJust)
import Data.Sequence (Seq (..))
import qualified Data.Sequence as Seq (length, (!?))
-import Rahm.Desktop.Common (Location (Location), focusLocation, getCurrentScreen, getCurrentWorkspace, locationWorkspace)
+import Rahm.Desktop.Common (Location (Location, locationWindow), focusLocation, getCurrentScreen, getCurrentWorkspace, locationWorkspace)
import Rahm.Desktop.Hooks.WindowChange
import Rahm.Desktop.Logger
import Text.Printf (printf)
-import XMonad (ExtensionClass (extensionType, initialValue), ScreenId, StateExtension (..), Window, X)
+import XMonad (ExtensionClass (extensionType, initialValue), ScreenId, StateExtension (..), Window, X, withWindowSet)
import XMonad.StackSet
import qualified XMonad.Util.ExtensibleState as XS
( get,
@@ -106,14 +106,21 @@ jumpToLastLocation = do
logs Trace "Jumping to Last Location."
mapM_ focusLocation =<< lastLocation
--- Get the last location for the current screen.
+-- Get the last location for the current screen. If
lastLocation :: X (Maybe Location)
lastLocation = do
screenId <- getCurrentScreen
ret <- getZipper . getCurrentZipper screenId <$> XS.get
XS.modify $ \(History byScreen) ->
History (Map.adjust popSeqZipper screenId byScreen)
- return ret
+
+ t <- withWindowSet $ \ws ->
+ return $ flip findTag ws =<< (locationWindow =<< ret)
+
+ -- The last location should not return the last location.
+ if t == Just "*" || (locationWorkspace <$> ret) == Just "*"
+ then lastLocation
+ else return ret
nextLocation :: X (Maybe Location)
nextLocation = do