228

(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 focus. [Add other terms that will make this more searchable!] X-mouse

Alexej Magura
  • 4,833
  • 3
  • 26
  • 40
dreeves
  • 26,430
  • 45
  • 154
  • 229
  • 42
    I wish I could place a conditional bounty on this. I'd pay a lot for an actual solution to this. – dreeves Jan 28 '09 at 19:42
  • 19
    I would pay money for this for sure. If it basically worked like mouse focus (without auto-raise) does in unix, I'd be super happy. Perhaps we can put up a bounty somewhere. – Nathan Binkert Dec 21 '11 at 19:57
  • Same here, I would pay money for this. – Yves Dorfsman Dec 12 '13 at 21:52
  • PLZ SOMEONE FIX THIS! – frhd Mar 19 '15 at 08:20
  • 1
    I love how I went to vote up a comment only to see that it's Nathan Binkert. Let's grab beers soon. Would love to know what you're up to these days! – Wedge Martin Feb 11 '16 at 16:14
  • 2
    Sure you're crazy. But apparently I am too. I'm also looking for a solution that allows working without auto-raise, since I do a lot of work where I need to quickly do something in a window but do not need to see the whole window at that particular moment. – cjs Jul 12 '16 at 06:49
  • 1
    There's nothing crazy about this. I've always used and relied on this setting in all my Unix/Solaris/Linux/Window desktops. Having to click a windows's title bar to bring it to the top is an abomination. Why does MacOS has to be different? – Mike Feb 11 '20 at 16:35
  • MacOS would an almost bearable experience with this. – Steve Jun 17 '20 at 15:55
  • the only thing stopping me from buying a mac – jmdavalos Sep 25 '20 at 00:29
  • It's possible with AutoRaise as of 2020 (see latest accepted answer by Gareth James) https://github.com/sbmpost/AutoRaise – Justin Lewis Oct 13 '21 at 14:15

24 Answers24

90

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).

Mathias Bynens
  • 144,855
  • 52
  • 216
  • 248
