macvim-dev / macvim

Vim - the text editor - for macOS
https://macvim.org
Vim License
7.51k stars 683 forks source link

Window focus follows mouse #1348

Open amit777 opened 1 year ago

amit777 commented 1 year ago

Is your feature request about something that is currently impossible or hard to do? Please describe the problem. iterm2 and various terminals have a feature where the window focus can follow where the mouse pointer is above

Describe the solution you'd like if I have multiple macvim windows open and I move my mouse over a different window, that window should have the keyboard input focus

ychin commented 1 year ago

Hmm, I'm a little unsure about this. This feature is not a very macOS-like behavior in terms of window management go (it's more common in Linux). What other terminals support this feature? I don't know of a single GUI text editor in macOS that supports this. What kind of use case are you thinking of? There are also third party tools that allow you to do this globally for all Mac apps.

eirnym commented 1 year ago

Hi @amit777, thank you for a topic to discuss

First of all, I'd like to point, that using mouse could be actually slower if you use mouse depending on a distance between windows and if you use actual mouse or built-in trackpad. Here an interesting blog post from 2008 discusing this and other matters on that.

Additionally there're actually key combinations to change a window without raising it. I recommend this stackoverflow thread, where you can find both key-combinations and tools you can use different applications.

For me personally it's way faster to press a standard key-combination a few times to switch the focus (with raise it or without) to other window or app than use a third-party app to do that. This includes switching to a window on another monitor, which is a pretty long way to drag mouse cursor.

amit777 commented 1 year ago

Hi, yes, it's very Linux like.. I just thought maybe it was possible since iTerm2 supports it. It makes it very easy to input into different windows that may be spread through out your screen without having to click on the window.

I found some hints here that might be helpful: https://stackoverflow.com/questions/67258537/focus-follows-mouse-on-macos

Also, it looks like it may be possible to do this generally on MacOSX using this: https://github.com/sbmpost/AutoRaise

so it may be a moot request for MacVim!

ychin commented 1 year ago

I think there are a couple things in question here: autoraise vs autofocus, and within-app vs cross-app.

The AutoRaise plugin seems to only do auto-raise, but not auto-focus (meaning focus without raise), so it may be slightly different from what you want to do.

For cross-app, I don't think MacVim can easily do that (iTerm also only does within-app). If you want this to go from another app's window to a MacVim window, your best bet is to Ctrl-Option-Click on the window (see that StackOverflow link) to focus the window without raising it. For within-app focus-follow-mouse-move (this is what iTerm does), this is probably possible, but I would say maybe try those options first and see if it works. I'm personally not too inclined to implement this because this kind of breaks how macOS usually expects focus to works and MacVim aims to be a very "Mac-like" gVim implementation. If there are more people who chime in I may change my mind.