aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/Common.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/Common.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/Common.hs')
-rw-r--r--src/Rahm/Desktop/Common.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/Rahm/Desktop/Common.hs b/src/Rahm/Desktop/Common.hs
index 5c29a1c..71ffad0 100644
--- a/src/Rahm/Desktop/Common.hs
+++ b/src/Rahm/Desktop/Common.hs
@@ -2,6 +2,7 @@ module Rahm.Desktop.Common
( focusLocation,
masterWindow,
windowsInWorkspace,
+ pointerWorkspace,
getString,
askWindowId,
windowJump,
@@ -17,6 +18,9 @@ module Rahm.Desktop.Common
runMaybeT_,
setBorderColor,
click,
+ pointerLocation,
+ pointerWindow,
+ getDisplayAndRoot,
Location (..),
)
where
@@ -225,3 +229,27 @@ click = do
(dpy, root) <- asks $ (,) <$> display <*> X.theRoot
(_, _, window, _, _, _, _, _) <- io $ X.queryPointer dpy root
focus window
+
+getDisplayAndRoot :: X (X.Display, X.Window)
+getDisplayAndRoot = X.asks $ (,) <$> X.display <*> X.theRoot
+
+pointerLocation :: (Integral a, Integral b) => X (a, b)
+pointerLocation = do
+ (dpy, root) <- getDisplayAndRoot
+ (_, _, _, fromIntegral -> x, fromIntegral -> y, _, _, _) <-
+ io $ X.queryPointer dpy root
+ return (x, y)
+
+pointerWindow :: X X.Window
+pointerWindow = do
+ (dpy, root) <- getDisplayAndRoot
+ (_, _, w, _, _, _, _, _) <-
+ io $ X.queryPointer dpy root
+ return w
+
+pointerWorkspace :: X (Maybe WorkspaceId)
+pointerWorkspace = runMaybeT $ do
+ (x, y) <- lift pointerLocation
+ (S.Screen (S.tag -> ws1) _ _) <- MaybeT $ X.pointScreen x y
+ return ws1
+