3 ms·
> Focus Follow Mouse > I have multiple screens and multiple windows. I want to be able to hover over a new one and start interacting with it without clicking.
by saagarjha 5y ago
> Focus Follow Mouse
> I have multiple screens and multiple windows. I want to be able to hover over a new one and start interacting with it without clicking.
Having attempted to implement this once, doing this is nontrivial. If you try to focus anything under your mouse then you can end up changing the selection state of tables and controls, which is generally undesirable.
- Reason077 5y agoHave you tried AutoRaise? https://github.com/sbmpost/AutoRaise https://github.com/sbmpost/AutoRaise
- mnw21cam 5y agoThat's something different. I don't see why so many different OSes have a problem with a window that is not raised having focus.
- tomsmeding 5y agoThis is about _window_ focus, not focus on individual controls within a window. The former is useful (I tried GNOME for a while but went back to i3 for, among other things, this reason), but the latter is (as you found out) probably not a good idea.
- saagarjha 5y agoThey are one and the same, because when you are interacting with a window you are actually interacting with controls inside the window. It is easy to forward cursor events to the target window (hover and scroll already do this, FWIW) but when you want to say type something you'll need to focus the text element under the cursor before you can just blast key events to that application. Doing this in a way that feels intuitive is non-trivial. If you go the simple route and focus every control (so you can do things like tab between them) you run into the issue of the mouse activating some of them as you go over the element and giving it focus–for example, if you do it on a window sidebar, you'll switch between the tabs. I didn't get a chance to really thing about it, but I was thinking of just giving text elements focus and considering it to be good enough; but there are still challenges there: should you be able to focus on a search field (which might blow away the current context and replace it with a "searching" screen)? How should I handle keyboard shortcuts?
- projektfu 5y agoGnome has this but you need to install the tweaks ui to get it. It's how I run Gnome. With multiple monitors it makes much more sense to me than click to focus. I tried it on windows but a lot of programs don't expect it and raise themselves when they get focus. My mac has only one monitor.
- shadowgovt 5y agoThere's a much deeper reason that MacOS doesn't make focus-follows-mouse easy. In most window managers (including Windows), the first-class entity is the window. Windows are related to applications (or processes), but they exist as their own thing, operate independently from most other windows without special handling, and usually have their own menu bar. Apple took a severely different tack on this fundamental abstraction: the first-class entity is the application. At all times, there is at most one application with foreground context and all others are background, and it's actually a pretty expensive operation to switch between them. They did this for a couple reasons (some accident of history and some practical... for example, Apple's decision to put the application's menu at the top of the screen to coincide with the original usability studies on how the edges and corners of the screen were the easiest to mouse to implied there'd be at most one application at a time owning a global menubar context). This had huge consequences for the constraints put on applications. For a long time, it was hard to write a tiling window manager for Mac OS X because there was no language by which you could describe all windows; you'd have to query every app for the geometry of its windows, then compute a new global layout, then foreground each app so it could update its window positions. This is no longer the case, but it made any TWM implementation a toy for years. The upshot of this design for focus-follows-mouse is it has a lot of unintended consequences and can make the system actually quite hard to use in a focus-follows-mouse configuration. For one, it induces latency in all your mouse operations if you're constantly toggling the foreground app as you mouse around. For another, it actually makes it quite difficult to mouse to the menu bar if the menu bar is going to change when your mouse drifts over another window. (It is interesting to observe how, while at some level "they're all just window managers," the detailed decisions made by the different OS developers led to some things being subtlety much harder in one or the other).