2011-11-16 86 views
0

在我config.hs我用一個監視器顯示wmclockmon上的所有窗口的頂部是這樣的:添加XMonad:在鼠標懸停隱藏監視器(config.hs)

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。

我現在要做的就是當我將鼠標懸停在鼠標上時隱藏顯示器(當然,當我離開該區域時再顯示它)。你有什麼提示如何實現這一點?

回答

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) 

正如你可以看到我的顯示器的座標是硬編碼! 關於如何重新顯示時鐘的問題仍然是開放的。但是,如果您切換工作區或其他窗口,它會再次顯示。這對我來說足夠了。

相關問題