diff options
author | Devin Mullins <me@twifkak.com> | 2008-05-12 11:06:47 +0200 |
---|---|---|
committer | Devin Mullins <me@twifkak.com> | 2008-05-12 11:06:47 +0200 |
commit | c484dd25009881c9a050d08d2aea1faa621e3b50 (patch) | |
tree | 20fab3bbf2eed5a679472655ecebc0479d4e565f /XMonad/Actions | |
parent | a9a4a6396cb32b9963dabad8d5042a7e60f8199b (diff) | |
download | XMonadContrib-c484dd25009881c9a050d08d2aea1faa621e3b50.tar.gz XMonadContrib-c484dd25009881c9a050d08d2aea1faa621e3b50.tar.xz XMonadContrib-c484dd25009881c9a050d08d2aea1faa621e3b50.zip |
X.A.WindowNavigation: simplify inr somewhat
darcs-hash:20080512090647-78224-1a2dd996d217d4be6818bf08b2f5c111f1158b41.gz
Diffstat (limited to 'XMonad/Actions')
-rw-r--r-- | XMonad/Actions/WindowNavigation.hs | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/XMonad/Actions/WindowNavigation.hs b/XMonad/Actions/WindowNavigation.hs index 2c022e1..8f24258 100644 --- a/XMonad/Actions/WindowNavigation.hs +++ b/XMonad/Actions/WindowNavigation.hs @@ -143,7 +143,7 @@ navigableTargets point dir = navigable dir point <$> windowRects -- Filters and sorts the windows in terms of what is closest from the Point in -- the Direction. navigable :: Direction -> Point -> [(Window, Rectangle)] -> [(Window, Rectangle)] -navigable d pt = sortby d . filter (inr d (fromPoint pt) . snd) +navigable d pt = sortby d . filter (inr d pt . snd) -- Produces a list of normal-state windows, on any screen. Rectangles are -- adjusted based on screen position relative to the current screen, because I'm @@ -163,23 +163,18 @@ windowRect win = withDisplay $ \dpy -> do return $ Just $ (win, Rectangle x y w h) `catchX` return Nothing -fromPoint :: Point -> FPoint -fromPoint p = P (fromIntegral $ pt_x p) (fromIntegral $ pt_y p) - --- Stolen from droundy's implementation of WindowNavigation. --- TODO: refactor, perhaps - -data FPoint = P Double Double - -inr :: Direction -> FPoint -> Rectangle -> Bool -inr D (P x y) (Rectangle l yr w h) = x >= fromIntegral l && x < fromIntegral l + fromIntegral w && - y < fromIntegral yr + fromIntegral h -inr U (P x y) (Rectangle l yr w _) = x >= fromIntegral l && x < fromIntegral l + fromIntegral w && - y > fromIntegral yr -inr R (P a x) (Rectangle b l _ w) = x >= fromIntegral l && x < fromIntegral l + fromIntegral w && - a < fromIntegral b -inr L (P a x) (Rectangle b l c w) = x >= fromIntegral l && x < fromIntegral l + fromIntegral w && - a > fromIntegral b + fromIntegral c +-- Modified from droundy's implementation of WindowNavigation. + +-- TODO: simplify this +inr :: Direction -> Point -> Rectangle -> Bool +inr D (Point px py) (Rectangle rx ry w h) = px >= rx && px < rx + fromIntegral w && + py < ry + fromIntegral h +inr U (Point px py) (Rectangle rx ry w _) = px >= rx && px < rx + fromIntegral w && + py > ry +inr R (Point px py) (Rectangle rx ry _ h) = px < rx && + py >= ry && py < ry + fromIntegral h +inr L (Point px py) (Rectangle rx ry w h) = px > rx + fromIntegral w && + py >= ry && py < ry + fromIntegral h sortby :: Direction -> [(a,Rectangle)] -> [(a,Rectangle)] sortby D = sortBy $ comparing (rect_y . snd) |