module XMonad.Util.Hacks (
windowedFullscreenFixEventHook,
javaHack,
trayerAboveXmobarEventHook,
trayAbovePanelEventHook,
trayerPaddingXmobarEventHook,
trayPaddingXmobarEventHook,
trayPaddingEventHook,
) where
import XMonad
import XMonad.Hooks.StatusBar (xmonadPropLog')
import XMonad.Prelude (All (All), fi, filterM, when)
import System.Posix.Env (putEnv)
windowedFullscreenFixEventHook :: Event -> X All
windowedFullscreenFixEventHook :: Event -> X All
windowedFullscreenFixEventHook (ClientMessageEvent Dimension
_ CULong
_ Bool
_ Display
dpy Window
win Window
typ (CInt
_:[CInt]
dats)) = do
Window
wmstate <- String -> X Window
getAtom String
"_NET_WM_STATE"
Window
fullscreen <- String -> X Window
getAtom String
"_NET_WM_STATE_FULLSCREEN"
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Window
typ forall a. Eq a => a -> a -> Bool
== Window
wmstate Bool -> Bool -> Bool
&& forall a b. (Integral a, Num b) => a -> b
fromIntegral Window
fullscreen forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [CInt]
dats) forall a b. (a -> b) -> a -> b
$
Display -> Window -> (WindowAttributes -> X ()) -> X ()
withWindowAttributes Display
dpy Window
win forall a b. (a -> b) -> a -> b
$ \WindowAttributes
attrs ->
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Display -> Window -> Dimension -> Dimension -> IO ()
resizeWindow Display
dpy Window
win (forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ WindowAttributes -> CInt
wa_width WindowAttributes
attrs forall a. Num a => a -> a -> a
- CInt
1) (forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ WindowAttributes -> CInt
wa_height WindowAttributes
attrs)
Display -> Window -> Dimension -> Dimension -> IO ()
resizeWindow Display
dpy Window
win (forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ WindowAttributes -> CInt
wa_width WindowAttributes
attrs) (forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ WindowAttributes -> CInt
wa_height WindowAttributes
attrs)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Bool -> All
All Bool
True
windowedFullscreenFixEventHook Event
_ = forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Bool -> All
All Bool
True
javaHack :: XConfig l -> XConfig l
javaHack :: forall (l :: * -> *). XConfig l -> XConfig l
javaHack XConfig l
conf = XConfig l
conf
{ startupHook :: X ()
startupHook = forall (l :: * -> *). XConfig l -> X ()
startupHook XConfig l
conf
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (String -> IO ()
putEnv String
"_JAVA_AWT_WM_NONREPARENTING=1")
}
trayerAboveXmobarEventHook :: Event -> X All
trayerAboveXmobarEventHook :: Event -> X All
trayerAboveXmobarEventHook = Query Bool -> Query Bool -> Event -> X All
trayAbovePanelEventHook (Query String
className forall a. Eq a => Query a -> a -> Query Bool
=? String
"trayer") (Query String
appName forall a. Eq a => Query a -> a -> Query Bool
=? String
"xmobar")
trayAbovePanelEventHook
:: Query Bool
-> Query Bool
-> (Event -> X All)
trayAbovePanelEventHook :: Query Bool -> Query Bool -> Event -> X All
trayAbovePanelEventHook Query Bool
trayQ Query Bool
panelQ ConfigureEvent{ev_window :: Event -> Window
ev_window = Window
w, ev_above :: Event -> Window
ev_above = Window
a} | Window
a forall a. Eq a => a -> a -> Bool
== Window
none = do
X Bool -> X () -> X ()
whenX (forall a. Query a -> Window -> X a
runQuery Query Bool
trayQ 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
dpy -> do
Window
rootw <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Window
theRoot
(Window
_, Window
_, [Window]
ws) <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall a b. (a -> b) -> a -> b
$ Display -> Window -> IO (Window, Window, [Window])
queryTree Display
dpy Window
rootw
let aboveTrayWs :: [Window]
aboveTrayWs = forall a. (a -> Bool) -> [a] -> [a]
dropWhile (Window
w forall a. Eq a => a -> a -> Bool
/=) [Window]
ws
[Window]
panelWs <- forall (m :: * -> *) a.
Applicative m =>
(a -> m Bool) -> [a] -> m [a]
filterM (forall a. Query a -> Window -> X a
runQuery Query Bool
panelQ) [Window]
aboveTrayWs
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (forall (m :: * -> *) a. MonadIO m => IO a -> m a
io forall b c a. (b -> c) -> (a -> b) -> a -> c
. Display -> Window -> IO ()
lowerWindow Display
dpy) [Window]
panelWs
forall a. Monoid a => a
mempty
trayAbovePanelEventHook Query Bool
_ Query Bool
_ Event
_ = forall a. Monoid a => a
mempty
trayerPaddingXmobarEventHook :: Event -> X All
trayerPaddingXmobarEventHook :: Event -> X All
trayerPaddingXmobarEventHook = Query Bool -> String -> Event -> X All
trayPaddingXmobarEventHook (Query String
className forall a. Eq a => Query a -> a -> Query Bool
=? String
"trayer") String
"_XMONAD_TRAYPAD"
trayPaddingXmobarEventHook
:: Query Bool
-> String
-> Event -> X All
trayPaddingXmobarEventHook :: Query Bool -> String -> Event -> X All
trayPaddingXmobarEventHook Query Bool
trayQ String
prop = Query Bool -> (Int -> X ()) -> Event -> X All
trayPaddingEventHook Query Bool
trayQ forall {a}. Show a => a -> X ()
hspaceLog
where hspaceLog :: a -> X ()
hspaceLog a
width = String -> String -> X ()
xmonadPropLog' String
prop (String
"<hspace=" forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show a
width forall a. [a] -> [a] -> [a]
++ String
"/>")
trayPaddingEventHook
:: Query Bool
-> (Int -> X ())
-> Event -> X All
trayPaddingEventHook :: Query Bool -> (Int -> X ()) -> Event -> X All
trayPaddingEventHook Query Bool
trayQ Int -> X ()
widthChanged ConfigureEvent{ ev_window :: Event -> Window
ev_window = Window
w, ev_width :: Event -> CInt
ev_width = CInt
wa } = do
X Bool -> X () -> X ()
whenX (forall a. Query a -> Window -> X a
runQuery Query Bool
trayQ Window
w) forall a b. (a -> b) -> a -> b
$ Int -> X ()
widthChanged (forall a b. (Integral a, Num b) => a -> b
fi CInt
wa)
forall a. Monoid a => a
mempty
trayPaddingEventHook Query Bool
_ Int -> X ()
_ Event
_ = forall a. Monoid a => a
mempty