From 6eb4bd53a098bf5645f8eda13db1243ffc1df088 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Sun, 24 Apr 2022 20:47:40 -0600 Subject: Roll ScreenRotate into StackSet --- src/Rahm/Desktop/StackSet.hs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/Rahm/Desktop/StackSet.hs') diff --git a/src/Rahm/Desktop/StackSet.hs b/src/Rahm/Desktop/StackSet.hs index 251bee3..8db16c1 100644 --- a/src/Rahm/Desktop/StackSet.hs +++ b/src/Rahm/Desktop/StackSet.hs @@ -5,10 +5,12 @@ module Rahm.Desktop.StackSet ( swapWorkspaces, greedyView, shiftWin, + screenRotateBackward, + screenRotateForward, module W) where -import Prelude hiding (head, tail) -import Data.List.Safe (head, tail) +import Prelude hiding (head) +import Data.List.Safe (head) import Data.List (find) import XMonad.StackSet as W hiding (greedyView, shiftWin) import qualified XMonad.StackSet @@ -49,3 +51,19 @@ greedyView wid ss = swapWorkspaces (tag . workspace . current $ ss) wid ss shiftWin :: (Ord a, Eq s, Eq i) => i -> a -> StackSet i l a s sd -> StackSet i l a s sd shiftWin wid a = XMonad.StackSet.shiftWin wid a . fst . ensureWorkspace wid + +screenRotateBackward :: W.StackSet i l a sid sd -> W.StackSet i l a sid sd +screenRotateBackward (W.StackSet current visible others floating) = do + let screens = current : visible + workspaces = tail $ cycle $ map W.workspace screens + (current':visible') = zipWith (\s w -> s {workspace = w} ) screens workspaces + in W.StackSet current' visible' others floating + +screenRotateForward :: W.StackSet i l a sid sd -> W.StackSet i l a sid sd +screenRotateForward (W.StackSet current visible others floating) = do + let screens = current : visible + workspaces = rcycle $ map W.workspace screens + (current':visible') = zipWith (\s w -> s {workspace = w} ) screens workspaces + in W.StackSet current' visible' others floating + + where rcycle l = last l : l -- cgit