From 74cdda710ffa1f99d8251759a62e1bea9fc61ff5 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Wed, 6 Dec 2023 18:03:11 -0700 Subject: 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. --- src/Rahm/Desktop/Common.hs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/Rahm/Desktop/Common.hs') 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 + -- cgit