在我的 config.hs 中我使用监视器在所有窗口之上显示 wmclockmon ,如下所示:
myClckMonitor = monitor
{ prop = ClassName "DockApp" `And` Title "wmclockmon"
, rect = Rectangle (1680 - 64) 0 64 64
, persistent = False
, name = "clock"
}
myNewLayout = ModifiedLayout myClckMonitor $ smartBorders $ avoidStruts $ myLayout ||| noBorders Full
另外将其添加到manageHook的忽略中。
我现在要做的是当我将鼠标悬停(鼠标悬停)时隐藏显示器(当然,当我离开该区域时再显示它)。你有任何提示如何实现这一目标吗?
答案 0 :(得分:1)
我终于明白了!
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)
正如您所看到的,我的显示器的坐标是硬编码的! 关于如何重新显示时钟的问题仍然存在。但是,如果您切换工作区或另一个窗口,它将再次可见。这对我来说已经足够了。