Clint Ecker
  • 1,522
  • 1
  • 10
  • 12
  • 1
    Awesome, just what I was looking for. – JLZenor Apr 07 '12 at 16:26
  • 1
    This is definitely only a partial solution -- but it's an easy and useful partial solution!! Thank you! – lindes Apr 09 '12 at 23:51
  • 3
    Addendum: Setting this for terminal allows it to work if you mouse over a terminal window, even from within another app! Since for me, that's the main reason I'd be likely to actually want to use it, that makes this a 99% answer! Huge up-vote! (Well, I already did, but I'd do it again if I could.) – lindes Apr 10 '12 at 13:22
  • Note that you'll probably need to close Terminal and re-open for it to take effect. – Dennis Feb 26 '15 at 14:56
  • 7
    iTerm2 has this functionality built in... in Preferences, select the Pointer tab, down at the bottom is a "Focus follows mouse" option. It will even grab the focus away from the currently active app (i.e. say your browser is the active app and you're typing in a browser field... mouse into an iTerm2 window and your typing appears there, mouse out and it goes back to your browser or other active app). – jlp Feb 07 '17 at 00:46
  • @jlp iTerm's "Focus follows mouse" setting only affects iTerm windows, at least on Mac. It works very smoothly, but it's pretty limited. – travisw Nov 17 '17 at 16:29
  • Scroll further down, there are apps that can do this: https://github.com/koekeishiya/kwm etc – John Hunt Jul 10 '18 at 13:55
  • 1
    ^ The `kwm` repo link is dead (archived under a different name) . [Another answer](https://stackoverflow.com/a/55970830/3038726) points out that it "has been superseded by yabai", which, as of this comment, works fine. – OJ7 Feb 19 '20 at 04:31
  • Love this; Terminal.app is also the only reason i came here – nate May 06 '21 at 12:25
  • Indeed "defaults write com.apple.Terminal FocusFollowsMouse -bool true" works, I tried on macOS Monterey 12.3.1. There's one limitation, even though the focus changes to the respective app (e.g. Terminal), the OS menu bar still shows the previous app. If you press CMD+Q, it will close the app in focus (e.g. Terminal). – Henrique Gontijo Apr 26 '22 at 15:38
  • Using MacOS Ventura 13.3.1. Didn't work! – knkbga May 12 '23 at 05:53
62

Although this is far from a complete solution, two handy actions that are built into OSX (10.11) are:

⌃⌥-click (control-option-click) - switches focus without raising window

⌘-click (command-click) - clicks in window without switching focus

Not sure when these shortcuts were introduced, as I haven't been able to find them written about anywhere.

dvj
  • 367
  • 6
  • 10
  • I'm not seeing this work consistently, BUT it almost works on Yosemite 10.10.5 – ericslaw Oct 07 '16 at 20:17
  • This does not work in Mac OS X El Capitan: ⌃⌥-click generates a right click, while ⌘-click extends the selection. – Sébastien Nov 02 '16 at 15:45
  • 2
    /Technically/ this works on 10.12 "macOS sierra", but lack of modifier key standards across apps and wm make another Yegge-esque tragedy. ⌘-clicking a link in browsers also opens a new tab. In Chrome, ⌘-click on a tab is also multi-select. At least ⌃⌥-click works well enough on editors & terminals, and ⌘-click-drag on the title bar consistently moves windows without raising them. – Metaxis Nov 30 '16 at 01:56
  • This solution, though imperfect, at least provides a meaningful function toward some of the use-cases. Thank you. – Jason R. Coombs Nov 09 '18 at 14:37
  • 1
    Just want to confirm that this still works in Mojave. The point above that it isn't consistent between various apps is correct however. Chrome and FF both fail to follow the standard. @Sébastien ... You are clicking on the foremost window. The `click` is intended for a window without focus. – undefined Jan 06 '19 at 21:08
  • 1
    As for a source, this was mentioned in a WWDC 2018 video on [Advanced Debugging with Xcode and LLDB](https://developer.apple.com/videos/play/wwdc2018/412?time=2316). – Graystripe Apr 17 '19 at 00:57
  • Command-click seems to work, but w/ limited utility. Control-option-click (COC) is heavily dependent on apps used. Eg, open multiple windows in chrome & firefox (FF); focus chrome, then COC on a FF window & you get a right-click option menu (but doesn't raise), but focus FF window & COC chrome window and works as advertised. But focus one window in chrome & try to COC another chrome window and it simply raises. Focus one FF window and COC another FF window and it shows right-click option menu (and raises!). – michael Jan 09 '23 at 02:22
  • 1
    Fwiw the Terminal fix _does_ work w/ other apps (like chrome & firefox examples from my previous comment), but only when moving the mouse over to terminal, not the other way around (i.e., terminal stays in the background but does get focus) https://stackoverflow.com/a/98331/127971 Seems like the "fix" for sloppy focus needs to be implemented in individual applications, not at the OS (desktop) level. – michael Jan 09 '23 at 02:24
60

Steve Yegge wrote an essay about this a while back, where he tried and failed to write a suitable extension. I've since tried to find focus-follows-mouse applications for OS X and failed also.

John Millikin
  • 197,344
  • 39
  • 212
  • 226
  • 4
    He doesn't seem to have put up the code that he wrote either :( – Stuart Axon Mar 24 '10 at 18:22
  • 8
    That makes a lot of sense. One thing that annoys/confuses me is that the scroll behavior does seem to have a lazy focus. So I can move the mouse over to another window, scroll the text, and then when I start typing, the output goes to another application. – Ocie Mitchell May 07 '18 at 19:47
50

Focus-follows-mouse is not a particularly suitable input method for OS X because its menu bar was designed to be at the top of the screen. When you move the mouse out of your application window to get to the menus, if it crosses any other application's windows on the way, the menu changes.

So yes, in reply to dreeves comment, it works perfectly fine for Terminal (or for any other single application on the desktop), because the only other windows it's going to affect are Terminal windows, so the menu never changes as you switch windows. And it works fine for X11 because X11 apps generally have their menu bars embedded in the window, so you don't have to leave the window to access them.

Of course you can work around the menu-changing issue by introducing an artificial delay before the focus changes and/or the menu switches, but it's never going to work as well as it does on other desktops.

calum_b
  • 233
  • 4
  • 12
  • 5
    Totally fair point about the menu bar though with the standard delay it was not an issue for me in practice. – dreeves Oct 15 '10 at 23:18
  • 24
    Like others, I'm an old X-Windows turned Mac a couple of years ago. And also like others, this one issue continues to drive me up a wall. Having to click on a window to get it focused and then having it auto-rise to the top is bad. (I was about to write words like 'insanity', but decided I wouldn't be so over the top.) – VTPete Dec 09 '10 at 17:35
  • 1
    +1 This was the most informative answer, due to the bit about the menu bar. – bentford Dec 25 '10 at 07:33
  • 7
    @Calum: sorry, but I do not agree. I have used Focus-Follows-Mouse on Mac OS X (using CodeTek Virtual Desktop Pro), and it worked perfectly! It worked consistently with all apps, and switching apps, moving windows to different workspaces, and navigating workspaces worked much easier than how it is implemented in the latest OS X [10.6.7]. It is sad that Apple crushed CodeTek and it's product - Virtual Desktop Pro was really superior to how OS X workspaces are implemented. It worked basically like Fvwm on LINUX - super fast navigation. – Tilo Jun 22 '11 at 16:50
  • @Tilo Interesting... So how did it solve the problem of the menu bar changing as you traversed intermediate windows? I knew that focus-follows-mouse solutions are (or were) available for OS X, but I'd never seen one that solves this problem in a non-annoying (to me) way. – calum_b Jun 25 '11 at 14:54
  • 2
    @Calum: I can't really test it right now, as none of my Macs runs 10.4 or earlier, but if I recall correctly the application would switch after a fraction of a second and the menu bar would switch accordingly – Tilo Jun 28 '11 at 04:13
  • @Tilo: okay, so that's one of the workarounds I mentioned in my answer, and one which I personally find too annoying to use. But if it works for others, that's great :) – calum_b Jun 28 '11 at 10:27
  • 10
    This is just one *more* reason why the *detached top menu bar* in OS X is one of the most bizarre, ridiculous UI ideas I've ever seen. Whoever came up with that one needs to be tarred and feathered. – Nate Feb 10 '13 at 04:42
  • 2
    @Nate I agree it has its problems nowadays, but it was a perfectly good system when it first appeared on a Mac in 1984. But in those days, the screen was only 9" across so mouse travel distance wasn't a problem, and you could only run one application at a time anyway (other than desk accessories) until MultiFinder showed up three years later. – calum_b Feb 21 '13 at 11:57
  • 2
    @Nate The screen edges are particularly easy to reach locations, if you are using a mouse, trackball, or touchpad as your pointing device (basically anything other than touch or pen) because you can simply "overshoot" in the general direction of the menu item and your pointer will stop right on it. Notice how the menu items' hot spots are flush with the top edge of the screen and with each other. – Tobia Oct 24 '13 at 14:14
  • Wrong. Ubuntu and its Unity UI introduces the top menu bar without compromising the focus-follows-mouse feature. – Jason R. Coombs Aug 19 '14 at 23:35
  • @JasonR.Coombs Not a fan of Ubuntu so haven't played with it in a while... how do they solve the problem? – calum_b Aug 20 '14 at 14:34
  • @calum_b: Missed your reply earlier. They do it by simply changing the menu to the active app's menu. It's true you can sometimes not get to the menu without losing it. Also, if I recall correctly, they don't treat the desktop like an app (Finder), so you don't lose the menu for the current app as long as you don't pass over another app before reaching the menu. I can't confirm, but I suspect there was also a small delay for switching and a hotkey to jump the mouse to the menu. – Jason R. Coombs Nov 09 '18 at 14:34
  • I disagree that the menu issue is a fair point. The lack of features like autoraise is one place macOS has always been weak. I don't appreciate when people come to the defense of a technology I have to use. I don't cheer lead for macOS; I use it. Almost none of the macOS weaknesses have been addressed by the current leadership at Apple. What are the chances we get new leadership, or get these problems addressed if there are cheerleaders muddying the water? – Addlai Nov 20 '22 at 22:46
  • @Addlai You're welcome to that point of view of course. But unless you can propose a solution that doesn't have any of the drawbacks mentioned, then it's still not going to be something that Apple would ever implement. – calum_b Nov 22 '22 at 08:46
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!

mjturner
  • 1,035
  • 7
  • 16
Gareth James
  • 28
  • 3
  • 7
23

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

sbmpost
  • 21
  • 1
  • 3
  • 2
    Could you edit your previous post? That's more clear and easier to vote on one particular application in one post than multiple posts with different versions. – Diamondo25 Feb 02 '16 at 11:25
  • It's true, it would help with clutter and if your new program works I'd like to vote it up to the top for posterity! – dreeves Feb 10 '16 at 08:37
  • 1
    @dreeves added instructions to make it executable: chmod 700 AutoRaise from the command line (in Applications folder). Also fixed a bug where the raising would stop working when a notification arrives. Also reduced the default delay. I am using it with multiple screens. For that purpose it seems to do the job quite well. – sbmpost Feb 17 '16 at 10:40
  • 1
    Ah, and I removed my older (outdated) posts. So feel free to vote up this one ;-) – sbmpost Feb 17 '16 at 11:20
  • Thanks so much for all the improvements! I'm trying it now and there's still one dealbreaker: there needs to be a ~500ms delay before autoraising (focus can be immediate). Otherwise windows jump up even if you're quickly moving the mouse from one window to another. (Btw, I'm getting a stream of " Failed to find window under cursor" warnings in the terminal window it AutoRaise launches from.) – dreeves Feb 19 '16 at 07:55
  • @dreeves: The applescript as shown above uses Finder to start AutoRaise, making sure that assistive access is only required once (and not for every program from which you might use the AutoRaise service). The downside is that applescript 'launch application' doesn't support parameters... So the delay can only be set with -delay when running directly from the terminal. If you experiment a bit with the timings that you would like, then I can compile a custom version for you that by default uses the correct delay ;-). Those warnings are debug messages. I can remove those as well... – sbmpost Mar 01 '16 at 18:05
  • Wow, thanks for the script, it works like a charm but one question: How do I achieve it that the binary will be launched on startup with launchd? Executing in a terminal is not a very good option so far. – thonixx Oct 01 '16 at 09:47
  • @sbmpost I'm with @dreeves. Please remove the debug messages and make it possible to configure a delay. The command line option `-delay` has no effect. `$ ./AutoRaise -delay=100ms By sbmpost(c) 2016, usage: AutoRaise -delay <1=50ms> Started with 50 ms delay...` Please integrate your script with [Homebrew](http://brew.sh/) – barthel Dec 26 '16 at 10:14
  • 2
    Thanks for the tool, works great. It would be awesome if you opensourced it! – Steve Goranson Oct 31 '17 at 03:01
  • 1
    I'd also like to see this go open source. All other links I've tried are dead, amethyst still is not pixel-perfect (or at least, buggy on my machine), so using this AutoRaise + amethyst makes me a bit happier than yesterday. Wouldn't like to see this lost! – ArthurChamz Mar 08 '18 at 11:26
  • There is one annoying bug present. If you open a top menu item and it covers some window, then you try to select some subitem, you can't do that because down laying window raises. This software will be awesome after fixing this bug. But before that it is useless. – Thomas Anderson Nov 30 '18 at 11:56
  • 7
    Long overdue, but the source of this thing can be found here: https://github.com/sbmpost/AutoRaise – sbmpost Mar 28 '19 at 07:36
  • thank you! thank you! thank you! – Tom Mulkins Nov 05 '21 at 20:55
  • Still has issues: https://github.com/sbmpost/AutoRaise/issues/94 – mjs Jul 20 '22 at 08:30
21

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.

Kyle Rose
  • 91
  • 2
  • 4
  • 1
    same for me! :P yet Apple claims they know things better – Tilo Nov 19 '13 at 15:37
  • 3
    This would be brilliant. One of the main points of focus-follows-mouse would be to give keyboard focus to other windows without having to explicitly click on them, so focus-on-keypress should do the right thing. Does anything implement this? – jamesdlin May 15 '18 at 19:54
  • I would happily use the ctrl+F2 keyboard shortcut for the few occasions I need to access the menu if I could have focus-follows-mouse. – Matthew Jan 24 '19 at 16:18
  • Almost 8 YEARS in and my brain still refuses to adapt! I agree this would be an excellent solution! I wrote some Lua for Hammerspoon that would trigger code on mouse movement going idle, but never developed it further to make it useful. – ericslaw Feb 15 '23 at 21:21
17

Amethyst supports this feature. It can be easily installed with brew install amethyst.

Here's the config file I use. It turns all the features off besides focus-follows-mouse. Save it to ~/.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
}
Daghall
  • 589
  • 6
  • 10
