要让 xdotool 转发您的鼠标点击,您需要确保它使用--window
参数定位到正确的窗口。例如,如果您的窗口 id 是 79693135,那么xdotool click --window 79693135 3
就完全按照您的意愿行事。
以下基本xmonad.hs
说明如何执行此操作以使无键盘鼠标手势正常工作:
import XMonad
import qualified XMonad.Actions.CycleWS as Workspace
import XMonad.Actions.MouseGestures ( mouseGesture, Direction2D(..) )
import qualified XMonad.Util.EZConfig as EZ
import XMonad.Util.Run ( safeSpawn )
import qualified Data.Map as Map
mouseGestureButton :: Button
mouseGestureButton = button3 -- right click
sendMouseClickToWindow :: Window -> X ()
sendMouseClickToWindow win =
safeSpawn
"xdotool" ["click", "--window", show win, show mouseGestureButton]
myMouseGestures :: [([Direction2D], Window -> X ())]
myMouseGestures =
[ ([R], const Workspace.nextWS) -- move to the next workspace
, ([L], const Workspace.prevWS) -- move to the previous workspace
, ([], sendMouseClickToWindow)
]
addMouseGestures :: XConfig a -> XConfig a
addMouseGestures =
flip EZ.additionalMouseBindings
[((0, mouseGestureButton), mouseGesture $ Map.fromList myMouseGestures)]
main = xmonad $ addMouseGestures def
注意:为此使用按钮 1 不是一个好主意,因为这会干扰选择文本和通常与按钮 1 一起使用的其他鼠标拖动功能。所以使用按钮 3(就像 OP 所做的那样)绝对是正确的想法。