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