You can use this module with the following in your ~/.xmonad/xmonad.hs:
import XMonad.Actions.FloatSnap
Then add appropriate key bindings, for example:
, ((modm, xK_Left), withFocused $ snapMove L Nothing)
, ((modm, xK_Right), withFocused $ snapMove R Nothing)
, ((modm, xK_Up), withFocused $ snapMove U Nothing)
, ((modm, xK_Down), withFocused $ snapMove D Nothing)
, ((modm .|. shiftMask, xK_Left), withFocused $ snapShrink R Nothing)
, ((modm .|. shiftMask, xK_Right), withFocused $ snapGrow R Nothing)
, ((modm .|. shiftMask, xK_Up), withFocused $ snapShrink D Nothing)
, ((modm .|. shiftMask, xK_Down), withFocused $ snapGrow D Nothing)
For detailed instructions on editing your key bindings, see
XMonad.Doc.Extending.
And possibly add an appropriate mouse binding, for example:
, ((modm, button1), (\w -> focus w >> mouseMoveWindow w >> snapMagicMove (Just 50) (Just 50) w))
, ((modm .|. shiftMask, button1), (\w -> focus w >> mouseMoveWindow w >> snapMagicResize [L,R,U,D] (Just 50) (Just 50) w))
, ((modm, button3), (\w -> focus w >> mouseResizeWindow w >> snapMagicResize [R,D] (Just 50) (Just 50) w))
For detailed instructions on editing your mouse bindings, see
XMonad.Doc.Extending.
Using these mouse bindings, it will not snap while moving, but allow you to click the window once after it has been moved or resized to snap it into place.
Note that the order in which the commands are applied in the mouse bindings are important.
Interesting values for the distance to look for window in the orthogonal axis are Nothing (to snap against every window), Just 0 (to only snap
against windows that we should collide with geometrically while moving) and Just 1 (to also snap against windows we brush against).
For snapMagicMove, snapMagicResize and snapMagicMouseResize, try instead setting it to the same as the maximum snapping distance.
When a value is specified it can be geometrically conceived as adding a border with the specified width around the window and then checking which
windows it should collide with.
|