3 # Copyright © 2008, 2015 Nick Bowler
5 # Emits an FVWM directed resize command based on the position of the mouse
6 # cursor within a window (mouseX, mouseY) and the width and height of the
7 # window (windowW, windowH).
9 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
10 # This is free software: you are free to do what the fuck you want to.
11 # There is NO WARRANTY, to the extent permitted by law.
14 printf 'usage: %s mouseX mouseY windowW windowH\n' "$0" 1>&2
18 # The window's area is divided into a 4x4 grid of equally sized rectangles.
19 # We return a resize direction depending on which rectangle was clicked,
20 # according to the following diagram:
22 # ┏━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━┓
23 # ┃ NorthWest │ North │ NorthEast ┃
24 # ┠───────────┼───────────┬───────────┼───────────┨
25 # ┃ │ NorthWest │ NorthEast │ ┃
26 # ┃ West ├───────────┼───────────┤ East ┃
27 # ┃ │ SouthWest │ SouthEast │ ┃
28 # ┠───────────┼───────────┴───────────┼───────────┨
29 # ┃ SouthWest │ South │ SouthEast ┃
30 # ┗━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━┛
34 grid_x=$(($1/$rect_w))
35 grid_y=$(($2/$rect_h))
37 case $grid_x$grid_y in
38 11|00) dir=NorthWest ;;
39 21|30) dir=NorthEast ;;
40 12|03) dir=SouthWest ;;
41 22|33) dir=SouthEast ;;
49 printf 'Resize Direction %s\n' "$dir"