aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/Keys.hs
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2023-12-06 18:03:11 -0700
committerJosh Rahm <rahm@google.com>2023-12-06 18:03:11 -0700
commit74cdda710ffa1f99d8251759a62e1bea9fc61ff5 (patch)
treea8aeb1bb9e6553263d6c9173c48f39f77856735e /src/Rahm/Desktop/Keys.hs
parent8e2466e4b9a656622878d197e0d47161e6e10c4b (diff)
downloadrde-74cdda710ffa1f99d8251759a62e1bea9fc61ff5.tar.gz
rde-74cdda710ffa1f99d8251759a62e1bea9fc61ff5.tar.bz2
rde-74cdda710ffa1f99d8251759a62e1bea9fc61ff5.zip
Add new 'selected windows' feature
This new feature creates a 'selected windows' buffer which allows the user to select windows. These windows are then automatically made the argument for a Wml window operation such as shifting. This is great for when one wants to apply an action to a set of windows which are too difficult to describe with Wml expressions. In addition, I have added a bunch of mouse bindings and key bindings to this.
Diffstat (limited to 'src/Rahm/Desktop/Keys.hs')
-rw-r--r--src/Rahm/Desktop/Keys.hs119
1 files changed, 107 insertions, 12 deletions
diff --git a/src/Rahm/Desktop/Keys.hs b/src/Rahm/Desktop/Keys.hs
index fe96338..210d4c5 100644
--- a/src/Rahm/Desktop/Keys.hs
+++ b/src/Rahm/Desktop/Keys.hs
@@ -50,7 +50,7 @@ import Rahm.Desktop.Common
runMaybeT_,
setBorderColor,
withBorderColor,
- withBorderColorM,
+ withBorderColorM, pointerWorkspace,
)
import Rahm.Desktop.DMenu (runDMenu)
import qualified Rahm.Desktop.Dragging as D
@@ -83,13 +83,19 @@ import Rahm.Desktop.Keys.Dsl
(-|-),
)
import Rahm.Desktop.Keys.Wml
- ( gotoWorkspaceFn,
+ ( addWindowToSelection,
+ clearWindowSelection,
+ getAndResetWindowSelection,
+ gotoWorkspaceFn,
moveWindowToWorkspaceFn,
readNextLocationSet,
+ readNextLocationSet',
readNextWorkspace,
readNextWorkspaceName,
readWindowsetMacro,
readWorkspaceMacro,
+ removeWindowFromSelection,
+ toggleWindowInSelection,
workspaceForString,
workspaceForStringT,
workspaceName,
@@ -130,7 +136,8 @@ import Rahm.Desktop.RebindKeys
)
import qualified Rahm.Desktop.StackSet as W
import Rahm.Desktop.Submap
- ( mapNextString,
+ ( escape,
+ mapNextString,
submap,
submapButtonsWithKey,
)
@@ -290,7 +297,7 @@ keymap = runKeys $ do
doc "Jump to a window" $
pushPendingBuffer "' " $ do
runMaybeT_ $ do
- l <- readNextLocationSet
+ l <- readNextLocationSet'
case l of
(h : _) -> lift (focusLocation h)
_ -> return ()
@@ -567,6 +574,34 @@ keymap = runKeys $ do
doc "For mosaic layout, shrink the size-share of the current window" $
sendMessage =<< shrinkPositionAlt
+ bind xK_n $ do
+ forM_
+ [ ( justMod,
+ addWindowToSelection,
+ "Add a window set to the selection set",
+ "n "
+ ),
+ ( shiftMod,
+ removeWindowFromSelection,
+ "Remove a window set from the selection set",
+ "N "
+ )
+ ]
+ $ \(m, fn, d, ch) -> do
+ m $
+ doc d $
+ pushPendingBuffer ch $ do
+ runMaybeT_ $ do
+ locset <- readNextLocationSet'
+ lift $
+ forM_ locset $ \(Location _ mWin) ->
+ mapM_ fn mWin
+
+ bind xK_period $ do
+ justMod $
+ doc "Toggle the currently focused window in the selection set; (kinda) shorthand for Mod+n . ." $
+ flip whenJust toggleWindowInSelection =<< withWindowSet (return . W.peek)
+
bind xK_m $ do
justMod $
doc
@@ -973,10 +1008,14 @@ mouseMap = runButtons $ do
bind button1 $ do
justMod $
- doc "Float and move a window" $
- \w ->
- pushPendingBuffer "Dragging" $
- focus w >> mouseMoveWindow w >> windows W.shiftMaster
+ doc
+ "Float and move a window"
+ myMouseMoveWindow
+
+ shiftMod $
+ doc
+ "Add the currently focused window to the selection set."
+ toggleWindowInSelection
bind button2 $ do
justMod $ windows . (W.shiftMaster .) . W.focusWindow
@@ -1117,10 +1156,66 @@ mouseMap = runButtons $ do
doc "Jump to the last location." $
noWindow (click >> jumpToLastLocation)
- bind button1 $
- noMod $
- doc "'drag' a workspace to another screen" $
- noWindow D.dragWorkspace
+ -- bind button1 $
+ -- noMod $
+ -- doc "'drag' a workspace to another screen" $
+ -- noWindow D.dragWorkspace
+
+ continuous $ do
+ bind button1 $
+ noMod $
+ doc
+ "add the window under the cursor to the window selection"
+ toggleWindowInSelection
+
+ bind button2 $
+ noMod $
+ doc "Clear the window selection" (noWindow clearWindowSelection)
+
+ bind button13 $
+ noMod $
+ doc "Kill the windows in the selection" $
+ noWindow $ do
+ windows <- getAndResetWindowSelection
+ forM_ windows X.killWindow
+ escape
+
+ bind button3 $
+ noMod $
+ doc "Move all the windows to the workspace the pointer is on" $
+ noWindow $ do
+ wins <- getAndResetWindowSelection
+ runMaybeT_ $ do
+ ws <- MaybeT pointerWorkspace
+ lift $
+ let f =
+ appEndo
+ ( mconcat (map (Endo . W.shiftWin ws) wins)
+ )
+ in windows f >> escape
+
+ bind button15 $ noMod $ doc "" $ noWindow (return () :: X ())
+
+ forM_ [(button7, ",.", "right"), (button6, ";.", "left")] $
+ \(b, mot, d) -> do
+ bind b $
+ noMod $
+ doc
+ ( "Move the selected windows to the workspace on the \
+ \screen to the "
+ ++ d
+ )
+ $ noWindow $ do
+ wins <- getAndResetWindowSelection
+ runMaybeT_ $ do
+ ws' <- workspaceForStringT mot
+ ws <- MaybeT . return $ workspaceName ws'
+ lift $
+ let f =
+ appEndo
+ ( mconcat (map (Endo . W.shiftWin ws) wins)
+ )
+ in windows f >> escape
let workspaceButtons =
[ ( button2,