aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2025-03-06 10:41:10 -0700
committerJosh Rahm <rahm@google.com>2025-03-06 10:41:10 -0700
commit1f66fa91b479946e9b4d172d88bbd5aa15676423 (patch)
treeabe9297b77769f630827c4027896d95b8f002169 /src/Rahm
parentc31124dfaa8a337e9fe16c43666482da2ca69984 (diff)
downloadrde-1f66fa91b479946e9b4d172d88bbd5aa15676423.tar.gz
rde-1f66fa91b479946e9b4d172d88bbd5aa15676423.tar.bz2
rde-1f66fa91b479946e9b4d172d88bbd5aa15676423.zip
Fix vertial alignment of WorkspaceSelect.
Diffstat (limited to 'src/Rahm')
-rw-r--r--src/Rahm/Desktop/Common.hs30
-rw-r--r--src/Rahm/Desktop/Dzen/WorkspaceSelect.hs9
2 files changed, 15 insertions, 24 deletions
diff --git a/src/Rahm/Desktop/Common.hs b/src/Rahm/Desktop/Common.hs
index 6fe9364..713a1d6 100644
--- a/src/Rahm/Desktop/Common.hs
+++ b/src/Rahm/Desktop/Common.hs
@@ -18,6 +18,7 @@ module Rahm.Desktop.Common
click,
pointerLocation,
pointerWindow,
+ pointerScreen,
getDisplayAndRoot,
floatAll,
Location (..),
@@ -47,27 +48,6 @@ import Rahm.Desktop.Logger
import qualified Rahm.Desktop.StackSet as S
import Text.Printf (printf)
import XMonad
- ( ScreenId,
- Window,
- WorkspaceId,
- X,
- XConf (config, display),
- XConfig (focusedBorderColor, normalBorderColor),
- appName,
- asks,
- focus,
- io,
- liftX,
- refresh,
- runQuery,
- setWindowBorderWidth,
- setWindowBorderWithFallback,
- stringProperty,
- title,
- windows,
- withFocused,
- withWindowSet,
- )
import qualified XMonad as X
import qualified XMonad.Hooks.ManageHelpers as X
import XMonad.Prompt (XPrompt (commandToComplete, showXPrompt))
@@ -207,6 +187,14 @@ pointerWindow = do
io $ X.queryPointer dpy root
return w
+pointerScreen ::
+ X
+ ( Maybe (S.Screen WorkspaceId (Layout Window) Window ScreenId ScreenDetail)
+ )
+pointerScreen = runMaybeT $ do
+ (x, y) <- lift pointerLocation
+ MaybeT $ X.pointScreen x y
+
pointerWorkspace :: X (Maybe WorkspaceId)
pointerWorkspace = runMaybeT $ do
(x, y) <- lift pointerLocation
diff --git a/src/Rahm/Desktop/Dzen/WorkspaceSelect.hs b/src/Rahm/Desktop/Dzen/WorkspaceSelect.hs
index 9d12e27..2108a7b 100644
--- a/src/Rahm/Desktop/Dzen/WorkspaceSelect.hs
+++ b/src/Rahm/Desktop/Dzen/WorkspaceSelect.hs
@@ -8,13 +8,14 @@ import Data.List (find, sortBy)
import Data.Ord (comparing)
import Data.Word
import qualified Graphics.X11 as X
-import Rahm.Desktop.Common (gotoWorkspace)
+import Rahm.Desktop.Common (gotoWorkspace, pointerLocation, pointerScreen)
import Rahm.Desktop.StackSet as W
import Rahm.Desktop.Submap (ButtonOrKeyEvent (ButtonPress), nextButton, nextButtonOrKeyEvent)
import System.IO
import Text.Printf (printf)
import XMonad
import XMonad.Util.Run (spawnPipe)
+import Data.Maybe (fromMaybe)
dzenSize :: (Integral a) => a
dzenSize = 100
@@ -25,12 +26,14 @@ displayDzenSelection :: X ()
displayDzenSelection = do
(W.StackSet cur vis other _floating) <- gets windowset
+ screen <- fromMaybe cur <$> pointerScreen
+
let allWorkspaces :: [(W.Workspace WorkspaceId (Layout Window) Window, ScreenType)]
allWorkspaces =
sortBy (comparing (W.tag . fst)) $
filter (not . null . W.integrate' . W.stack . fst) $
((W.workspace cur, Current) : map ((,Visible) . W.workspace) vis) ++ map (,Hidden) other
- (SD rect) = W.screenDetail cur
+ (SD rect) = W.screenDetail screen
dzenRects = calculatePositions rect allWorkspaces
rectsToWorkspaces = map (second (first W.tag)) dzenRects
@@ -66,7 +69,7 @@ displayDzenSelection = do
calculatePositions (Rectangle (toInt -> x) (toInt -> y) (toInt -> w) (toInt -> h)) as =
let nas = length as
cellSize = (w `div` nas)
- y' = fi $ (h `div` 2) - (toInt cellSize `div` 2)
+ y' = fi $ y + (h `div` 2) - (toInt cellSize `div` 2)
sz = min 200 (cellSize * 9 `div` 10)
in zipWith
(\x' a -> (embedRectangle (Rectangle (fi x') (fi y') (fi cellSize) (fi cellSize)) sz sz, a))