diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-12-15 15:20:04 +0100 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-12-15 15:20:04 +0100 |
commit | 57d1dffdbd453af572d1460495edd81427bc2b04 (patch) | |
tree | 8deb94ba6a52200c1ea7e44c8f095874e873b17a /third_party/SingleApplication-3.3.2/Windows.md | |
parent | Use icns on macOS (diff) | |
download | nheko-57d1dffdbd453af572d1460495edd81427bc2b04.tar.xz |
Update to SingleApplication 3.3.2 proper
Diffstat (limited to 'third_party/SingleApplication-3.3.2/Windows.md')
-rw-r--r-- | third_party/SingleApplication-3.3.2/Windows.md | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/third_party/SingleApplication-3.3.2/Windows.md b/third_party/SingleApplication-3.3.2/Windows.md new file mode 100644 index 00000000..13c52da0 --- /dev/null +++ b/third_party/SingleApplication-3.3.2/Windows.md @@ -0,0 +1,46 @@ +Windows Specific Implementations +================================ + +Setting the foreground window +----------------------------- + +In the `instanceStarted()` example in the `README` we demonstrated how an +application can bring it's primary instance window whenever a second copy +of the application is started. + +On Windows the ability to bring the application windows to the foreground is +restricted, see [`AllowSetForegroundWindow()`][AllowSetForegroundWindow] for more +details. + +The background process (the primary instance) can bring its windows to the +foreground if it is allowed by the current foreground process (the secondary +instance). To bypass this `SingleApplication` must be initialized with the +`allowSecondary` parameter set to `true` and the `options` parameter must +include `Mode::SecondaryNotification`, See `SingleApplication::Mode` for more +details. + +Here is an example: + +```cpp +if( app.isSecondary() ) { + // This API requires LIBS += User32.lib to be added to the project + AllowSetForegroundWindow( DWORD( app.primaryPid() ) ); +} + +if( app.isPrimary() ) { + QObject::connect( + &app, + &SingleApplication::instanceStarted, + this, + &App::instanceStarted + ); +} +``` + +```cpp +void App::instanceStarted() { + QApplication::setActiveWindow( [window/widget to set to the foreground] ); +} +``` + +[AllowSetForegroundWindow]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms632668.aspx |