mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
X.A.FloatKeys: Add direction{Move,Resize}Window
These are simpler, more easily understood, alternatives to the existing functions. Fixes: https://github.com/xmonad/xmonad-contrib/issues/712
This commit is contained in:
parent
3d65a6bf72
commit
4c8edd3bfb
@ -74,6 +74,11 @@
|
|||||||
and `manyTill` functions, in order to achieve feature parity with
|
and `manyTill` functions, in order to achieve feature parity with
|
||||||
`Text.ParserCombinators.ReadP`.
|
`Text.ParserCombinators.ReadP`.
|
||||||
|
|
||||||
|
* `XMonad.Actions.FloatKeys`
|
||||||
|
|
||||||
|
- Added `directionMoveWindow` and `directionMoveWindow` as more
|
||||||
|
alternatives to the existing functions.
|
||||||
|
|
||||||
### Other changes
|
### Other changes
|
||||||
|
|
||||||
## 0.17.1 (September 3, 2022)
|
## 0.17.1 (September 3, 2022)
|
||||||
|
@ -19,11 +19,15 @@ module XMonad.Actions.FloatKeys (
|
|||||||
keysMoveWindowTo,
|
keysMoveWindowTo,
|
||||||
keysResizeWindow,
|
keysResizeWindow,
|
||||||
keysAbsResizeWindow,
|
keysAbsResizeWindow,
|
||||||
|
directionMoveWindow,
|
||||||
|
directionResizeWindow,
|
||||||
|
Direction2D(..),
|
||||||
P, G, ChangeDim
|
P, G, ChangeDim
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
import XMonad.Prelude (fi)
|
import XMonad.Prelude (fi)
|
||||||
|
import XMonad.Util.Types
|
||||||
|
|
||||||
-- $usage
|
-- $usage
|
||||||
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
||||||
@ -38,9 +42,37 @@ import XMonad.Prelude (fi)
|
|||||||
-- > , ((modm .|. shiftMask, xK_s ), withFocused (keysAbsResizeWindow (10,10) (1024,752)))
|
-- > , ((modm .|. shiftMask, xK_s ), withFocused (keysAbsResizeWindow (10,10) (1024,752)))
|
||||||
-- > , ((modm, xK_a ), withFocused (keysMoveWindowTo (512,384) (1%2,1%2)))
|
-- > , ((modm, xK_a ), withFocused (keysMoveWindowTo (512,384) (1%2,1%2)))
|
||||||
--
|
--
|
||||||
|
-- Using "XMonad.Util.EZConfig" syntax, we can easily build keybindings
|
||||||
|
-- where @M-<arrow-keys>@ moves the currently focused window and
|
||||||
|
-- @M-S-<arrow-keys>@ resizes it using 'directionMoveWindow' and
|
||||||
|
-- 'directionResizeWindow':
|
||||||
|
--
|
||||||
|
-- > [ ("M-" <> m <> k, withFocused $ f i)
|
||||||
|
-- > | (i, k) <- zip [U, D, R, L] ["<Up>", "<Down>", "<Right>", "<Left>"]
|
||||||
|
-- > , (f, m) <- [(directionMoveWindow 10, ""), (directionResizeWindow 10, "S-")]
|
||||||
|
-- > ]
|
||||||
|
--
|
||||||
-- For detailed instructions on editing your key bindings, see
|
-- For detailed instructions on editing your key bindings, see
|
||||||
-- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
|
-- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
|
||||||
|
|
||||||
|
-- | @directionMoveWindow delta dir win@ moves the window @win@ by
|
||||||
|
-- @delta@ pixels in direction @dir@.
|
||||||
|
directionMoveWindow :: Int -> Direction2D -> Window -> X ()
|
||||||
|
directionMoveWindow delta dir win = case dir of
|
||||||
|
U -> keysMoveWindow (0, -delta) win
|
||||||
|
D -> keysMoveWindow (0, delta) win
|
||||||
|
R -> keysMoveWindow (delta, 0) win
|
||||||
|
L -> keysMoveWindow (-delta, 0) win
|
||||||
|
|
||||||
|
-- | @directionResizeWindow delta dir win@ resizes the window @win@ by
|
||||||
|
-- @delta@ pixels in direction @dir@.
|
||||||
|
directionResizeWindow :: Int -> Direction2D -> Window -> X ()
|
||||||
|
directionResizeWindow delta dir win = case dir of
|
||||||
|
U -> keysResizeWindow (0, -delta) (0, 0) win
|
||||||
|
D -> keysResizeWindow (0, delta) (0, 0) win
|
||||||
|
R -> keysResizeWindow (delta, 0) (0, 0) win
|
||||||
|
L -> keysResizeWindow (-delta, 0) (0, 0) win
|
||||||
|
|
||||||
-- | @keysMoveWindow (dx, dy)@ moves the window by @dx@ pixels to the
|
-- | @keysMoveWindow (dx, dy)@ moves the window by @dx@ pixels to the
|
||||||
-- right and @dy@ pixels down.
|
-- right and @dy@ pixels down.
|
||||||
keysMoveWindow :: ChangeDim -> Window -> X ()
|
keysMoveWindow :: ChangeDim -> Window -> X ()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user