]> ruderich.org/simon Gitweb - config/dotfiles.git/blobdiff - xmonad.hs
xmonad.hs: Fix endless loop in nextLayoutIncluding.
[config/dotfiles.git] / xmonad.hs
index 76f64d5243ac8973555ca00843e98a8a31d3929d..d4c323a162c12236484828adb40b75316c4ece51 100644 (file)
--- a/xmonad.hs
+++ b/xmonad.hs
@@ -1,6 +1,6 @@
 -- xmonad configuration file.
 --
--- Should work fine with xmonad 0.7 and above.
+-- Tested with xmonad 0.9, most settings should work fine with xmonad 0.7.
 
 
 -- "hiding" necessary for LayoutCombinators.
@@ -108,16 +108,17 @@ nextLayoutIncluding :: [String] -> X ()
 nextLayoutIncluding layouts = do
     cws <- gets (W.workspace . W.current . windowset)
     sendMessageWithNoRefresh NextLayout cws
-    nextLayoutIncluding' layouts
+    nextLayoutIncluding' layouts 1000 -- nobody has more than 1000 layouts
 
-nextLayoutIncluding' :: [String] -> X ()
-nextLayoutIncluding' layouts = do
+nextLayoutIncluding' :: [String] -> Int -> X ()
+nextLayoutIncluding' layouts iterations = do
     cws <- gets (W.workspace . W.current . windowset)
-    if not $ (description $ W.layout cws) `elem` layouts
+    -- iterations prevents an endless loop if no valid layout can be found.
+    if not ((description $ W.layout cws) `elem` layouts) && iterations > 0
         -- Skip over excluded layouts.
         then do
             sendMessageWithNoRefresh NextLayout cws
-            nextLayoutIncluding' layouts
+            nextLayoutIncluding' layouts (iterations - 1)
         -- Found allowed layout, show it.
         else refresh