mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
add more flexible withWindowNavigationKeys
Names aren't permanent yet, so don't cry if they change.
This commit is contained in:
parent
255a04753e
commit
cdeb842834
@ -19,6 +19,8 @@ module XMonad.Actions.WindowNavigation (
|
|||||||
-- * Usage
|
-- * Usage
|
||||||
-- $usage
|
-- $usage
|
||||||
withWindowNavigation,
|
withWindowNavigation,
|
||||||
|
withWindowNavigationKeys,
|
||||||
|
WNAction(..),
|
||||||
go, swap,
|
go, swap,
|
||||||
Direction(..)
|
Direction(..)
|
||||||
) where
|
) where
|
||||||
@ -28,6 +30,7 @@ import XMonad.Hooks.ManageDocks (Direction(..))
|
|||||||
import qualified XMonad.StackSet as W
|
import qualified XMonad.StackSet as W
|
||||||
|
|
||||||
import Control.Applicative ((<$>))
|
import Control.Applicative ((<$>))
|
||||||
|
import Control.Arrow (second)
|
||||||
import Data.IORef
|
import Data.IORef
|
||||||
import Data.List (sortBy)
|
import Data.List (sortBy)
|
||||||
import Data.Map (Map())
|
import Data.Map (Map())
|
||||||
@ -40,8 +43,8 @@ import Graphics.X11.Xlib
|
|||||||
-- Don't use it! What, are you crazy?
|
-- Don't use it! What, are you crazy?
|
||||||
|
|
||||||
-- TODO:
|
-- TODO:
|
||||||
|
-- - implement swap
|
||||||
-- - cleanup
|
-- - cleanup
|
||||||
-- - actually deal with multiple screens
|
|
||||||
-- - documentation :)
|
-- - documentation :)
|
||||||
-- - tests? (esp. for edge cases in currentPosition)
|
-- - tests? (esp. for edge cases in currentPosition)
|
||||||
-- - solve the 2+3, middle right to bottom left problem
|
-- - solve the 2+3, middle right to bottom left problem
|
||||||
@ -49,14 +52,22 @@ import Graphics.X11.Xlib
|
|||||||
|
|
||||||
-- TODO: more flexible api
|
-- TODO: more flexible api
|
||||||
withWindowNavigation :: (KeySym, KeySym, KeySym, KeySym) -> XConfig l -> IO (XConfig l)
|
withWindowNavigation :: (KeySym, KeySym, KeySym, KeySym) -> XConfig l -> IO (XConfig l)
|
||||||
withWindowNavigation (u,l,d,r) conf = do
|
withWindowNavigation (u,l,d,r) conf =
|
||||||
|
withWindowNavigationKeys [ ((modMask conf, u), WNGo U),
|
||||||
|
((modMask conf, l), WNGo L),
|
||||||
|
((modMask conf, d), WNGo D),
|
||||||
|
((modMask conf, r), WNGo R) ]
|
||||||
|
conf
|
||||||
|
|
||||||
|
withWindowNavigationKeys :: [((KeyMask, KeySym), WNAction)] -> XConfig l -> IO (XConfig l)
|
||||||
|
withWindowNavigationKeys wnKeys conf = do
|
||||||
posRef <- newIORef M.empty
|
posRef <- newIORef M.empty
|
||||||
return conf { keys = \cnf -> M.fromList [
|
return conf { keys = \cnf -> M.fromList (map (second (fromWNAction posRef)) wnKeys)
|
||||||
((modMask cnf, u), go posRef U),
|
`M.union` keys conf cnf }
|
||||||
((modMask cnf, l), go posRef L),
|
where fromWNAction posRef (WNGo dir) = go posRef dir
|
||||||
((modMask cnf, d), go posRef D),
|
fromWNAction posRef (WNSwap dir) = swap posRef dir
|
||||||
((modMask cnf, r), go posRef R)
|
|
||||||
] `M.union` (keys conf cnf) }
|
data WNAction = WNGo Direction | WNSwap Direction
|
||||||
|
|
||||||
type WNState = Map WorkspaceId Point
|
type WNState = Map WorkspaceId Point
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user