aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/StackSet.hs
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2022-11-21 20:57:42 -0700
committerJosh Rahm <joshuarahm@gmail.com>2022-11-21 20:57:42 -0700
commit8888a83ef06d16d4bdd3c06bef721fff43f04175 (patch)
treef94c6175c935a05846b6322d29625e354ff2cd17 /src/Rahm/Desktop/StackSet.hs
parente76a1c089951a72055bc8fc35808ccfa8988ddec (diff)
parent7d6e83479719e04b77a8230a7ecf03e971cd5fc6 (diff)
downloadrde-8888a83ef06d16d4bdd3c06bef721fff43f04175.tar.gz
rde-8888a83ef06d16d4bdd3c06bef721fff43f04175.tar.bz2
rde-8888a83ef06d16d4bdd3c06bef721fff43f04175.zip
Merge branch 'v017' of josher.dev:rde into v017
Diffstat (limited to 'src/Rahm/Desktop/StackSet.hs')
-rw-r--r--src/Rahm/Desktop/StackSet.hs116
1 files changed, 64 insertions, 52 deletions
diff --git a/src/Rahm/Desktop/StackSet.hs b/src/Rahm/Desktop/StackSet.hs
index 6b90fab..6c425aa 100644
--- a/src/Rahm/Desktop/StackSet.hs
+++ b/src/Rahm/Desktop/StackSet.hs
@@ -1,33 +1,35 @@
-module Rahm.Desktop.StackSet (
- masterWindow,
- findWorkspace,
- ensureWorkspace,
- swapWorkspaces,
- greedyView,
- shiftWin,
- screenRotateBackward,
- screenRotateForward,
- mapWindows,
- swapWindows,
- getLocationWorkspace,
- WindowLocation(..),
- windowMemberOfWorkspace,
- findWindow,
- module W) where
+module Rahm.Desktop.StackSet
+ ( masterWindow,
+ findWorkspace,
+ ensureWorkspace,
+ swapWorkspaces,
+ greedyView,
+ shiftWin,
+ screenRotateBackward,
+ screenRotateForward,
+ mapWindows,
+ swapWindows,
+ getLocationWorkspace,
+ WindowLocation (..),
+ windowMemberOfWorkspace,
+ findWindow,
+ module W,
+ )
+where
-import Prelude hiding (head)
-import Data.List.Safe (head)
+import Data.Default
import Data.List (find)
+import Data.List.Safe (head)
+import qualified Data.Map as Map
+import Data.Maybe (catMaybes, fromMaybe, listToMaybe)
import XMonad.StackSet as W hiding (greedyView, shiftWin)
import qualified XMonad.StackSet
-import Data.Default
-import Data.Maybe (fromMaybe, catMaybes, listToMaybe)
-import qualified Data.Map as Map
+import Prelude hiding (head)
-data WindowLocation i l a s sd =
- OnScreen (Screen i l a s sd) |
- OnHiddenWorkspace (Workspace i l a) |
- Floating
+data WindowLocation i l a s sd
+ = OnScreen (Screen i l a s sd)
+ | OnHiddenWorkspace (Workspace i l a)
+ | Floating
getLocationWorkspace :: WindowLocation i l a s sd -> Maybe (Workspace i l a)
getLocationWorkspace (OnScreen (Screen w _ _)) = Just w
@@ -55,32 +57,43 @@ swapWindows toSwap = mapWindows $ \w ->
masterWindow :: StackSet i l a s sd -> Maybe a
masterWindow = head . integrate' . stack . workspace . current
-findWorkspace :: (Eq i) =>
- i -> StackSet i l a s sd -> Maybe (Workspace i l a)
-findWorkspace wid = find ((==wid) . tag) . workspaces
+findWorkspace ::
+ (Eq i) =>
+ i ->
+ StackSet i l a s sd ->
+ Maybe (Workspace i l a)
+findWorkspace wid = find ((== wid) . tag) . workspaces
-ensureWorkspace :: (Eq i) =>
- i -> StackSet i l a s sd -> (StackSet i l a s sd, Workspace i l a)
+ensureWorkspace ::
+ (Eq i) =>
+ i ->
+ StackSet i l a s sd ->
+ (StackSet i l a s sd, Workspace i l a)
ensureWorkspace t ss =
case findWorkspace t ss of
Nothing ->
- let ws = Workspace t (layout . workspace . current $ ss) Nothing in
- (ss { hidden = ws : hidden ss }, ws)
+ let ws = Workspace t (layout . workspace . current $ ss) Nothing
+ in (ss {hidden = ws : hidden ss}, ws)
Just ws -> (ss, ws)
swapWorkspaces ::
(Eq i) =>
- i -> i -> StackSet i l a s sd -> StackSet i l a s sd
+ i ->
+ i ->
+ StackSet i l a s sd ->
+ StackSet i l a s sd
swapWorkspaces wid1 wid2 ss =
let (ss', workspace1) = ensureWorkspace wid1 ss
(ss'', workspace2) = ensureWorkspace wid2 ss'
- in
- mapWorkspace (\w ->
- case () of
- _ | tag w == wid1 -> workspace2
- _ | tag w == wid2 -> workspace1
- _ -> w) ss''
-
+ in mapWorkspace
+ ( \w ->
+ case () of
+ _ | tag w == wid1 -> workspace2
+ _ | tag w == wid2 -> workspace1
+ _ -> w
+ )
+ ss''
+
greedyView :: (Eq i) => i -> StackSet i l a s sd -> StackSet i l a s sd
greedyView wid ss = swapWorkspaces (tag . workspace . current $ ss) wid ss
@@ -91,17 +104,17 @@ 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
+ (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
+ (current' : visible') = zipWith (\s w -> s {workspace = w}) screens workspaces
+ in W.StackSet current' visible' others floating
+ where
+ rcycle l = last l : l
{- Finds a Window and returns the screen its on and the workspace its on.
- Returns nothing if the window doesn't exist.
@@ -109,13 +122,12 @@ screenRotateForward (W.StackSet current visible others floating) = do
- If the window is not a screen Just (Nothing, workspace) is returned.
- If the window is a floating window Just (Nothing, Nothing) is returned. -}
findWindow ::
- (Eq a) => StackSet i l a s sd -> a -> Maybe (WindowLocation i l a s sd)
+ (Eq a) => StackSet i l a s sd -> a -> Maybe (WindowLocation i l a s sd)
findWindow (StackSet cur vis hid float) win =
- listToMaybe . catMaybes $
- map findWindowScreen (cur : vis) ++
- map findWindowWorkspace hid ++
- [findWindowFloat]
-
+ listToMaybe . catMaybes $
+ map findWindowScreen (cur : vis)
+ ++ map findWindowWorkspace hid
+ ++ [findWindowFloat]
where
findWindowScreen s@(Screen ws _ _) =
if windowMemberOfWorkspace ws win