diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Main.hs | 1 | ||||
| -rw-r--r-- | src/Rahm/Desktop/Keys/Wml.hs | 21 | ||||
| -rw-r--r-- | src/Rahm/Desktop/Workspaces.hs | 46 |
3 files changed, 58 insertions, 10 deletions
diff --git a/src/Main.hs b/src/Main.hs index a9aa419..0c00be9 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -121,6 +121,7 @@ main = do className =? "MPlayer" --> doFloat, className =? "Xfce4-notifyd" --> doIgnore, className =? "popup-terminal" --> doShift "*" <> updatePopupTerminalHook, + className =? "spotify" --> doShift "s", className =? "floating-terminal" --> doCenterFloat, title =? "Event Tester" --> doFloat, title =? "Notes" --> doCenterFloat, diff --git a/src/Rahm/Desktop/Keys/Wml.hs b/src/Rahm/Desktop/Keys/Wml.hs index 0c09fd1..792ff74 100644 --- a/src/Rahm/Desktop/Keys/Wml.hs +++ b/src/Rahm/Desktop/Keys/Wml.hs @@ -93,7 +93,7 @@ import Rahm.Desktop.History ) import Rahm.Desktop.Keys.KeyFeed import Rahm.Desktop.Layout.PinWindow (pinnedWindows) -import Rahm.Desktop.Logger (LogLevel (Info, Trace), logs) +import Rahm.Desktop.Logger import Rahm.Desktop.Marking ( farLeftWindow, farRightWindow, @@ -105,14 +105,6 @@ import Rahm.Desktop.Marking import qualified Rahm.Desktop.StackSet as W import Rahm.Desktop.Submap (mapNextStringWithKeysym) import Rahm.Desktop.Workspaces - ( accompaningWorkspace, - adjacentWorkspace, - adjacentWorkspaceNotVisible, - getHorizontallyOrderedScreens, - next, - prev, - workspaceWithWindow, - ) import Rahm.Desktop.XMobarLog.PendingBuffer ( addStringToPendingBuffer, setPendingBuffer, @@ -474,12 +466,21 @@ readNextWorkspace = screens <- liftXToFeed $ map (W.tag . W.workspace . snd) - <$> withWindowSet (return . getHorizontallyOrderedScreens) + <$> withWindowSet (return . getScreensOnSamePlane) let (_, rest) = break ((== workspaceName ws) . Just) (screens ++ screens) justWorkspace <$> hoistMaybe (head $ tail rest) + -- Workspace on the screen above the current workspace.. + (_, _, "+") -> do + screens <- + liftXToFeed $ + map (W.tag . W.workspace . snd) + <$> withWindowSet (return . getScreensOnDifferentPlane) + + justWorkspace <$> hoistMaybe (head screens) + -- Workspace to the next screen to the left of the next workspace. (_, _, ";") -> do ws <- readNextWorkspace diff --git a/src/Rahm/Desktop/Workspaces.hs b/src/Rahm/Desktop/Workspaces.hs index 6f0c08a..0c70591 100644 --- a/src/Rahm/Desktop/Workspaces.hs +++ b/src/Rahm/Desktop/Workspaces.hs @@ -15,6 +15,8 @@ module Rahm.Desktop.Workspaces adjacentScreen, withScreen, workspaceWithWindow, + getScreensOnSamePlane, + getScreensOnDifferentPlane, WorkspaceState (..), ) where @@ -26,9 +28,11 @@ import Data.Char (isUpper, toLower, toUpper) import Data.List (find, sort, sortBy, sortOn, (\\)) import Data.List.Safe ((!!)) import Data.Maybe (fromMaybe, mapMaybe) +import Debug.Trace import Rahm.Desktop.Common (getCurrentWorkspace, gotoWorkspace, runMaybeT_) import Rahm.Desktop.Logger import qualified Rahm.Desktop.StackSet as W +import Text.Printf (printf) import XMonad ( Rectangle (Rectangle), ScreenDetail (SD), @@ -100,6 +104,48 @@ getHorizontallyOrderedScreens windowSet = where screens = (True, W.current windowSet) : map (False,) (W.visible windowSet) +getVerticallyOrderedScreens :: + W.StackSet wid l a ScreenId ScreenDetail -> + [(Bool, W.Screen wid l a ScreenId ScreenDetail)] +-- ^ Returns a list of screens ordered from top to bottom +getVerticallyOrderedScreens windowSet = + flip sortBy screens $ \sc1 sc2 -> + let (SD (Rectangle _ y1 _ _)) = W.screenDetail (snd sc1) + (SD (Rectangle _ y2 _ _)) = W.screenDetail (snd sc2) + in y1 `compare` y2 + where + screens = (True, W.current windowSet) : map (False,) (W.visible windowSet) + +-- | Returns screens which are horizontally ordered, but are on the same "plane" +-- as the current screen. A screen is considered on the same "plane" if it's +-- middle point is vertically oriented within the vertical boundaries of the +-- current screen. +getScreensOnSamePlane :: + W.StackSet wid l a ScreenId ScreenDetail -> + [(Bool, W.Screen wid l a ScreenId ScreenDetail)] +getScreensOnSamePlane ss = + filter matchesYCenter $ getHorizontallyOrderedScreens ss + where + yCenter + | (SD (Rectangle _ y _ h)) <- W.screenDetail . W.current $ ss = + (y + fromIntegral h) `div` 2 + matchesYCenter (_, W.screenDetail -> (SD (Rectangle _ y _ h))) = + y < yCenter && y + fromIntegral h > yCenter + +-- | Returns screens which are vertically ordered, but are on a different plane +-- from the current screen. +getScreensOnDifferentPlane :: + W.StackSet wid l a ScreenId ScreenDetail -> + [(Bool, W.Screen wid l a ScreenId ScreenDetail)] +getScreensOnDifferentPlane ss = + filter (not . matchesScreen . getYCenter . snd) $ getVerticallyOrderedScreens ss + where + getYCenter (W.screenDetail -> SD (Rectangle _ y _ h)) = + y + (fromIntegral h `div` 2) + matchesScreen yCenter + | (SD (Rectangle _ y _ h)) <- W.screenDetail (W.current ss) = + yCenter < y + fromIntegral h && yCenter > y + accompaningWorkspace :: WorkspaceId -> WorkspaceId accompaningWorkspace [s] = return $ |