mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-01 20:51:52 -07:00
Rather than writing over the vanilla Line navigation function, Hybrid navigation has been implemented separately.
This commit is contained in:
@@ -43,6 +43,7 @@ module XMonad.Actions.Navigation2D ( -- * Usage
|
|||||||
, Navigation2D
|
, Navigation2D
|
||||||
, lineNavigation
|
, lineNavigation
|
||||||
, centerNavigation
|
, centerNavigation
|
||||||
|
, hybridNavigation
|
||||||
, fullScreenRect
|
, fullScreenRect
|
||||||
, singleWindowRect
|
, singleWindowRect
|
||||||
, switchLayer
|
, switchLayer
|
||||||
@@ -74,10 +75,11 @@ import XMonad.Util.Types
|
|||||||
-- natural but may make it impossible to navigate to a given window from the
|
-- natural but may make it impossible to navigate to a given window from the
|
||||||
-- current window, particularly in the floating layer. /Center navigation/
|
-- current window, particularly in the floating layer. /Center navigation/
|
||||||
-- feels less natural in certain situations but ensures that all windows can be
|
-- feels less natural in certain situations but ensures that all windows can be
|
||||||
-- reached without the need to involve the mouse. Navigation2D allows different
|
-- reached without the need to involve the mouse. A third option is to use
|
||||||
-- navigation strategies to be used in the two layers and allows customization
|
-- /Hybrid navigation/, which automatically chooses between the two whenever
|
||||||
-- of the navigation strategy for the tiled layer based on the layout currently
|
-- navigation is attempted. Navigation2D allows different navigation strategies
|
||||||
-- in effect.
|
-- to be used in the two layers and allows customization of the navigation strategy
|
||||||
|
-- for the tiled layer based on the layout currently in effect.
|
||||||
--
|
--
|
||||||
-- You can use this module with (a subset of) the following in your @~\/.xmonad\/xmonad.hs@:
|
-- You can use this module with (a subset of) the following in your @~\/.xmonad\/xmonad.hs@:
|
||||||
--
|
--
|
||||||
@@ -316,6 +318,14 @@ lineNavigation = N 1 doLineNavigation
|
|||||||
centerNavigation :: Navigation2D
|
centerNavigation :: Navigation2D
|
||||||
centerNavigation = N 2 doCenterNavigation
|
centerNavigation = N 2 doCenterNavigation
|
||||||
|
|
||||||
|
|
||||||
|
-- | Hybrid navigation. This attempts Line navigation, then falls back on Center
|
||||||
|
-- navigation if it does not find any suitable target windows. This is useful since
|
||||||
|
-- Line navigation tends to fail on gaps, but provides more intuitive motions
|
||||||
|
-- when it succeeds, provided there are no floating windows.
|
||||||
|
hybridNavigation :: Navigation2D
|
||||||
|
hybridNavigation = N 2 doHybridNavigation
|
||||||
|
|
||||||
-- | Stores the configuration of directional navigation. The 'Default' instance
|
-- | Stores the configuration of directional navigation. The 'Default' instance
|
||||||
-- uses line navigation for the tiled layer and for navigation between screens,
|
-- uses line navigation for the tiled layer and for navigation between screens,
|
||||||
-- and center navigation for the float layer. No custom navigation strategies
|
-- and center navigation for the float layer. No custom navigation strategies
|
||||||
@@ -664,7 +674,7 @@ doScreenNavigation conf dir act cur wsrects
|
|||||||
-- these lists for all visible workspaces.)
|
-- these lists for all visible workspaces.)
|
||||||
doLineNavigation :: Eq a => Direction2D -> Rect a -> [Rect a] -> Maybe a
|
doLineNavigation :: Eq a => Direction2D -> Rect a -> [Rect a] -> Maybe a
|
||||||
doLineNavigation dir (cur, rect) winrects
|
doLineNavigation dir (cur, rect) winrects
|
||||||
| null winrects' = doCenterNavigation dir (cur, rect) winrects -- MY MODIFICATION HERE
|
| null winrects' = Nothing -- doCenterNavigation dir (cur, rect) winrects
|
||||||
| otherwise = Just . fst $ L.foldl1' closer winrects'
|
| otherwise = Just . fst $ L.foldl1' closer winrects'
|
||||||
where
|
where
|
||||||
-- The current window's center
|
-- The current window's center
|
||||||
@@ -758,6 +768,13 @@ doCenterNavigation dir (cur, rect) winrects
|
|||||||
-- or it has the same distance but comes later
|
-- or it has the same distance but comes later
|
||||||
-- in the window stack
|
-- in the window stack
|
||||||
|
|
||||||
|
-- | Implements Hybrid navigation. This attempts Line navigation first,
|
||||||
|
-- then falls back on Center navigation if it finds no suitable target window.
|
||||||
|
doHybridNavigation :: Eq a => Direction2D -> Rect a -> [Rect a] -> Maybe a
|
||||||
|
doHybridNavigation dir (cur, rect) winrects
|
||||||
|
| (doLineNavigation dir (cur, rect) winrects == Nothing) = doCenterNavigation dir (cur, rect) winrects
|
||||||
|
| otherwise = doLineNavigation dir (cur, rect) winrects
|
||||||
|
|
||||||
-- | Swaps the current window with the window given as argument
|
-- | Swaps the current window with the window given as argument
|
||||||
swap :: Window -> WindowSet -> WindowSet
|
swap :: Window -> WindowSet -> WindowSet
|
||||||
swap win winset = W.focusWindow cur
|
swap win winset = W.focusWindow cur
|
||||||
|
Reference in New Issue
Block a user