【发布时间】:2016-01-03 15:11:13
【问题描述】:
谁能告诉我如何防止鼠标离开某个窗口或全屏游戏?尝试了三个 Steam 游戏(Satellite Reign、Cities:Skylines 和 Civ 5),都有相同的问题:只要我在边框上移动鼠标(用于屏幕平移),焦点就会切换到我的第二台显示器。
非常欢迎任何有关正确来源的建议或提示(我猜鼠标行为是自定义客户端属性?) :)
谢谢!
【问题讨论】:
标签: fullscreen steam awesome-wm
谁能告诉我如何防止鼠标离开某个窗口或全屏游戏?尝试了三个 Steam 游戏(Satellite Reign、Cities:Skylines 和 Civ 5),都有相同的问题:只要我在边框上移动鼠标(用于屏幕平移),焦点就会切换到我的第二台显示器。
非常欢迎任何有关正确来源的建议或提示(我猜鼠标行为是自定义客户端属性?) :)
谢谢!
【问题讨论】:
标签: fullscreen steam awesome-wm
很棒的 wm 信号可能很有用。这是一个简单的示例(更像是提示)它是如何工作的。
把它放在 rc.lua 开头的某个地方
local is_mouse_locked = false
这段代码放在client.connect_signal("manage", function (c, startup)块内
-- in this example
-- signal connected to every window and make action if 'is_mouse_locked' switcher active
-- however much better would be connect and disconnect signal to certain window by hotkey
c:connect_signal("mouse::leave",
function(c)
if is_mouse_locked then
local cg = c:geometry() -- get window size
local mg = mouse.coords() -- get current mouse position
-- quick and dirty calculate for mouse position correction
local newx = mg.x <= cg.x and cg.x + 5 or mg.x >= (cg.x + cg.width) and cg.x + cg.width - 5 or mg.x
local newy = mg.y <= cg.y and cg.y + 5 or mg.y >= (cg.y + cg.height) and cg.y + cg.height - 5 or mg.y
-- set mouse to new position
mouse.coords({ x = newx, y = newy })
end
end
)
并将其添加到热键
awful.key({ modkey, }, "v", function () is_mouse_locked = not is_mouse_locked end),
【讨论】: