From: Kevin Ottens Date: Thu, 22 Oct 2020 10:39:40 +0000 (+0200) Subject: Ensure we quickly show/hide the systray window on startup X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~22^2~94^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=24964e2b9b0e4c339765efd7a80754beb407cc15;p=nextcloud-desktop.git Ensure we quickly show/hide the systray window on startup This is quick enough that no flickering should appear in practice. We end up doing this because for some reason on Windows (I dug up deep into the Windows QPA without nailing it down) not showing that systray window at least once prevents the app object to return from exec() when the session ends. It's as if that window would be in some limbo state (neither opened nor closed) which would prevent quitting. Clearly what we're doing here is a workaround... Signed-off-by: Kevin Ottens --- diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index d29456207..3309f54b3 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -206,6 +206,15 @@ void Systray::positionWindow(QQuickWindow *window) const window->setPosition(position); } +void Systray::forceWindowInit(QQuickWindow *window) const +{ + // HACK: At least on Windows, if the systray window is not shown at least once + // it can prevent session handling to carry on properly, so we show/hide it here + // this shouldn't flicker + window->show(); + window->hide(); +} + QScreen *Systray::currentScreen() const { const auto screens = QGuiApplication::screens(); diff --git a/src/gui/systray.h b/src/gui/systray.h index 9e1458a13..bf7e6133e 100644 --- a/src/gui/systray.h +++ b/src/gui/systray.h @@ -57,6 +57,7 @@ public: Q_INVOKABLE void setOpened(); Q_INVOKABLE void setClosed(); Q_INVOKABLE void positionWindow(QQuickWindow *window) const; + Q_INVOKABLE void forceWindowInit(QQuickWindow *window) const; signals: void currentUserChanged(); diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index d06260a46..bb6be3ecb 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -24,6 +24,8 @@ Window { Accessible.role: Accessible.Application Accessible.name: qsTr("Nextcloud desktop main dialog") + Component.onCompleted: Systray.forceWindowInit(trayWindow) + // Close tray window when focus is lost (e.g. click somewhere else on the screen) onActiveChanged: { if(!active) {