wprl
  • 24,489
  • 11
  • 55
  • 70
  • Nice! Can you set a delay on the auto-focus? (I think 500 milliseconds is what other window managers that support this use.) Or maybe the delay is only important for auto-raise, not auto-focus. – dreeves Mar 27 '15 at 23:59
  • 1
    @dreeves there is a slight delay on it, but as far as I know the timing is not configurable. – wprl Mar 30 '15 at 01:00
  • On reflection, I think auto-focus should be instant or almost instant. Probably something well under 500ms. Auto-raise is optional but if auto-raise happens then it needs a delay, probably 500ms. Otherwise windows jump up and down just from moving the mouse from one part of the screen to another. – dreeves Mar 31 '15 at 04:05
  • 4
    There are several syntax errors in the configuration file. I've corrected those and pasted them [here](http://paste.jaraco.com/iwSBT). – Jason R. Coombs Jun 15 '15 at 17:30
  • 2
    I tried Amethyst, and it works to solve the OP's question. It does not appear to have support for the variant Focus Follows Mouse _without_ Autoraise. – Jason R. Coombs Jun 15 '15 at 17:38
  • 5
    If anyone discovers a "Focus Follows Mouse _without_ Autoraise" capability, I'd like to hear about it. In the meantime: @JasonR.Coombs [your updated ~/.amethyst settings](http://paste.jaraco.com/iwSBT) worked for me--quite helpful, thanks. – Johnny Utahh Jul 02 '15 at 15:39
  • This works unusably poorly in Yosemite. I desperately miss focus follows mouse, but the cure here is worse than the disease. – Eric Angell Sep 25 '15 at 17:02
  • 3
    You don't need to modify the configuration file manually. You can enable this feature in the Preferences of Amethyst. The name is Focus follows mouse (experimental). – webcpu Mar 15 '16 at 08:09
  • @UnchartedWorks: True. But if I remove the tiling layouts, the app crashes immediately on startup. Anyone else experiencing this? Currently, I can't seem to use the focus-follows-mouse feature without the automatic tiling enable, which I don't need anyway. – frhd Jan 25 '17 at 14:39
  • Edit: It seems that including only the **floating** layout item, it works. – frhd Jan 25 '17 at 14:45
  • No doubt that **Amethyst's** version of focus-follows-mouse is the best, currently. But after using it for some 20 minutes, I've found the Autoraise quite annoying. Small windows floating in front of bigger ones this way are almost impossible to reach due to Autoraise. If you have everything tiled, it seems usable, though. – frhd Jan 25 '17 at 15:03
  • Thank you, stranger! I enabled this feature by mistake in amethyst and it was just driving me crazy, literally! Now it is disabled and my mental health is safe. Thanks. – Andrei Glingeanu Oct 20 '17 at 12:22
  • I'll have to agree that while Amethyst does focus-follows-mouse perfectly, the other default behaviors like tiling are catastrophically bad, and they seem to persist even when using the custom `~/.amethyst` file given here. – Christopher Hunter Apr 30 '18 at 20:47
