diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 99cd9336..76ed7ecd 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -742,6 +742,25 @@ bool MainWindow::serverArgs(QStringList& args, QString& app) #endif args << "-c" << configFilename << "--address" << address(); +#if defined(Q_OS_WIN) + // pass in physical resolution and primary screen center + // TODO: get this information in the core binary even when + // high DPI is used + int height = QApplication::desktop()->height(); + int width = QApplication::desktop()->width(); + + QRect rec = QApplication::desktop()->screenGeometry(); + int heightCenter = rec.height() / 2; + int widthCenter = rec.width() / 2; + + appendLogDebug(tr("screen resolution: %1 %2 primary screen center: %3 %4") + .arg(width).arg(height).arg(widthCenter).arg(heightCenter)); + + args << "--res-w" << QString::number(width); + args << "--res-h" << QString::number(height); + args << "--prm-wc" << QString::number(widthCenter); + args << "--prm-hc" << QString::number(heightCenter); + #endif return true; } diff --git a/src/lib/synergy/ArgParser.cpp b/src/lib/synergy/ArgParser.cpp index 92185b26..3580ab5a 100644 --- a/src/lib/synergy/ArgParser.cpp +++ b/src/lib/synergy/ArgParser.cpp @@ -23,7 +23,9 @@ #include "synergy/ClientArgs.h" #include "synergy/ToolArgs.h" #include "synergy/ArgsBase.h" +#include "synergy/DpiHelper.h" #include "base/Log.h" +#include "base/String.h" ArgsBase* ArgParser::m_argsBase = NULL; @@ -56,6 +58,18 @@ ArgParser::parseServerArgs(ServerArgs& args, int argc, const char* const* argv) // save configuration file path args.m_configFile = argv[++i]; } + else if (isArg(i, argc, argv, "", "--res-w", 1)) { + DpiHelper::s_resolutionWidth = synergy::string::stringToSizeType(argv[++i]); + } + else if (isArg(i, argc, argv, "", "--res-h", 1)) { + DpiHelper::s_resolutionHeight = synergy::string::stringToSizeType(argv[++i]); + } + else if (isArg(i, argc, argv, "", "--prm-wc", 1)) { + DpiHelper::s_primaryWidthCenter = synergy::string::stringToSizeType(argv[++i]); + } + else if (isArg(i, argc, argv, "", "--prm-hc", 1)) { + DpiHelper::s_primaryHeightCenter = synergy::string::stringToSizeType(argv[++i]); + } else { LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname)); return false;