xmonad-contrib-0.17.1: Community-maintained extensions for xmonad

Copyright | (c) 2009 Anders Engstrom <ankaan@gmail.com>
License | BSD3-style (see LICENSE)
Maintainer | Anders Engstrom <ankaan@gmail.com>
Stability | unstable
Portability | unportable
Safe Haskell | Safe-Inferred
Language | Haskell2010

XMonad.Actions.FloatSnap

Contents

- Usage

Description

Move and resize floating windows using other windows and the edge of the screen as guidelines.

Synopsis

- data Direction2D
  - = U
  - | D
  - | R
  - | L
- snapMove :: Direction2D -> Maybe Int -> Window -> X ()
- snapGrow :: Direction2D -> Maybe Int -> Window -> X ()
- snapShrink :: Direction2D -> Maybe Int -> Window -> X ()
- snapMagicMove :: Maybe Int -> Maybe Int -> Window -> X ()
- snapMagicResize :: [Direction2D] -> Maybe Int -> Maybe Int -> Window -> X ()
- snapMagicMouseResize :: Rational -> Maybe Int -> Maybe Int -> Window -> X ()
- afterDrag :: X () -> X ()
- ifClick :: X () -> X ()
- ifClick' :: Int -> X () -> X () -> X ()

# Usage

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 appropriate mouse bindings, for example:

           , ((modm,               button1), (\w -> focus w >> mouseMoveWindow w >> ifClick (snapMagicMove (Just 50) (Just 50) w)))
           , ((modm .|. shiftMask, button1), (\w -> focus w >> mouseMoveWindow w >> ifClick (snapMagicResize [L,R,U,D] (Just 50) (Just 50) w)))
           , ((modm,               button3), (\w -> focus w >> mouseResizeWindow w >> ifClick (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. Snapping can also be used together with other window resizing functions, such as those from XMonad.Actions.FlexibleResize

An alternative set of mouse bindings that will always snap after the drag is:

           , ((modm,               button1), (\w -> focus w >> mouseMoveWindow w >> afterDrag (snapMagicMove (Just 50) (Just 50) w)))
           , ((modm .|. shiftMask, button1), (\w -> focus w >> mouseMoveWindow w >> afterDrag (snapMagicResize [L,R,U,D] (Just 50) (Just 50) w)))
           , ((modm,               button3), (\w -> focus w >> mouseResizeWindow w >> afterDrag (snapMagicResize [R,D] (Just 50) (Just 50) w)))

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.

data Direction2D #

Two-dimensional directions:

Constructors

U | Up
D | Down
R | Right
L | Left

#### Instances

Instances details

Bounded Direction2D # |
Instance details Defined in XMonad.Util.Types Methods minBound :: Direction2D # maxBound :: Direction2D #
Enum Direction2D # |

Instance details

Defined in XMonad.Util.Types

Methods

succ :: Direction2D -> Direction2D #

pred :: Direction2D -> Direction2D #

toEnum :: Int -> Direction2D #

fromEnum :: Direction2D -> Int #

enumFrom :: Direction2D -> [Direction2D] #

enumFromThen :: Direction2D -> Direction2D -> [Direction2D] #

enumFromTo :: Direction2D -> Direction2D -> [Direction2D] #

enumFromThenTo :: Direction2D -> Direction2D -> Direction2D -> [Direction2D] #

Read Direction2D # |
Instance details Defined in XMonad.Util.Types Methods readsPrec :: Int -> ReadS Direction2D # readList :: ReadS [Direction2D] # readPrec :: ReadPrec Direction2D readListPrec :: ReadPrec [Direction2D]
Show Direction2D # |
Instance details Defined in XMonad.Util.Types Methods showsPrec :: Int -> Direction2D -> ShowS # show :: Direction2D -> String # showList :: [Direction2D] -> ShowS #
Eq Direction2D # |
Instance details Defined in XMonad.Util.Types Methods (==) :: Direction2D -> Direction2D -> Bool # (/=) :: Direction2D -> Direction2D -> Bool #
Ord Direction2D # |
Instance details Defined in XMonad.Util.Types Methods compare :: Direction2D -> Direction2D -> Ordering # (<) :: Direction2D -> Direction2D -> Bool # (<=) :: Direction2D -> Direction2D -> Bool # (>) :: Direction2D -> Direction2D -> Bool # (>=) :: Direction2D -> Direction2D -> Bool # max :: Direction2D -> Direction2D -> Direction2D # min :: Direction2D -> Direction2D -> Direction2D #

snapMove #

Arguments

:: Direction2D | What direction to move the window in.
-> Maybe Int | The distance in the orthogonal axis to look for windows to snap against. Use Nothing to snap against every window.
-> Window | The window to move.
-> X () |

Move a window in the specified direction until it snaps against another window or the edge of the screen.

snapGrow #

Arguments

:: Direction2D | What edge of the window to grow.
-> Maybe Int | The distance in the orthogonal axis to look for windows to snap against. Use Nothing to snap against every window.
-> Window | The window to grow.
-> X () |

Grow the specified edge of a window until it snaps against another window or the edge of the screen.

snapShrink #

Arguments

:: Direction2D | What edge of the window to shrink.
-> Maybe Int | The distance in the orthogonal axis to look for windows to snap against. Use Nothing to snap against every window.
-> Window | The window to shrink.
-> X () |

Shrink the specified edge of a window until it snaps against another window or the edge of the screen.

snapMagicMove #

Arguments

:: Maybe Int | The distance in the orthogonal axis to look for windows to snap against. Use Nothing to snap against every window.
-> Maybe Int | The maximum distance to snap. Use Nothing to not impose any boundary.
-> Window | The window to move.
-> X () |

Move a window by both axises in any direction to snap against the closest part of other windows or the edge of the screen.

snapMagicResize #

Arguments

:: [Direction2D] | The edges to snap.
-> Maybe Int | The distance in the orthogonal axis to look for windows to snap against. Use Nothing to snap against every window.
-> Maybe Int | The maximum distance to snap. Use Nothing to not impose any boundary.
-> Window | The window to move and resize.
-> X () |

Resize the window by each edge independently to snap against the closest part of other windows or the edge of the screen.

snapMagicMouseResize #

Arguments

:: Rational | How big the middle snap area of each axis should be.
-> Maybe Int | The distance in the orthogonal axis to look for windows to snap against. Use Nothing to snap against every window.
-> Maybe Int | The maximum distance to snap. Use Nothing to not impose any boundary.
-> Window | The window to move and resize.
-> X () |

Resize the window by each edge independently to snap against the closest part of other windows or the edge of the screen. Use the location of the mouse over the window to decide which edges to snap. In corners, the two adjoining edges will be snapped, along the middle of an edge only that edge will be snapped. In the center of the window all edges will snap. Intended to be used together with XMonad.Actions.FlexibleResize or XMonad.Actions.FlexibleManipulate.

afterDrag #

Arguments

:: X () | The task to schedule.
-> X () |

Schedule a task to take place after the current dragging is completed.

ifClick #

Arguments

:: X () | The action to take if the dragging turned out to be a click.
-> X () |

Take an action if the current dragging can be considered a click, supposing the drag just started before this function is called. A drag is considered a click if it is completed within 300 ms.

ifClick' #

Arguments

:: Int | Maximum time of dragging for it to be considered a click (in milliseconds.)
-> X () | The action to take if the dragging turned out to be a click.
-> X () | The action to take if the dragging turned out to not be a click.
-> X () |

Take an action if the current dragging is completed within a certain time (in milliseconds.)