UI: ControlCommand: Allow other foreground windows

This commit is contained in:
Nodir Temirkhodjaev 2024-01-06 18:13:49 +03:00
parent 75e020cac8
commit 80fe138b14
5 changed files with 13 additions and 2 deletions

View File

@ -112,6 +112,8 @@ bool ControlManager::processCommandClient()
if (args.isEmpty())
return false;
OsUtil::allowOtherForegroundWindows(); // let the running instance to activate a window
return postCommand(command, args);
}

View File

@ -174,3 +174,8 @@ void OsUtil::setThreadIsBusy(bool on)
// Works correct only on Windows 11+
SetThreadExecutionState(ES_CONTINUOUS | (on ? ES_SYSTEM_REQUIRED : 0));
}
bool OsUtil::allowOtherForegroundWindows()
{
return AllowSetForegroundWindow(ASFW_ANY);
}

View File

@ -38,8 +38,9 @@ public:
static void writeToConsole(const QString &line);
static bool setCurrentThreadName(const QString &name);
static void setThreadIsBusy(bool on);
static bool allowOtherForegroundWindows();
};
#endif // OSUTIL_H

View File

@ -18,6 +18,7 @@ void WidgetWindow::showWidget(QWidget *w, bool activate)
if (w->isMinimized()) {
w->setWindowState(w->windowState() ^ Qt::WindowMinimized);
}
w->show();
w->raise();

View File

@ -116,8 +116,10 @@ int main(int argc, char *argv[])
ControlManager controlManager;
ioc.setService<ControlManager>(controlManager);
if (controlManager.isCommandClient()) // Send control command to running instance
if (controlManager.isCommandClient()) {
// Send control command to running instance
return controlManager.processCommandClient() ? 0 : FortErrorControl;
}
// Setup Fort Manager
FortManager::setupResources();