Ensure we quickly show/hide the systray window on startup
authorKevin Ottens <kevin.ottens@nextcloud.com>
Thu, 22 Oct 2020 10:39:40 +0000 (12:39 +0200)
committerCamila (Rebase PR Action) <hello@camila.codes>
Thu, 22 Oct 2020 17:31:05 +0000 (17:31 +0000)
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 <kevin.ottens@nextcloud.com>
src/gui/systray.cpp
src/gui/systray.h
src/gui/tray/Window.qml

index d29456207e710e626637255d0d7fb5d5e6a192c5..3309f54b3db0cfb5c113ef3815200f550c1522f4 100644 (file)
@@ -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();
index 9e1458a13c82746181569063dabe98effc136dac..bf7e6133ee2ba43e338ead2eaa0a154d328b821f 100644 (file)
@@ -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();
index d06260a46831e686c007cf26ea1533c54310c014..bb6be3ecb46d8c872a584c37c3f8242596d4ce7c 100644 (file)
@@ -24,6 +24,8 @@ Window {
     Accessible.role: Accessible.Application\r
     Accessible.name: qsTr("Nextcloud desktop main dialog")\r
 \r
+    Component.onCompleted: Systray.forceWindowInit(trayWindow)\r
+\r
     // Close tray window when focus is lost (e.g. click somewhere else on the screen)\r
     onActiveChanged: {\r
         if(!active) {\r