[LyX/master] Streamline -geometry command-line option support
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Fri Aug 30 11:19:00 UTC 2024
commit ce9de28f06eb770ae440992fb8ca8b98a07c1cfd
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date: Thu Aug 29 11:10:31 2024 +0200
Streamline -geometry command-line option support
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 | 23 +++++------------------
src/frontends/qt/GuiApplication.cpp | 14 --------------
2 files changed, 5 insertions(+), 32 deletions(-)
diff --git a/src/LyX.cpp b/src/LyX.cpp
index c0dbd019b9..8f13f83713 100644
--- a/src/LyX.cpp
+++ b/src/LyX.cpp
@@ -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]);
diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp
index 6665631d31..f7eabe276c 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -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);
More information about the lyx-cvs
mailing list