mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
X.A.WindowNavigation: have currentPosition handle axes independently
This improves some subtle interactions between mod-j/k and mod-w/a/s/d, though that might not become very apparent until I fix setPosition.
This commit is contained in:
parent
1d93dfba51
commit
7852e704fa
@ -109,22 +109,24 @@ withTargetWindow adj posRef dir = fromCurrentPoint $ \win pos -> do
|
||||
-- a restart), derives the current position from the current window. Also,
|
||||
-- verifies that the position is congruent with the current window (say, if you
|
||||
-- used mod-j/k or mouse or something).
|
||||
-- TODO: factor x + fromIntegral w `div` 2 duplication out
|
||||
currentPosition :: IORef WNState -> X Point
|
||||
currentPosition posRef = do
|
||||
root <- asks theRoot
|
||||
currentWindow <- gets (W.peek . windowset)
|
||||
currentRect <- maybe (Rectangle 0 0 0 0) snd <$> windowRect (fromMaybe root currentWindow)
|
||||
currentRect@(Rectangle rx ry rw rh) <- maybe (Rectangle 0 0 0 0) snd <$>
|
||||
windowRect (fromMaybe root currentWindow)
|
||||
|
||||
wsid <- gets (W.tag . W.workspace . W.current . windowset)
|
||||
mp <- M.lookup wsid <$> io (readIORef posRef)
|
||||
|
||||
case mp of
|
||||
Just p | p `inside` currentRect -> return p
|
||||
Just (Point x y) -> return $ Point (x `inside` (rx, rw)) (y `inside` (ry, rh))
|
||||
_ -> return (middleOf currentRect)
|
||||
|
||||
where Point px py `inside` Rectangle rx ry rw rh =
|
||||
px >= rx && px < rx + fromIntegral rw &&
|
||||
py >= ry && py < ry + fromIntegral rh
|
||||
where pos `inside` (lower, dim) = if pos >= lower && pos < lower + fromIntegral dim
|
||||
then pos
|
||||
else lower + fromIntegral dim `div` 2
|
||||
|
||||
middleOf (Rectangle x y w h) =
|
||||
Point (x + fromIntegral w `div` 2) (y + fromIntegral h `div` 2)
|
||||
|
@ -72,6 +72,8 @@ import Foreign (unsafePerformIO)
|
||||
-- > $ defaultConfig
|
||||
--
|
||||
|
||||
-- TODO: note mod-shift-space
|
||||
|
||||
-- * Setting up Irssi + rxvt-unicode
|
||||
--
|
||||
-- This is one common example. YMMV. To make messages to you trigger a dzen flash,
|
||||
|
Loading…
x
Reference in New Issue
Block a user