(我不想听到关于我想要这个太疯狂的说法!:)
焦点跟随鼠标也被称为指向焦点、指针焦点,以及(在某些实现中)松散焦点。[添加其他术语以使其更易搜索!] X-mouse。
(我不想听到关于我想要这个太疯狂的说法!:)
焦点跟随鼠标也被称为指向焦点、指针焦点,以及(在某些实现中)松散焦点。[添加其他术语以使其更易搜索!] X-mouse。
您可以通过在命令行中输入以下命令来为Terminal.app完成此操作:
defaults write com.apple.Terminal FocusFollowsMouse -bool true
对于 X11 应用程序,您可以执行以下操作:
defaults write com.apple.x11 wm_ffm -bool true
defaults write org.x.X11 wm_ffm -bool true
显然有一个叫做CodeTek Virtual Desktop的程序可以在整个系统中模拟桌面,但是它需要花费$$(而且他们从未为OSX Leopard发布过版本)。
虽然这远非完整的解决方案,但内置于OSX(10.11)中的两个便利操作是:
⌃⌥-单击(control-option-click)- 在不提升窗口的情况下切换焦点
⌘-单击(command-click)- 在不切换焦点的情况下在窗口中点击
我不确定这些快捷键是何时引入的,因为我找不到任何关于它们的书面说明。
click
是针对没有焦点的窗口的。 - undefinedSteve Yegge曾经写过一篇关于这个问题的文章,他试图编写一个合适的扩展程序但失败了。我后来也试图在OS X上寻找鼠标跟随焦点的应用程序,但同样失败了。
我已经不断地回到这个问题大约10年了,最终我找到了一个简单的解决方案:AutoRaise https://github.com/sbmpost/AutoRaise
默认情况下它启用了焦点跟随鼠标和自动提升窗口。你可以通过配置选项延迟自动提升。
它还有一个被称为“warp”的功能,当你使用 Command-Tab 切换到一个窗口时,它会将鼠标指针居中于该窗口。我之前从未知道我需要这个功能,但一旦尝试过后,就再也离不开它了!
对于 OS X 操作系统来说,鼠标跟随焦点并不是一个特别适合的输入方式,因为它的菜单栏被设计在屏幕顶部。当鼠标移出你的应用程序窗口到达菜单时,如果途中穿过了其他应用程序的窗口,那么菜单就会改变。
所以,回答 dreeves 的评论,它在 Terminal(或桌面上的任何其他单个应用程序)上完全正常工作,因为它将影响的唯一其他窗口是终端窗口,因此在切换窗口时菜单永远不会改变。而且它在 X11 上也可以正常工作,因为 X11 应用程序通常将其菜单栏嵌入窗口中,因此您无需离开窗口即可访问它们。
当然,您可以通过在焦点更改和/或菜单切换之前引入人为延迟来解决菜单更改问题,但它永远不会像在其他桌面上那样有效。
on run {input, parameters}
tell application "Finder"
if exists of application process "AutoRaise" then
quit application "/Applications/AutoRaise"
display notification "AutoRaise Stopped"
else
launch application "/Applications/AutoRaise"
display notification "AutoRaise Started"
end if
end tell
return input
end run
更新 (18-04-2019): 源代码https://github.com/sbmpost/AutoRaise
更新 (05-06-2020): 默认延迟设置为2,轮询时间缩短。这些设置可以防止鼠标快速移动时意外地窗口上升(例如到达顶部菜单)。还添加了“弯曲鼠标”功能和修复了一个内存泄漏问题。有关详细信息,请查看 README
Amethyst 支持这个功能。你可以使用 brew install amethyst
命令轻松安装。
这是我使用的配置文件,除了鼠标跟随焦点之外,它将所有功能都关闭了。将其保存到 ~/.amethyst
文件中。
{
"LAYOUTS": "----------------------",
"layouts": [
],
"MODIFIERS": "----------------------",
"Valid modifiers are": [
"option",
"shift",
"control",
"command"
],
"mod1": [
],
"mod2": [
],
"COMMANDS": "----------------------",
"Commands are": {
"cycle-layout": "Cycle layout to the next layout",
"cycle-layout-backward": "Cycle layout to the previous layout",
"focus-screen-1": "Focus the main window on the first screen",
"focus-screen-2": "Focus the main window on the second screen",
"focus-screen-3": "Focus the main window on the third screen",
"focus-screen-2": "Focus the main window on the second screen",
"focus-screen-3": "Focus the main window on the third screen",
"focus-screen-4": "Focus the main window on the fourth screen",
"throw-screen-1": "Throw the focused window to the first screen",
"throw-screen-2": "Throw the focused window to the second screen",
"throw-screen-3": "Throw the focused window to the third screen",
"throw-screen-4": "Throw the focused window to the fourth screen",
"shrink-main": "Shrink the main pane of the current layout",
"expand-main": "Expand the main pane of the current layout",
"increase-main": "Increase the number of windows in the main pane",
"decrease-main": "Decrease the number of windows in the main pane",
"focus-ccw": "Move window focus counter-clockwise on the current screen",
"focus-cw": "Move window focus clockwise on the current screen",
"swap-ccw": "Swap focused window with the next window going counter-clockwi$
"swap-cw": "Swap focused window with the next window going clockwise",
"swap-main": "Swap focused window with the main window of its screen",
"throw-space-1": "Throw the focused window to the first space",
"throw-space-2": "Throw the focused window to the second space",
"throw-space-3": "Throw the focused window to the third space",
"throw-space-4": "Throw the focused window to the fourth space",
"throw-space-5": "Throw the focused window to the fifth space",
"throw-space-6": "Throw the focused window to the sixth space",
"throw-space-7": "Throw the focused window to the seventh space",
"throw-space-8": "Throw the focused window to the eighth space",
"throw-space-9": "Throw the focused window to the ninth space",
"throw-space-8": "Throw the focused window to the eighth space",
"throw-space-9": "Throw the focused window to the ninth space",
"toggle-float": "Toggle the focused window between being floating and tiled"
},
"screens": "3",
"cycle-layout": {
"mod": "mod1",
},
"cycle-layout-backward": {
"mod": "mod2",
},
"select-tall-layout": {
"mod": "mod1"
},
"select-wide-layout": {
"mod": "mod1"
},
"select-fullscreen-layout": {
"mod": "mod1"
},
"select-column-layout": {
"mod": "mod1"
},
"mod": "mod1"
},
"focus-screen-1": {
"mod": "mod1"
},
"focus-screen-2": {
"mod": "mod1"
},
"focus-screen-3": {
"mod": "mod1"
},
"focus-screen-4": {
"mod": "mod1"
},
"throw-screen-1": {
"mod": "mod2"
},
"throw-screen-2": {
"mod": "mod2"
},
"throw-screen-3": {
"mod": "mod2"
},
"throw-screen-4": {
"mod": "mod2"
"throw-screen-4": {
"mod": "mod2"
},
"shrink-main": {
"mod": "mod1"
},
"expand-main": {
"mod": "mod1"
},
"increase-main": {
"mod": "mod1"
},
"decrease-main": {
"mod": "mod1"
},
"focus-ccw": {
"mod": "mod1"
},
"focus-cw": {
"mod": "mod1"
},
"swap-screen-ccw": {
"mod": "mod2"
},
"swap-screen-cw": {
},
"swap-screen-cw": {
"mod": "mod2"
},
"swap-ccw": {
"mod": "mod2"
},
"swap-cw": {
"mod": "mod2"
},
"swap-main": {
"mod": "mod1"
},
"throw-space-1": {
"mod": "mod2"
},
"throw-space-2": {
"mod": "mod2"
},
"throw-space-3": {
"mod": "mod2"
},
"throw-space-4": {
"mod": "mod2"
},
"mod": "mod2"
},
"throw-space-5": {
"mod": "mod2"
},
"throw-space-6": {
"mod": "mod2"
},
"throw-space-7": {
"mod": "mod2"
},
"throw-space-8": {
"mod": "mod2"
},
"throw-space-9": {
"mod": "mod2"
},
"toggle-float": {
"mod": "mod1"
},
"toggle-tiling": {
"mod": "mod2"
},
"display-current-layout": {
"mod": "mod1"
"display-current-layout": {
"mod": "mod1"
},
"MISC": "----------------------",
"floating": [],
"float-small-windows": false,
"mouse-follows-focus": false,
"focus-follows-mouse": true,
"enables-layout-hud": false,
"enables-layout-hud-on-space-change": false
}
chunkc set ffm_disable_autoraise 0
在~/.chunkwmrc
文件中。
编辑 2019-09-12:
chunkwm已被yabai取代。要安装:
brew tap koekeishiya/formulae
brew install yabai
mkdir -p ~/.config/yabai/
printf 'yabai -m config focus_follows_mouse autoraise' >> ~/.config/yabai/yabairc
brew services start yabai
defaults write com.apple.Terminal FocusFollowsMouse -string YES
同样地,对于X11窗口:
defaults write org.x.X11 wm_ffm -bool true
defaults write com.apple.x11 wm_ffm true
我不知道有其他支持此功能的应用程序。