From a844f82fd01b6d942e51089574d855deb1c138f0 Mon Sep 17 00:00:00 2001 From: Lucas Sifoni Date: Tue, 25 Nov 2025 19:01:25 +0100 Subject: [PATCH 1/2] Fixes windows platform arguments being systematically prepended --- main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index f58d6c5c..ddd80df8 100644 --- a/main.cpp +++ b/main.cpp @@ -128,7 +128,11 @@ int main(int argc, char *argv[]) // Following code adds the platform argument programmatically // Create a new argv array with existing args plus platform args - int newArgc = argc + 2; + #ifdef Q_OS_WIN + int newArgc = argc + 2; + #else + int newArgc = argc; + #endif std::vector args; args.reserve(newArgc); // Copy existing arguments @@ -136,8 +140,10 @@ int main(int argc, char *argv[]) args.emplace_back(argv[i]); } // Add new arguments + #ifdef Q_OS_WIN args.emplace_back("-platform"); args.emplace_back("windows:darkmode=1"); + #endif // Build non-const char* array std::vector newArgv; newArgv.reserve(newArgc); From 2b67254fc1a5c0db56b89b14955715da7d4b1acd Mon Sep 17 00:00:00 2001 From: Chantepierre Date: Wed, 26 Nov 2025 08:32:47 +0100 Subject: [PATCH 2/2] Simplifies conditionals in darkmode flag definition for win32 --- main.cpp | 52 ++++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/main.cpp b/main.cpp index ddd80df8..7687d79e 100644 --- a/main.cpp +++ b/main.cpp @@ -123,36 +123,32 @@ static int myCvErrorCallback( int /*status*/, const char* /*func_name*/, int main(int argc, char *argv[]) { - // DFTFringe doesn't have a good darkmode palette - // one could call "DFTFringe.exe -platform windows:darkmode=1" to disable dark mode (except for app borders) - // Following code adds the platform argument programmatically - - // Create a new argv array with existing args plus platform args - #ifdef Q_OS_WIN - int newArgc = argc + 2; + #ifdef _WIN32 + // DFTFringe doesn't have a good darkmode palette + // one could call "DFTFringe.exe -platform windows:darkmode=1" to disable dark mode (except for app borders) + // Following code adds the platform argument programmatically + // Create a new argv array with existing args plus platform args + int newArgc = argc + 2; + std::vector args; + args.reserve(newArgc); + // Copy existing arguments + for (int i = 0; i < argc; ++i) { + args.emplace_back(argv[i]); + } + // Add new arguments + args.emplace_back("-platform"); + args.emplace_back("windows:darkmode=1"); + // Build non-const char* array + std::vector newArgv; + newArgv.reserve(newArgc); + for (auto &arg : args) { + newArgv.push_back(&arg[0]); // C++11 guarantees contiguous storage + } + // Allow secondary instances + SingleApplication app( newArgc, newArgv.data(), true ); #else - int newArgc = argc; + SingleApplication app( argc, argv, true ); #endif - std::vector args; - args.reserve(newArgc); - // Copy existing arguments - for (int i = 0; i < argc; ++i) { - args.emplace_back(argv[i]); - } - // Add new arguments - #ifdef Q_OS_WIN - args.emplace_back("-platform"); - args.emplace_back("windows:darkmode=1"); - #endif - // Build non-const char* array - std::vector newArgv; - newArgv.reserve(newArgc); - for (auto &arg : args) { - newArgv.push_back(&arg[0]); // C++11 guarantees contiguous storage - } - - // Allow secondary instances - SingleApplication app( newArgc, newArgv.data(), true ); MessageReceiver msgReceiver;