Neovim-qt: How should window resizing behave?

Created on 12 Mar 2016  路  18Comments  路  Source: equalsraf/neovim-qt

More on this in a PR that should pop up in a bit, we need to discuss how resizing should behave to address #106, #83, #84(indirectly, resizes in layouts), and #4.

Resizes can arrive from multiple sources

  1. Neovim itself may trigger a resize, e.g. set lines
  2. User interaction i.e. user resizes the window
  3. Window manager or widget layout changes, something in the window changed e.g. the layout of other widgets, that caused the Shell widget to be resized as a consequence

Neovim resizing works as follows

  1. The GUI calls neovim for a resize - see ui_try_resize()
  2. Neovim (eventually) triggers the correct event (followed up by a redraw), but there may be other events in the pipeline
  3. (I think) if the GUI triggers multiple resizes simultaneously (without waiting for completion) the following requests are dropped, very common when resizing a window

A few cases that need to be considered

  1. The shell widget might be a window (maximized or not)
  2. In some systems there is the notion of full screen mode (MacVim, Vim-Qt) it usually behaves very differently from maximized window
  3. The shell widget might be part of another widget
  4. Not all GUIs behave the same, check out vim-gtk, vim-qt, MacVim

The important bit to understand here is that a resize can trigger another resize and sometimes this is racy e.g.

  • Some users drop a set lines/cols in init.vim, should that work for the GUI?
  • If the windows is maximized and Neovim triggers a resize (e.g. plugin or set lines) should the window leave the maximized state and be resized - I feel this breaks user expectations - for e.g. vim-qt resized vim back to its previous size
  • If Neovim is actually an embeded widget then resizes are likely not possible, but races can occur - Neovim resizes, the layout resize back
  • When resizing a window (depending on the window manager) the resize is progressive, i.e. one bit at a time, this is terribly inefficient.
  • For a non-maximized window should we allow resizes larger than the current screen/workspace (e.g. set lines=2000)?
  • Not all window managers respond to these events in the same way, e.g. KWin might allow you to resize the window, i3 will not

Ping #106, #83, #4. TLDR; need to agree on what is the expected behaviour for resizes, and need to write unit tests that check the correct behaviour (upcoming PR should help).

question

Most helpful comment

@with0out On Windows 7 I found using -qwindowgeometry 800x600 instead of --geometry 800x600 worked for me.

All 18 comments

Just adding another fly in the ointment: Some window managers (awesome for one) allow you to maximise a window vertically and/or horizontally and back again. This is a feature I use a lot as I tend to have many instances of (neo)vim open at once.

In more general terms, you might hit Parkinson's bike shed asking for this. Personally, I do not care what the behaviour is as long as it is clearly documented.

In more general terms, you might hit Parkinson's bike shed asking for this. Personally, I do not care what the behaviour is as long as it is clearly documented.

True. Likely I'll just implement whatever comes to mind and call it the de facto behaviour :D. But the point is also to identify what can't be done (some things work fine on my window manager but not yours, etc).

Turns out resizing the widget is a really bad idea specially in window managers where Qt fails to detect if the window is maximized. So instead we just resize Neovim to always have the same size as the widget. The downside is that set lines does not work at all.

Excuse me, so...is there a way to automaticly set window _size_ upon start yet?
(unrelated, but since we can't use winpos, can we still _position_ the window upon startup?)
Thanks!

@with0out Yes, there is a way to set the window size upon start up: add alias gvim='nvim-qt --geometry 500x320 --' in your shell rc file. Clearly, the number might need to change depending on what you want/need.

Window position _is not_ something that nvim-qt should ever do. That is the job of your window manager.

@kierun Just tried O:\Neovim\nvim-qt.exe --geometry 800x600 in cmd, and similarly in cygwin shell, it's size didn't seem to change...
(I'm in windows 7, using latest neovim-qt and neovim release)

@with0out I have no idea whatsoever about Windows.

@with0out On Windows 7 I found using -qwindowgeometry 800x600 instead of --geometry 800x600 worked for me.

I think it's important that the window actually saves its state and then when you open Neovim-Qt again, it will appear at the same coordinates with the same size as when you quit.

Of course there are exceptions. For example when you pull the window to the far right, you get it maximized to half of the screen. Now if a second Neovim-Qt window should be opened, it shouldn't be above that window, but instead occupy exactly the other half of the screen.

It seems like the default should be to just let the window manager decide where you should go. I'm not against an option to be explicit but I if anyone is saving the state it should be the WM because that is it's job.

I think it's important that the window actually saves its state and then when you open Neovim-Qt again, it will appear at the same coordinates with the same size as when you quit.

Please do not do that: it is the job of your window manager to do that!

There are far too many edge cases that it will break -- for example tilling window managers.

What I'm suggesting is to actually leave it to the window manager.

I think it's important that the window actually saves its state and then when you open Neovim-Qt again, it will appear at the same coordinates with the same size as when you quit.

This one is tricky if you need a way to command the GUI into a specific size I certainly don't mind adding a command to do it.

The tricky part is to store state and to know when to resize it (or when not to). Honestly I prefer to just add the command and let people script the behavior that makes sense for them or their WM, Vimscript does that well enough. More than that will likely clash into someone's setup.

Is there any way how to start neovim on Windows 10 with a reasonably sized window (not 1x10 or so by default) without passing any arguments to it? Neither set lines nor set columns work. I need it to make NeoVim the default text editor.

@dumblob windows seems to have specific issue when the windows sometimes gets smaller than it should https://github.com/equalsraf/neovim-qt/issues/251

On Windows it seems like setting a shortcut with arguments doesn't work as a default app. The arguments are just ignored.

So to set the startup width and size you can regedit Computer\HKEY_CLASSES_ROOT\Applications\nvim-qt.exe\shell\open\command and change it to something like "C:\Program Files\nvim\bin\nvim-qt.exe" "%1" -qwindowgeometry 800x600

@kylemacfarlane Sadly, the registry hack did not work for me. Should I reboot or something?

Wait! Error between keyboard and floor! I close regedit and now it works like a charm.

Thank you.

Setting -qwindowgeometry works for me.

Was this page helpful?
0 / 5 - 0 ratings