Don't start polling from the GUI for a CLI launch

We can end up missing early computerStateChanged signals.

Fixes #2039
This commit is contained in:
Cameron Gutman committed 2026-10-22 19:28:12 -05:00
1 parent dc92b6d2f3
commit 74020b537b
2 files changed
+37 -29

No files matched your search

+36 -28
View File
@@ -51,7 +51,7 @@ ApplicationWindow {
} }
// Display any modal dialogs for configuration warnings // Display any modal dialogs for configuration warnings
if (runConfigChecks) { if (isGuiLaunch) {
if (SystemProperties.isWow64) { if (SystemProperties.isWow64) {
wow64Dialog.open() wow64Dialog.open()
} }
@@ -171,24 +171,28 @@ ApplicationWindow {
} }
onVisibleChanged: { onVisibleChanged: {
// When we become invisible while streaming is going on, // Polling is only managed from the window for a normal GUI launch;
// stop polling immediately. // CLI commands (stream/quit/pair) manage it via the ComputerSeeker.
if (!visible) { if (isGuiLaunch) {
inactivityTimer.stop() // When we become invisible while streaming is going on,
// stop polling immediately.
if (!visible) {
inactivityTimer.stop()
if (pollingActive) { if (pollingActive) {
ComputerManager.stopPollingAsync() ComputerManager.stopPollingAsync()
pollingActive = false pollingActive = false
}
} }
} else if (active) {
else if (active) { // When we become visible and active again, start polling
// When we become visible and active again, start polling inactivityTimer.stop()
inactivityTimer.stop()
// Restart polling if it was stopped // Restart polling if it was stopped
if (!pollingActive) { if (!pollingActive) {
ComputerManager.startPolling() ComputerManager.startPolling()
pollingActive = true pollingActive = true
}
} }
} }
@@ -197,20 +201,24 @@ ApplicationWindow {
} }
onActiveChanged: { onActiveChanged: {
if (active) { // Polling is only managed from the window for a normal GUI launch;
// Stop the inactivity timer // CLI commands (stream/quit/pair) manage it via the ComputerSeeker.
inactivityTimer.stop() if (isGuiLaunch) {
if (active) {
// Stop the inactivity timer
inactivityTimer.stop()
// Restart polling if it was stopped // Restart polling if it was stopped
if (!pollingActive) { if (!pollingActive) {
ComputerManager.startPolling() ComputerManager.startPolling()
pollingActive = true pollingActive = true
}
}
else {
// Start the inactivity timer to stop polling
// if focus does not return within a few minutes.
inactivityTimer.restart()
} }
}
else {
// Start the inactivity timer to stop polling
// if focus does not return within a few minutes.
inactivityTimer.restart()
} }
// Poll for gamepad input only when the window is in focus // Poll for gamepad input only when the window is in focus
+1 -1
View File
@@ -1034,7 +1034,7 @@ int main(int argc, char *argv[])
if (hasGUI) { if (hasGUI) {
engine.rootContext()->setContextProperty("initialView", initialView); engine.rootContext()->setContextProperty("initialView", initialView);
engine.rootContext()->setContextProperty("runConfigChecks", commandLineParserResult == GlobalCommandLineParser::NormalStartRequested); engine.rootContext()->setContextProperty("isGuiLaunch", commandLineParserResult == GlobalCommandLineParser::NormalStartRequested);
// Load the main.qml file // Load the main.qml file
engine.load(QUrl(QStringLiteral("qrc:/gui/main.qml"))); engine.load(QUrl(QStringLiteral("qrc:/gui/main.qml")));