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) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$ (Display -> X ()) -> X ()
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X ()) -> X ()) -> (Display -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ \Display
d ->
Display -> Window -> (WindowAttributes -> X ()) -> X ()
withWindowAttributes Display
d Window
w ((WindowAttributes -> X ()) -> X ())
-> (WindowAttributes -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ \WindowAttributes
wa -> do
sh <- IO SizeHints -> X SizeHints
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO SizeHints -> X SizeHints) -> IO SizeHints -> X SizeHints
forall a b. (a -> b) -> a -> b
$ Display -> Window -> IO SizeHints
getWMNormalHints Display
d Window
w
io $ warpPointer d none w 0 0 0 0 (fromIntegral (wa_width wa)) (fromIntegral (wa_height wa))
mouseDrag (\Int32
ex Int32
ey -> do
let x :: Int32
x = Int32
ex Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- CInt -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (WindowAttributes -> CInt
wa_x WindowAttributes
wa)
y :: Int32
y = Int32
ey Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- CInt -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (WindowAttributes -> CInt
wa_y WindowAttributes
wa)
sz :: (Int32, Int32)
sz = if Bool
c then (Int32 -> Int32 -> Int32
forall a. Ord a => a -> a -> a
max Int32
x Int32
y, Int32 -> Int32 -> Int32
forall a. Ord a => a -> a -> a
max Int32
x Int32
y) else (Int32
x,Int32
y)
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> Window -> Word32 -> Word32 -> IO ()
resizeWindow Display
d Window
w (Word32 -> Word32 -> IO ()) -> (Word32, Word32) -> IO ()
forall a b c. (a -> b -> c) -> (a, b) -> c
`uncurry`
SizeHints -> (Int32, Int32) -> (Word32, Word32)
forall a. Integral a => SizeHints -> (a, a) -> (Word32, Word32)
applySizeHintsContents SizeHints
sh (Int32, Int32)
sz
Window -> X ()
float Window
w)
(float w)