12

Focus follows mouse is now possible in macOS, Mojave in my case, using chunkwm. See this Stack Overflow response for a "no autoraise" solution. Autoraise is activated by leaving

chunkc set ffm_disable_autoraise         0

in ~/.chunkwmrc.

Edit 2019-09-12:

chunkwm has been superseded by yabai. To install:

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
Les Grieve
  • 708
  • 8
  • 10
  • It is important to note that chunkwm and yabai are _tiling_ window managers. Your advice is very good, but, alas, even with 15.5mm pixels, I still want overlapping windows. – ericslaw Feb 15 '23 at 21:26
  • Yabai's main purpose is to provide macOS with a tiling window manager. One sub-feature is focus_follows_mouse. The configuration described here uses only focus_follows_mouse, no tiling. – Les Grieve Feb 17 '23 at 12:47
8

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.

dreeves
  • 26,430
  • 45
  • 154
  • 229
8

I currently use MondoMouse and even with its quirks I couldn't use my mac without it. They have a free trial and I would recommend it to everyone.

MondoMouse

mcotton
  • 844
  • 6
  • 11
  • 3
    I've tried MondoMouse, but if I enable focus-follows-mouse, it auto-raises the window. Auto-raise is annoying for me, it decreases my productivity a lot. Is it possible to get focus-follows-mouse without auto-raise? – pts Jul 18 '09 at 18:45
  • This is a great find! Why isn't it voted up more? pts: I don't like overlapping windows anyway, so I think this will work for me. – airportyh Jan 08 '11 at 02:18
  • thanks for pointing that out - unfortunately the auto-raise drives me nuts :-/ – Tilo Jul 20 '11 at 22:05
  • You can try autoraise, and set delay=0 but in one instance (intellij) the window will autoraise regardless on focus. So not perfect. https://github.com/sbmpost/AutoRaise/issues/94 – mjs Jul 19 '22 at 22:33
