module XMonad.Actions.ConstrainedResize (
XMonad.Actions.ConstrainedResize.mouseResizeWindow
) where
import XMonad
mouseResizeWindow :: Window -> Bool -> X ()
mouseResizeWindow :: Window -> Bool -> X ()
mouseResizeWindow Window
w Bool
c = X Bool -> X () -> X ()
whenX (Window -> X Bool
isClient Window
w) forall a b. (a -> b) -> a -> b
$ forall a. (Display -> X a) -> X a
withDisplay forall a b. (a -> b) -> a -> b
$ \Display
d ->
Display -> Window -> (WindowAttributes -> X ()) -> X ()
withWindowAttributes Display
d Window
w forall a b. (a -> b) -> a -> b
$ \WindowAttributes
wa -> do
SizeHints
sh <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ Display -> Window -> IO SizeHints
getWMNormalHints Display
d Window
w
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ Display
-> Window
-> Window
-> Position
-> Position
-> Dimension
-> Dimension
-> Position
-> Position
-> IO ()
warpPointer Display
d Window
none Window
w Position
0 Position
0 Dimension
0 Dimension
0 (forall a b. (Integral a, Num b) => a -> b
fromIntegral (WindowAttributes -> CInt
wa_width WindowAttributes
wa)) (forall a b. (Integral a, Num b) => a -> b
fromIntegral (WindowAttributes -> CInt
wa_height WindowAttributes
wa))
(Position -> Position -> X ()) -> X () -> X ()
mouseDrag (\Position
ex Position
ey -> do
let x :: Position
x = Position
ex forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fromIntegral (WindowAttributes -> CInt
wa_x WindowAttributes
wa)
y :: Position
y = Position
ey forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fromIntegral (WindowAttributes -> CInt
wa_y WindowAttributes
wa)
sz :: (Position, Position)
sz = if Bool
c then (forall a. Ord a => a -> a -> a
max Position
x Position
y, forall a. Ord a => a -> a -> a
max Position
x Position
y) else (Position
x,Position
y)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ Display -> Window -> Dimension -> Dimension -> IO ()
resizeWindow Display
d Window
w forall a b c. (a -> b -> c) -> (a, b) -> c
`uncurry`
forall a. Integral a => SizeHints -> (a, a) -> D
applySizeHintsContents SizeHints
sh (Position, Position)
sz
Window -> X ()
float Window
w)
(Window -> X ()
float Window
w)