Focus-follows-mouse (plus auto-raise) on Mac OS X

前端 未结 21 1199
挽巷
挽巷 2020-12-07 07:00

(I don\'t want to hear about how crazy I am to want that! :)

Focus-follows-mouse is also known as point-to-focus, pointer focus, and (in some implementations) sloppy

相关标签:
21条回答
  • 2020-12-07 07:49

    Codetek had a product that did this but they never released a version for Leopard or later.

    MondoMouse can sort of do focus-follows-mouse, but not auto-raise. Even the focus-follows-mouse is broken though. For example, it doesn't play well with command-tab (if you command-tab to a new application and don't touch the mouse then it should not switch focus back to wherever the mouse pointer happens to be -- I'm pretty sure every implementation in Linux I've seen gets this right but MondoMouse doesn't).

    You can enable focus-follows-mouse (no autoraise) for just Terminal windows (just execute the following in a terminal):

    defaults write com.apple.Terminal FocusFollowsMouse -string YES
    

    And similarly for X11 windows:

    defaults write org.x.X11 wm_ffm -bool true 
    

    (For mac versions previous to 10.5.5 this was:

    defaults write com.apple.x11 wm_ffm true
    

    )

    I don't know of any other applications that support it.

    0 讨论(0)
  • 2020-12-07 07:50

    I've been coming back to this question periodically for about 10 years and I finally found a simple solution: AutoRaise https://github.com/sbmpost/AutoRaise

    By default it enables focus-follows-mouse AND autoraise. You can delay the autoraise with a config option.

    It also has what they call "warp" function that centers the mouse pointer in a window when you Command-Tab to the window. I never knew I needed this until I tried it, but once I tried it, I can't live without it!

    0 讨论(0)
  • 2020-12-07 07:51

    You can do it for Terminal.app by issuing the following command at the command line:

    defaults write com.apple.Terminal FocusFollowsMouse -bool true
    

    For X11 apps you can do this:

    defaults write com.apple.x11 wm_ffm -bool true
    

    In Snow Leopard, use this instead:

    defaults write org.x.X11 wm_ffm -bool true
    

    Apparently there's a program called CodeTek Virtual Desktop that'll emulate it systemwide, but it costs $$ (and they never got a version out for OSX Leopard).

    0 讨论(0)
  • 2020-12-07 07:52

    The menu issue is the only reason traditional focus-follows-mouse wouldn't work.

    Here's an alternative: don't change focus until a key is pressed on the keyboard. This would cover 95% of use cases for focus-follows-mouse, and would make this old curmudgeonly X user really happy. I don't know how many times I'll be scrolling through a web page in Chrome, and hit Command-T to open a new tab, and find the tab opening in the Terminal instead. If my brain hasn't picked up on this in 8 months of using a Mac, it never will.

    0 讨论(0)
  • 2020-12-07 07:52

    So I decided to improve again on the work I did on the MouseFocus.app which still had some flaws. Those are fixed now. I renamed the whole thing to "AutoRaise" to better reflect what this tool does: When you hover a window it will be raised to the front (with a delay of your choosing) and gets the focus. The tool can be downloaded here. To use it, copy it to your /Applications/ folder making sure it is executable (chmod 700 AutoRaise). Then double click it from within Finder. To quickly toggle it on/off you can use the applescript below and paste it into an automator service workflow. Then bind the created service to a keyboard shortcut via System Preferences|Keyboard|Shortcuts.

    Update (29-03-2017): The AutoRaise binary has been updated. If no delay has been specified on the command line, it will now also look for an AutoRaise.delay file in the same home folder. This is particularly useful when using the applescript below because 'launch application' does not support command line arguments. The delay should be specified in units of 50ms 20ms. For example to specify a delay of 20ms run this command once in a terminal: 'echo 1 > ~/AutoRaise.delay'

    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
    

    Update (18-04-2019): The source https://github.com/sbmpost/AutoRaise

    Update (05-06-2020): The default delay has been set to 2 and polling time was reduced. These settings prevent unintended window raising when moving the mouse quickly (to reach the top menu for instance). Also a warp mouse feature has been added and a memory leak has been fixed. For further details check out the README

    0 讨论(0)
  • 2020-12-07 07:54

    Tested MondoMouse (https://www.atomicbird.com/about/mac-apps) on MacOS Mojave. Seems to work fine for me!

    To install the prefpane, there will be a notice "enable access for assistive devices" that does not reside in the System Preferences > Accessibility anymore. You'll have to set it in Security & Privacy > Accessibility > Privacy

    There will be several warnings about allowing MondoMouse in each app you have open, but once set it works fine! What a relief :)

    0 讨论(0)
提交回复
热议问题