rohit-px2 / nvui

A modern frontend for Neovim.
MIT License
1.72k stars 49 forks source link

window size & states not working properly on windows 11 #133

Closed kurakurakantor closed 2 years ago

kurakurakantor commented 2 years ago

when frameless title bar is on, the window position in config moves around 30 pixels up every time i close it, and even though the config says the last state was maximize, it never run on maximize, instead it just open on normal, with the title bar outside of the screen because of the drift so i cant even reach the title bar. when i turn the frameless title bar off, the window always start on maximize, no matter what. i have no idea what is going on

kurakurakantor commented 2 years ago

aha! it's the custom title bar!! the showNormal() is kicking them from maximize and fullscreen, and for me who only uses the title bar, i think the workaround might just be having some conditionals to that, if the config says maximized, then showMaximized instead of showNormal, imma go try that

kurakurakantor commented 2 years ago

for the shift problem, when the window is not close to the top of the screen, it shifts consistently 38 pixels up and 9 pixels to the left, the workaround for me maybe to just manually correct that values when saving the geometry to the config

kurakurakantor commented 2 years ago

also figured out why window always start on maximize when the frameless is off, the load_config just says if the config for that passes as a boolean, showMaximized. i think there's supposed to be a maxim.toBool() in there

kurakurakantor commented 2 years ago

oh my god okay, removing the showMaximized altogether fixes everything, this is because showMaximized was loaded before the title bar (which reloaded the geometry), reload geometry after show will results in shift up left to the size of the non frameless title bar. those shifting up could be a workaround for x11's window shift issue, but in windows it just caused a shifting instead of correction, more about that here: https://doc.qt.io/archives/4.3/geometry.html

kurakurakantor commented 2 years ago

but removing showMaximized results in nvui not launching in maximized even if the config says it should HAHA

kurakurakantor commented 2 years ago

how to fix, working workaround for me: modify windows.cpp as follows

  1. on load_config, instead of showMaximized(), use maximized = (maxim.toBool())
  2. on enable_frameless_window, instead of showNormal();, use if (maximized) showMaximized(); else showNormal(); maximized is already a boolean available in the header files so why not just use that
  3. on save_state, instead of geometry(), use normalGeometry() so it saves size and position when not maximized

bonus, add save_state() on changeEvent so it saves not only when you close

disclaimer: i don't use fullscreen and only use frameless window so that's all i need to modify, also i don't know programming at all this is all trial by fire if someone experiencing the same issue and have a better solution i would appreciate the feedback