Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot focus back on float window after focus on other program #1988

Closed
xarthurx opened this issue Aug 21, 2023 · 5 comments · Fixed by #2115
Closed

Cannot focus back on float window after focus on other program #1988

xarthurx opened this issue Aug 21, 2023 · 5 comments · Fixed by #2115
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@xarthurx
Copy link

Describe the bug
On Windows, after opening a floating window (e.g. Lazy), if I mouse-click other program and click back, the cursor is always on the buffer behind the floating window -- I cannot focus on the floating window and close it.

In the end, I need to close the whole neovide itself.

This doesn't happen on nvim-qt -- I believe this is a neovide bug.

To Reproduce
Steps to reproduce the behavior:

  1. Open a floating window (e.g. Lazy)
  2. Click on some other program to make neovide loose focus
  3. Click back on neovide to focus on the window
  4. Cannot close the floating window

Expected behavior
I can focus on the floating window and close it.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows
  • Neovide Version: 0.11
  • Neovim Version 0.9.1
@xarthurx xarthurx added the bug Something isn't working label Aug 21, 2023
@fredizzimo
Copy link
Member

This is a more general version of #1943.

The focus works properly if you use neovide --multigrid, so I suggest that as a workaround. The problem seems to be that we pass the wrong grid id, at least with my quick testing.

The documentation for nvim_input_mouse says that the grid should be zero when not using multigrid.

{grid} Grid number if the client uses ui-multigrid, else 0.

I did a quick hack and modified these two lines to hardcode 0 and that seems to fix the problem
https://github.com/neovide/neovide/blob/main/src/window/mouse_manager.rs#L192
https://github.com/neovide/neovide/blob/main/src/window/mouse_manager.rs#L229

Adding the "good first issue" tag, this should be easy to fix and test for someone that wants to contribute to Neovide.

@fredizzimo fredizzimo added the good first issue Good for newcomers label Aug 21, 2023
@9mm
Copy link
Contributor

9mm commented Sep 13, 2023

@fredizzimo So Ive been fighting with this issue a bit and I believe it still is broken with multigrid.

I did what you suggested with making sure its a neovide problem, and I think it is. It seems to work fine in neovim terminal, which doesnt support the mouse "focus" events, but clicking outside the window and clicking back in DOES work, but is broken in neovide

For starters im using floaterm:

return {
  'voldikss/vim-floaterm',
  keys = {
    {
      '<Leader>x',
      function() vim.cmd('FloatermNew --title=ZSH --floaterm_autoclose=2 --width=0.7 --height=0.4') end,
      desc = 'ZSH shell',
    },
    {
      '<Leader>z',
      function() vim.cmd('FloatermNew --title=LazyGit --width=0.95 --height=0.95 lazygit') end,
      desc = 'LazyGit',
    },
  },
}

So first, I press <Leader>z to bring up LazyGit.

As SOON as I move the mouse outside the window the bottom status bar changes from --TERMINAL to just blank.

At that exact moment, LazyGit stops responding to the q command. Which is strange, becuase I dont have to click. Simply moving the mouse outside the window stops it from working.

Im not sure if this is desired behavior or not, id like to disable that, but thats not actually the "bug"

When I move the mouse back INTO the window, it still wont respond to "q"

I need to press <C-w><C-w><C-w><C-w> 4 times and it will refocus the window, so --TERMINAL shows back up, and now i can press q

The bug I believe can be simply reproduced by just clicking outside the window, and clicking back in, and the window will not re-focus. On neovim in terminal, it refocuses immediately. On Neovide, the cursor appears in the window, but its actually "behind" the window.

I have tried both 'improve render loop' branch, and 'stable' release branch.

Here is part of my bash script which shows which ENV vars im loading before calling neovide. You can see multigrid is enabled

export NEOVIDE_MULTIGRID=true
export NEOVIDE_FRAME=buttonless
export NEOVIDE_VSYNC=0

@xarthurx
Copy link
Author

I'm recently using nvim-qt and found that they have resolved this issue quite nicely.
Probably look into their code base?

@fredizzimo
Copy link
Member

@xarthurx
The fix should be trivial #1988 (comment), but I don't have time to fix each tiny issue myself, so I added a "good first issue" for someone else to pick up. Multigrid will be the default soon, and that's where we concentrate all our development on.

@9mm,
You are actually hitting a different issue, this one #1838. And after you click the terminal with the mouse it should work as long as you go back to terminal mode with a, A, i, I for example.

@9mm
Copy link
Contributor

9mm commented Sep 13, 2023

oooooo...... Interesting.

Knowing I can use a or i is extremely helpful, also that I could just disable hover altogether... which I will do as I cant think of other things I'd want to use mousehover for

With that said... what actually makes the mousemoveevent ignore the floating window? Wouldnt it make sense if it floated back onto the window when the mouse is back over it? or is that not how it works. No need to really answer just curious if you feel like it.

Thanks again @fredizzimo i am forever gratful for all this awesome work.

@Kethku Kethku added the hacktoberfest Good options for hactoberfest contributions. Not exclusive label Oct 5, 2023
@fredizzimo fredizzimo removed the hacktoberfest Good options for hactoberfest contributions. Not exclusive label Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants