weixin_39903571
weixin_39903571
2020-11-25 20:05

Window size presetting is not working

No matter if I start it with nvim-qt --geometry 300x200 or nvim-qt --qwindowgeometry 60x10, the window size is always the one of the last closed other nvim-qt window.

I'm using...


$ nvim-qt --version
NVIM-QT v0.2.14.0
Build type: Release
Compilation: -Wall -Wextra -Wno-unused-parameter -std=c++11 -Wfatal-errors
Qt Version: 5.13.2
Environment: 
  nvim: nvim
  args: --cmd set termguicolors
  runtime:

NVIM v0.4.3
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/home/travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compilado por travis-job-9a287301-34f2-4b86-92e3-462594f51f36

Features: +acl +iconv +tui
See ":help feature-compile"

     archivo "vimrc" del sistema: "$VIM/sysinit.vim"
            predefinido para $VIM: "
/home/travis/build/neovim/bot-ci/build/neovim/build/nvim.AppDir/usr/share/nvim
"

Run :checkhealth for more info

该提问来源于开源项目:equalsraf/neovim-qt

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

6条回答

  • weixin_39605997 weixin_39605997 5月前

    This issue reproduces in v0.2.14, but not v0.2.15. You need this commit: cc2c67891f5525fc463460c9b1c33f127aa54667.

    An upgrade will resolve the issue. Sorry for the break.

    点赞 评论 复制链接分享
  • weixin_39903571 weixin_39903571 5月前

    I updated the code:

    
    10:20:43|facundo:~/sistema/neovim-qt/build (master)$ git rev-parse HEAD
    eb98732b7d39233418b6197c3106ff1454a9fcaa
    

    but opened windows still not being affected by those parameters. I'm executing it like:

    
    10:20:44|facundo:~/sistema/neovim-qt/build (master)$ bin/nvim-qt --geometry 500x100 --qwindowgeometry 500x100
    
    点赞 评论 复制链接分享
  • weixin_39605997 weixin_39605997 5月前

    Thanks for re-testing!

    From what I can tell: - v0.2.14 -- not working - v0.2.15 -- working, fixed by cc2c67891f5525fc463460c9b1c33f127aa54667 - master -- not working, broken by 847f0271f2af61a35e8676e069a2e8b31a527760

    It looks like the problem lies in:

    C++
    NeovimQt::App app(argc, argv);
    

    The parent constructor, QApplication can modify argc/argv in-place. It will sometimes remove command line arguments! :fearful:

    In this case --geometry is recognized and removed. The removal of the argument prevents m_parser from checking for this scenario, and breaks the fix from cc2c67891f5525fc463460c9b1c33f127aa54667.

    I very much dislike QCommandLineParser and how Qt parses arguments...

    点赞 评论 复制链接分享
  • weixin_39605997 weixin_39605997 5月前

    Unrelated thoughts:

    The version output for v0.2.15 is not correct. The CMake constant was not updated for the release.

    It looks like the --version argument could use some additional work. The output for this scenario was not accurate. Instead of NVIM-QT v0.2.14.0, we should output something like NVIM_QT git-eb98732.

    Maybe there is a good way for CMake to automatically generate the version/hash from git?

    点赞 评论 复制链接分享
  • weixin_39605997 weixin_39605997 5月前

    Can you test this patch?

    From my tests, we can work around the issue by saving arguments before QApplication clobbers them:

    patch
    diff -r ee9766fc4c43 src/gui/main.cpp
    --- a/src/gui/main.cpp  Thu Jan 23 19:25:27 2020 -0500
    +++ b/src/gui/main.cpp  Mon Feb 17 00:57:41 2020 -0500
    @@ -40,15 +40,17 @@
    
     int cli_main(int argc, char **argv)
     {
    +   QStringList arguments{ "--nofork" };
    +   for (int i = 1; i < argc; i++)
    +   {
    +       arguments << argv[i];
    +   }
    +
        NeovimQt::App app(argc, argv);
    
        app.checkArgumentsMayTerminate();
    
    -   // Get existing arguments, drop executable, append --nofork.
    -   QStringList new_args{ app.arguments().mid(1) };
    -   new_args.insert(0, "--nofork");
    -
    -   if (!QProcess::startDetached(app.applicationFilePath(), new_args)) {
    +   if (!QProcess::startDetached(app.applicationFilePath(), arguments)) {
            qWarning() << "Unable to fork into background";
            return -1;
        }
    

    In an ideal world we would have App<{QCoreApplication or QApplication}> app(argc, argv), but Q_OBJECT does not support templates. Inheritance doesn't work well either (multiple inheritance issues).

    点赞 评论 复制链接分享
  • weixin_39903571 weixin_39903571 5月前

    I tested the patch; with it both --geometry and --qwindowgeometry (together or separated) work fine.

    Thanks!!

    点赞 评论 复制链接分享

相关推荐