6

chunkwm supports this too (by default I believe): chunkwm

asselinpaul
  • 386
  • 1
  • 5
  • 19
5

Interesting that Leopard has one flavor of focus-follows-mouse (sans autoraise) enabled by default. The scroll wheel works in unfocused windows.

ck_
  • 3,719
  • 10
  • 49
  • 76
  • AFAIK, it's been this way since scroll wheels gained Mac support. It is completely consistent in one sense: buttons/wheels/balls on the mouse follow the pointer, stuff on the keyboard follows focus. – Frank Schmitt Jan 12 '10 at 19:25
  • 3
    It was a new feature in Leopard. Daring Fireball has a whole load of content on how some widgets/windows are click-to-focus and others are out-of-focus-click-activates-the-widget. So it's definitely not consistent, yet. – ck_ Jan 13 '10 at 08:59
  • 1
    @Frank Schmitt - Buttons also follow focus - If I want to press a button in Lastfm, then I need to click the window once (even if I'm clicking right on the button) and then the button. – Stuart Axon Mar 24 '10 at 18:24
4

Unfortunately CodeTek Virtual Desktop Pro is no longer developed, and the company seems to have gone out of business a few years back..

Historic reference: http://www.codetek.com/ctvd/ (does not work on new OS X versions!)

Historic review: http://www.osnews.com/story/6144

Using CodeTek Virtual Desktop Pro you were able to get Focus-Follow-Mouse and disable Auto-Raise, and it also had a Pager for the virtual desktops -- similar to how Fvwm works on Linux. It really worked perfectly -- the best piece of software that I've ever bought. It worked consistently with all apps, and switching apps, moving windows to different workspaces, and navigating workspaces worked much easier than how it is implemented in the latest OS X versions [10.6, 10.7, 10.8]

Unfortunately with Mac OS X 10.5 VirtualDesktop Pro stopped working, and it looks like Apple actively made sure that CodeTek will not continue to work on it.

It is sad that Apple crushed CodeTek and it's product - Virtual Desktop Pro was really superior to how OS X workspaces are currently implemented. It worked basically like Fvwm on LINUX - super fast navigation -- without unnecessary clicks or mouse gestures...

It saddens me to see that Apple dictates window manager (Finder) behavior and does not seem to allow third-party replacements for the Finder anymore.

Tilo
  • 33,354
  • 5
  • 79
  • 106
3

Give DwellClick a try. Although, it's not for its intended purpose, the auto-click behavior has a side effect similar to auto-raise or focus-follows-mouse.

Personally, I only use the feature of left clicking after my cursor movement comes to rest, but there's also clicking with modifiers and a window dragging assist that's quite handy.

It's also a little frustrating while web browsing since you'll either want to disable the app or be more conscious of where the cursor rests (e.g. not on any links or buttons you don't intend to activate).

Ben M
  • 21
  • 3
  • 3
    I've tried this. The issue is that it raises the window. For me, one of the huge advantage of focus-follow-mouse, is the ability to work on a partially covered window (so I can copy text or follow instruction from another terminal or a browser that is taking a significant amount of the screen. – Yves Dorfsman Dec 12 '13 at 21:51
3

Use Dwell feature in mac. Go to Accessibility -> keyboard -> Accessibility keyboard (I'm on Catalina)

Click here for more info


enter image description here

enter image description here

cherankrish
  • 2,004
  • 1
  • 16
  • 11
  • 2
    This is fascinating that this is possible and built in on Macs now! But having it literally click on everything I hover over is too much. :) I just want it to change focus to (and auto-raise to foreground, though many people hate that part) anything I hover over. – dreeves Nov 23 '19 at 21:42
  • But it also shows the annoying accessibility keyboard :/ – ba11b0y Feb 06 '21 at 08:38
  • What the hell, this will keep clicking. I only need it to focus or raise the window. Not actually click. It can click if it is a new window since that will raise, but it does click even within the same program when moving the mouse. – mjs Jul 19 '22 at 22:22
  • I don't see how this can be used. – mjs Jul 19 '22 at 22:22
  • I mean, whenever you move the mouse basically it will follow with a click. Can be nice, but the risk of accidentally clicking stuff is huge. I wish it would only do it on new window activation, not within the same that is already active. – mjs Jul 19 '22 at 22:24
2

There is also the related issue of raise-on-click. Under OSX each time a window is clicked, it is also raised, thus potentially hiding other windows. This is problematic when working with copy/paste from two windows where one of them covers most of the screen. I like to keep a global (active in all workspaces) notepad from which I copy/paste stuff (could be anything from commands, text, todo items etc). This is challenging under OSX. It would be nice to have an option to disable raise-on-click.

sfar
  • 1
  • 1
  • @dvj's answer gives a couple of obscure tricks that help do the things you're talking about that are hard to do otherwise. – Don Hatch Feb 07 '17 at 07:37
1

Solution: Because I was so used to autoraise in Windows I badly missed it on the Mac. The solution I found for the Mac is Zooom (yes, three o's). It has an autoraise function. You can even set milliseconds to wait before autoraise. Can't live without it. Autoraise is an option in prefs as you can see in the screenshot https://www.macupdate.com/app/mac/23203/zooom http://coderage-software.com/zooom/index.html

1

Some potentially useful advice for part "focus on hover" with dual screens. It doesn't fix some things like typing into an input box when another screen already has input box focus. But it might help people who come here for all aspects of "focus on hover".

Without this fix I always had to "focus click" in a monitor before I can contextually click on anything at all.

You can get some aspects of "focus on hover" with this:

  1. Go into 'System Preferences'
  2. Select option 'Mission Control'
  3. In there you should see 'Displays have separate Spaces', untick it

Then at least with Monitor1 selected, now you can instantly click on something in Monitor2, like an email or Tab, without needing the first "focus click".

As always can be the case, this may not work for everyone depending on OS version and probably other things.

James
  • 4,644
  • 5
  • 37
  • 48
1

Experimenting with those options, my Command-Tab started to behave oddly. Here is the solution of how it gives focus to apps again:

It appears that a previous feature, namely the ability for Terminal's window focus to change with mouse movement, is broken in 10.6 and causes Command-Tab to not transfer window focus correctly. To fix the problem, just paste the following command in a Terminal:

defaults write com.apple.Terminal FocusFollowsMouse -string NO

Then restart Terminal.

Team Pannous
  • 1,074
  • 1
  • 8
  • 11
  • Oh wow, I'd be living with that for years after reading this thread! Now I have to decide which is the lesser evil. – terrace Jun 01 '12 at 16:08
0

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 :)

MaltaCode
  • 70
  • 7
0

Here's a working toy-level implementation for multi-monitor autofocus if anyone is interested: https://bitbucket.org/sivann/mac-screenfocus/src/master/

It mostly works, but does not handle multiple windows of the same app in different monitors. Gives focus to the last app that had it if you move the mouse to another monitor.

sivann
  • 2,083
  • 4
  • 29
  • 44
0

Another app to consider is Yabai. Yabai is primarily a tiling manager. But, you can disable the tiling, and only use the "focus on hover" feature. The benefit is Yabai is a popular project (15K stars) with active development, so this "side feature" might actually work better than some smaller projects where "focus on hover" is the primary feature.

In my experience is it stable and predictable. I do have issues with it no longer focusing windows, which requires a brew services restart yabai. It is set up so that if you're holding the fn key, "focus on hover" is disabled. By default it does not put the focused window on top, which is a feature I personally prefer.

My ~/.yabairc looks like:

#!/usr/bin/env sh

# global settings
yabai -m config mouse_follows_focus          off
yabai -m config focus_follows_mouse          autofocus
Chris Hayes
  • 11,505
  • 6
  • 33
  • 41
-18

You can't really do it well, because the Mac interface simply isn't designed with focus-follows-mouse (with or without auto-raise) in mind. I doubt that's going to change any time soon, and unless it does, everybody who tries to implement focus-follows-mouse will run into the same hurdles and wind up with an unsatisfactory result (to those who want such a thing).

So, yes, you are crazy for wanting this — but for technical reasons. Get used to using the Mac on its own terms and I'm sure your desire to force it to behave just like whatever X11 stuff you used to use will subside in a bit as you find new efficient ways of working.

Chris Hanson
  • 54,380
  • 8
  • 73
  • 102
  • 4
    I don't buy this. It works perfectly fine for Terminal and for X11. Why can't that be extended to all applications? – dreeves Nov 17 '08 at 19:10
  • 24
    Ugh! This simply is not true (at least the "your desire will subside" part). I've been using OSX for about two years now, and while many of the differences are just fine, I'm *still* accidentally closing the wrong tabs because I can *scroll* whatever's under my mouse, but keystrokes go to whatever has focus. It drives me up the wall! I can not overstate how much I dislike this behavior. – John Hyland Jun 01 '10 at 19:30
  • 4
    Great point about OSX already having scroll-follows-mouse. Do anti focus-follows-mouse people hate that feature? Can it be turned off? (Not that I want to. I consider it better than nothing, but the inconsistency is worse than annoying.) – dreeves Oct 15 '10 at 21:31
  • 4
    Quoting Chris Hanson "Get used to using the Mac on its own terms and I'm sure your desire to force it to behave just like whatever X11 stuff you used to use will subside in a bit as you find new efficient ways of working." I strongly disagree with this statement. In this day and age, I shouldn't have to get used to being without a useful/desirable feature because Mac doesn't want me to have it or doesn't think it is useful. The lack of the feature (which is present as an option in all other Unix/Linux distrobutions) is one of the reasons I hate my MAC more every day. –  Oct 19 '09 at 20:06