]> git.lyx.org Git - lyx.git/commitdiff
Streamline -geometry command-line option support
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 29 Aug 2024 09:10:31 +0000 (11:10 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 30 Aug 2024 09:15:02 +0000 (11:15 +0200)
Instead of baking our own support for -geometry command line option on
Windows (Qt only does that for Xcb), use the fact that Qt 5 provides
the equivalent -qwindowgeometry flag.

All we need to do is to replace the -geometry option with -qwindowgeometry.

This is part of the effort in ticket #13086 to get rid of the
compile-time QPA_XCB define.

src/LyX.cpp
src/frontends/qt/GuiApplication.cpp

index c0dbd019b97ba51590ec0e4fb00156ce70bef29f..8f13f837130044927d8888c97d0e7d7a90218c07 100644 (file)
@@ -127,8 +127,6 @@ namespace {
 string cl_system_support;
 string cl_user_support;
 
-string geometryArg;
-
 LyX * singleton_ = nullptr;
 
 void showFileError(string const & error)
@@ -611,7 +609,7 @@ void LyX::execCommands()
        }
 
        // create the first main window
-       lyx::dispatch(FuncRequest(LFUN_WINDOW_NEW, geometryArg));
+       lyx::dispatch(FuncRequest(LFUN_WINDOW_NEW));
 
        if (!pimpl_->files_to_load_.empty()) {
                // if some files were specified at command-line we assume that the
@@ -1342,20 +1340,6 @@ int parse_import(string const & type, string const & file, string & batch)
 }
 
 
-int parse_geometry(string const & arg1, string const &, string &)
-{
-       geometryArg = arg1;
-#if !defined(QPA_XCB)
-       // don't remove "-geometry", it will be pruned out later in the
-       // frontend if need be.
-       return -1;
-#else
-       // but that is only done if QPA_XCB is not defined.
-       return 1;
-#endif
-}
-
-
 int parse_batch(string const &, string const &, string &)
 {
        use_gui = false;
@@ -1433,7 +1417,6 @@ void LyX::easyParse(int & argc, char * argv[])
        cmdmap["--export-to"] = parse_export_to;
        cmdmap["-i"] = parse_import;
        cmdmap["--import"] = parse_import;
-       cmdmap["-geometry"] = parse_geometry;
        cmdmap["-batch"] = parse_batch;
        cmdmap["-f"] = parse_force;
        cmdmap["--force-overwrite"] = parse_force;
@@ -1446,6 +1429,10 @@ void LyX::easyParse(int & argc, char * argv[])
        cmdmap["--ignore-error-message"] = parse_ignore_error_message;
 
        for (int i = 1; i < argc; ++i) {
+               // Let Qt handle -geometry even when not on X11.
+               if (from_utf8(argv[i]) == "-geometry")
+                       argv[i] = const_cast<char *>("-qwindowgeometry");
+
                map<string, cmd_helper>::const_iterator it
                        = cmdmap.find(argv[i]);
 
index 6665631d31c593eb458aa0e8b7e69b59db0046ad..f7eabe276cfb2ade0432dad182bc11b1aac9f8ea 100644 (file)
@@ -172,20 +172,6 @@ namespace lyx {
 
 frontend::Application * createApplication(int & argc, char * argv[])
 {
-#if !defined(QPA_XCB)
-       // prune -geometry argument(s) by shifting
-       // the following ones 2 places down.
-       for (int i = 0 ; i < argc ; ++i) {
-               if (strcmp(argv[i], "-geometry") == 0) {
-                       int const remove = (i+1) < argc ? 2 : 1;
-                       argc -= remove;
-                       for (int j = i; j < argc; ++j)
-                               argv[j] = argv[j + remove];
-                       --i;
-               }
-       }
-#endif
-
 #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
        // On Windows, allow bringing the LyX window to top
        AllowSetForegroundWindow(ASFW_ANY);