我終於明白了!
我xmonad.hs的相應部分:
import Data.IORef
import XMonad.Layout.Monitor
myClckMonitor = monitor
{ prop = ClassName "DockApp" `And` Title "wmclockmon"
, rect = Rectangle (1680 - 64) 0 64 64
, persistent = False
, name = "clock"
}
screenRectEventHook :: Event -> X All
screenRectEventHook CrossingEvent { ev_window = win } = do
dpy <- asks display
root <- asks theRoot
(posX, posY, acc) <- io $ do
-- queryPointer :: Display -> Window -> IO (Bool, Window, Window, Int, Int, Int, Int, Modifier)
-- interface to the X11 library function XQueryPointer().
(_, _, _, ix, iy, _, _, _) <- queryPointer dpy root
r <- newIORef Nothing
return (fromIntegral ix, fromIntegral iy, r)
if (posY < 64 && posX > (1680 - 64))
then do
broadcastMessage HideMonitor >> refresh
return (All True)
else do
broadcastMessage ShowMonitor >> refresh
return (All True)
screenRectEventHook _ = return (All True)
,然後註冊事件掛鉤:
myEventHook e = do
screenRectEventHook e
return (All True)
正如你可以看到我的顯示器的座標是硬編碼! 關於如何重新顯示時鐘的問題仍然是開放的。但是,如果您切換工作區或其他窗口,它會再次顯示。這對我來說足夠了。