mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 22:23:31 +00:00
Avoid polling if the Qt window is minimized
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Window 2.2
|
||||
|
||||
import QtQuick.Controls.Material 2.1
|
||||
|
||||
import ComputerManager 1.0
|
||||
import AutoUpdateChecker 1.0
|
||||
|
||||
ApplicationWindow {
|
||||
property bool pollingActive: false
|
||||
|
||||
id: window
|
||||
visible: true
|
||||
width: 1280
|
||||
@@ -21,6 +25,24 @@ ApplicationWindow {
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
onVisibilityChanged: {
|
||||
// We don't want to just use 'active' here because that will stop polling if
|
||||
// we lose focus, which might be overzealous for users with multiple screens
|
||||
// where we may be clearly visible on the other display. Ideally we'll poll
|
||||
// only if the window is visible to the user (not if obscured by other windows),
|
||||
// but it seems difficult to do this portably.
|
||||
var shouldPoll = visibility !== Window.Minimized && visibility !== Window.Hidden
|
||||
|
||||
if (shouldPoll && !pollingActive) {
|
||||
ComputerManager.startPolling()
|
||||
pollingActive = true
|
||||
}
|
||||
else if (!shouldPoll && pollingActive) {
|
||||
ComputerManager.stopPollingAsync()
|
||||
pollingActive = false
|
||||
}
|
||||
}
|
||||
|
||||
function navigateTo(url, objectName)
|
||||
{
|
||||
var existingItem = stackView.find(function(item, index) {
|
||||
|
||||
Reference in New Issue
Block a user