From 1ec1d0ae5da56e9f259ca09837fcc88c1f9a8312 Mon Sep 17 00:00:00 2001 From: Devin Mullins Date: Thu, 15 May 2008 07:33:30 +0200 Subject: 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. darcs-hash:20080515053330-78224-2ba67cefda58b7c079b23f93441859e30c539c73.gz --- XMonad/Actions/WindowNavigation.hs | 14 ++++++++------ XMonad/Hooks/UrgencyHook.hs | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'XMonad') diff --git a/XMonad/Actions/WindowNavigation.hs b/XMonad/Actions/WindowNavigation.hs index d819d35..dc04737 100644 --- a/XMonad/Actions/WindowNavigation.hs +++ b/XMonad/Actions/WindowNavigation.hs @@ -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 - _ -> return (middleOf currentRect) + 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) diff --git a/XMonad/Hooks/UrgencyHook.hs b/XMonad/Hooks/UrgencyHook.hs index 93ec90c..308b9a7 100644 --- a/XMonad/Hooks/UrgencyHook.hs +++ b/XMonad/Hooks/UrgencyHook.hs @@ -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, -- cgit v1.2.3