Add function to detect floating windows in ManageHook

Add a willFloat function to deteect whether the managed window will be
floating or not

Add description of added change to CHANGES.md
This commit is contained in:
Andrea Berlingieri 2022-01-22 21:56:53 +01:00
parent eee0a0dc39
commit b6af6bb86a
2 changed files with 11 additions and 0 deletions

View File

@ -51,6 +51,9 @@
* Added `withUnfocused` function to `XMonad.Operations`, allowing for `X`
operations to be applied to unfocused windows.
* Added `willFloat` function to `XMonad.ManageHooks` to detect whether the
(about to be) managed window will be a floating window or not
[these build scripts]: https://github.com/xmonad/xmonad-testing/tree/master/build-scripts
### Bug Fixes

View File

@ -106,6 +106,14 @@ getStringProperty d w p = do
md <- io $ getWindowProperty8 d a w
return $ fmap (map (toEnum . fromIntegral)) md
-- | Return whether the window will be a floating window or not
willFloat :: Query Bool
willFloat = ask >>= \w -> liftX $ withDisplay $ \d -> do
sh <- io $ getWMNormalHints d w
let isFixedSize = isJust (sh_min_size sh) && sh_min_size sh == sh_max_size sh
isTransient <- isJust <$> io (getTransientForHint d w)
return (isFixedSize || isTransient)
-- | Modify the 'WindowSet' with a pure function.
doF :: (s -> s) -> Query (Endo s)
doF = return . Endo