equalsraf / neovim-qt

Neovim client library and GUI, in Qt5.
https://github.com/equalsraf/neovim-qt/wiki
ISC License
1.83k stars 171 forks source link

Neovim-Qt sometimes starts with small window #251

Closed xelra closed 3 years ago

xelra commented 7 years ago

This might be specific to Windows.

Sometimes the Neovim-Qt window is really small after starting it. It's hard to predict when it will happen, but it's more likely to happen on the first startup after a reboot. It never happens for consecutive startups.

This is how it looks: untitled

Then I just close the window and start Neovim-Qt again: untitled2

equalsraf commented 7 years ago

I can confirm this, we just discussed it in https://www.reddit.com/r/neovim/comments/5xm887/neovimqt_wont_read_my_configuration_files/

No idea what is going on there, the default behaviour should be to set the window to about 2/3 of the widht/height. But it sometime gets a lot smaller.

christianrondeau commented 7 years ago

Same issue: Windows 10 v1607, neovim v0.2.0.855 64 bit, nvim-qt v0.2.6... I think :) I actually don't know how to see the version number of nvim-qt!

qwfy commented 7 years ago

Having invalid settings in init.vim can cause this (tiny window), try typing nvim in bash (instead of launching it from a icon) to see if any errors are printed.

feanor12 commented 7 years ago

I have the same problem using arch-linux. Starting nvim-qt from the command line does not show any errors. I think it happens when the content is not loaded fast enough. For example when using a sftp mount.

j-silver commented 7 years ago

It's possible to impose the window size through the command line flag --geometry (width)x(height)

For example $ nvim-qt --geometry 1400x900

I've defined an alias of nvim-qt in my .bashrc

qwfy commented 7 years ago

@feanor12 I made a mistake in my previous comment, typing nvim instead of nvim-qt in the command line, I've corrected it.

feanor12 commented 7 years ago

@qwfy nvim does not create any errors on the command line, either.

dumblob commented 7 years ago

I experince very similar issue as @xelra. On my Windows 10 machine (freshly installed and updated) nvim always starts with a tiny window as @xelra showed disregarding whether it's a first execution or not after startup and disregarding whether it's plain execution from using a double click directly on the bundled nvim-qt.exe file or whether it's executed by Windows 10 when clicking on a text file associated (based on the file extension - you know the Windows way of handling "mime types") with nvim-qt.exe.

DaSea commented 7 years ago

In ginit.vim file, add call rpcnotify(0, 'Gui', 'WindowMaximized', 1), can show maximized!

RedX2501 commented 7 years ago

In my case it was an echom command in my init.vim file that prevented the window from reaching its size.

Edit: It really seems to be caused by any message during startup for me.

davclark commented 7 years ago

I have the same issue. Seems more common when I have an external monitor (in my case I have a different ratio for enlarging applications for hiDPI)

tistatos commented 7 years ago

I've had similar issue when on windows 10. My issue seemed to be plugins that had unmet requirement in regards to what flags nvim was compiled with. By disabling the plugins, the window opens in a proper size.

kylemacfarlane commented 7 years ago

I had the same problem and it ended up being caused by the YouCompleteMe plugin which wasn't starting up properly because I hadn't configured the Python provider yet.

But this bug is actually probably a symptom of another bug related to startup error messages. It's easy to recreate by doing something simple like setting colorscheme to something bad. nvim-qt.exe will start up with a tiny window (and broken colours of course) but no error messages. On the other hand nvim.exe will show the error messages but fail to start and has to be killed.

shlomif commented 7 years ago

I'm running into this problem here on Mageia Linux v7 using the Plasma 5 desktop and latest nvim and nvim-qt. I can reproduce it all the time by issuing nvim-qt +mak .

luzhlon commented 6 years ago

hey, I have a temporary solution as follows

if !has('nvim') | finish | endif

fun! s:set_size(...)
py3 << EOF
from ctypes import *
u32 = WinDLL('user32.dll')

# Fix me
LEFT = 160
TOP = 50
WIDTH = 888
HEIGHT = 666

GetForegroundWindow = u32.GetForegroundWindow
GetSystemMetrics = u32.GetSystemMetrics
SetWindowPos = u32.SetWindowPos

cw = GetForegroundWindow()
SetWindowPos(cw, 0, LEFT, TOP, WIDTH, HEIGHT, 0)
EOF
endf

fun! s:start()
    " call timer_start(50, funcref('s:set_size'))
    call s:set_size()
endf

au GUIEnter * call <sid>start()
equalsraf commented 6 years ago

:o GUIEnter should not even be called in nvim. @luzhlon is s:start() getting called?

luzhlon commented 6 years ago

@equalsraf thanks. I added doautocmd GUIEnter in my ginit.vim 😀

equalsraf commented 6 years ago

Was it working before? It might just work as a side effect of waiting for the python provider to load.

kierun commented 6 years ago

I get the exact same problem but only calling neovim-qt <some file> and only on Windows.

sryze commented 6 years ago

I'm new to neovim-qt, I added --maximized to nvim-qt.desktop in order to have it start always maximized but sometimes the window appears small after startup and looks like it's chopped off (can't see what commands I'm typing):

screenshot from 2017-12-24 09-33-51

Edit:

It happens even if not using the desktop file, when simply running nvim-qt --maximized from the terminal.

AdnoC commented 6 years ago

Modified the code @luzhlon posted to correctly center windows on different resolution monitors and to also scale the size based on the resolution.

The code is rather large so I put it in a gist.

luzhlon commented 6 years ago

@AdnoC It's too complicated, but it is more perfect as well.

AdnoC commented 6 years ago

@luzhlon True enough. Removing the pid stuff and just grabbing the foreground window makes it a bit more reasonable.

Problem was that I opened vim and clicked something else while it was opening, which caused that thing's window to be resized instead of nvim's.

Himura2la commented 6 years ago

On Windows 10 you should use -qwindowgeometry 1030x608

tigerwin2015 commented 6 years ago

you can create a shortcut for nvim-qt.vim and change the target to something like C:\tools\neovim\Neovim\bin\nvim-qt.exe -qwindowgeometry 1030x608

and the window becomes the size you specified.

thanks to @Himura2la

eyalk5 commented 4 years ago

/Applications/nvim-qt.app/Contents/MacOS/nvim-qt --qwindowgeometry 6x4 opens it on maximum

jgehrig commented 3 years ago

We now store the window size on close, and restore on open.

This issue should not occur anymore. Marking as closed.

roysubs commented 1 year ago

This issue is constant when running in Windows Sandbox (which I use a lot for testing and development). I do not see this issue anywhere else. Can you see from the work on the fix above a way to fix the "tiny-window glitch" for neovim running in a Windows Sandbox container?