From 80e356ffb2475046ed8e5f73cd7622d9de0fbfa0 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Mon, 5 Dec 2016 12:17:56 +0100 Subject: [PATCH] Add maximize=1/0 parameter to gui native viewer defs for opening maximized window on Windows --- src/qtgui/rclm_view.cpp | 19 ++++++++++++++----- src/qtgui/rclmain_w.h | 3 ++- src/utils/execmd.h | 2 ++ src/windows/execmd_w.cpp | 10 +++++++--- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/qtgui/rclm_view.cpp b/src/qtgui/rclm_view.cpp index 6322d2fd..ecba10e3 100644 --- a/src/qtgui/rclm_view.cpp +++ b/src/qtgui/rclm_view.cpp @@ -157,7 +157,10 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term) { string apptag; doc.getmeta(Rcl::Doc::keyapptg, &apptag); - LOGDEB("RclMain::startNativeViewer: mtype [" << (doc.mimetype) << "] apptag [" << (apptag) << "] page " << (pagenum) << " term [" << ((const char *)(term.toUtf8())) << "] url [" << (doc.url) << "] ipath [" << (doc.ipath) << "]\n" ); + LOGDEB("RclMain::startNativeViewer: mtype [" << doc.mimetype << + "] apptag [" << apptag << "] page " << pagenum << " term [" << + qs2utf8s(term) << "] url [" << doc.url << "] ipath [" << + doc.ipath << "]\n"); // Look for appropriate viewer string cmdplusattr = theconfig->getMimeViewerDef(doc.mimetype, apptag, @@ -174,9 +177,15 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term) string cmd; theconfig->valueSplitAttributes(cmdplusattr, cmd, viewerattrs); bool ignoreipath = false; + int execwflags = 0; if (viewerattrs.get("ignoreipath", cmdplusattr)) ignoreipath = stringToBool(cmdplusattr); - + if (viewerattrs.get("maximize", cmdplusattr)) { + if (stringToBool(cmdplusattr)) { + execwflags |= ExecCmd::EXF_MAXIMIZED; + } + } + // Split the command line vector lcmd; if (!stringToStrings(cmd, lcmd)) { @@ -389,13 +398,13 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term) it != doc.meta.end(); it++) { subs[it->first] = it->second; } - execViewer(subs, enterHistory, execpath, lcmd, cmd, doc); + execViewer(subs, enterHistory, execpath, lcmd, cmd, doc, execwflags); } void RclMain::execViewer(const map& subs, bool enterHistory, const string& execpath, const vector& _lcmd, const string& cmd, - Rcl::Doc doc) + Rcl::Doc doc, int flags) { string ncmd; vector lcmd; @@ -429,7 +438,7 @@ void RclMain::execViewer(const map& subs, bool enterHistory, zg_send_event(ZGSEND_OPEN, doc); // We keep pushing back and never deleting. This can't be good... - ExecCmd *ecmd = new ExecCmd(ExecCmd::EXF_SHOWWINDOW); + ExecCmd *ecmd = new ExecCmd(ExecCmd::EXF_SHOWWINDOW | flags); m_viewers.push_back(ecmd); ecmd->startExec(execpath, lcmd, false, false); } diff --git a/src/qtgui/rclmain_w.h b/src/qtgui/rclmain_w.h index 31fe1210..b791095a 100644 --- a/src/qtgui/rclmain_w.h +++ b/src/qtgui/rclmain_w.h @@ -252,9 +252,10 @@ private: virtual void setupResTB(bool combo); virtual void previewPrevOrNextInTab(Preview *, int sid, int docnum, bool next); + // flags may contain ExecCmd::EXF_xx values virtual void execViewer(const map& subs, bool enterHistory, const string& execpath, const vector& lcmd, - const string& cmd, Rcl::Doc doc); + const string& cmd, Rcl::Doc doc, int flags=0); virtual void setStemLang(const QString& lang); virtual void onSortCtlChanged(); virtual void showIndexConfig(bool modal); diff --git a/src/utils/execmd.h b/src/utils/execmd.h index 559a7feb..93ee8607 100644 --- a/src/utils/execmd.h +++ b/src/utils/execmd.h @@ -199,6 +199,8 @@ public: // because it avoids windows appearing and // disappearing when executing stuff for previewing EXF_SHOWWINDOW = 1, + // Windows only: show maximized + EXF_MAXIMIZED = 2, }; ExecCmd(int flags = 0); ~ExecCmd(); diff --git a/src/windows/execmd_w.cpp b/src/windows/execmd_w.cpp index a5129cbc..c7092bef 100644 --- a/src/windows/execmd_w.cpp +++ b/src/windows/execmd_w.cpp @@ -764,15 +764,19 @@ int ExecCmd::startExec(const string &cmd, const vector& args, siStartInfo.cb = sizeof(STARTUPINFO); if (m->m_flags & EXF_SHOWWINDOW) { siStartInfo.dwFlags |= STARTF_USESTDHANDLES; + if (m->m_flags & EXF_MAXIMIZED) { + siStartInfo.dwFlags |= STARTF_USESHOWWINDOW; + siStartInfo.wShowWindow = SW_SHOWMAXIMIZED; + } } else { siStartInfo.dwFlags |= STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; + // This is to hide the console when starting a cmd line command from + // the GUI. Also note STARTF_USESHOWWINDOW above + siStartInfo.wShowWindow = SW_HIDE; } siStartInfo.hStdOutput = hOutputWrite; siStartInfo.hStdInput = hInputRead; siStartInfo.hStdError = hErrorWrite; - // This is to hide the console when starting a cmd line command from - // the GUI. Also note STARTF_USESHOWWINDOW above - siStartInfo.wShowWindow = SW_HIDE; char *envir = mergeEnvironment(m->m_env);