From 765aa45c72079b798018cc11ef77380264159b31 Mon Sep 17 00:00:00 2001
From: Michail Vourlakos <mvourlakos@gmail.com>
Date: Sat, 1 Jan 2022 21:03:15 +0200
Subject: [PATCH] view:enable OnAllDesktops during creation

--try to avoid corner cases that wm ignores OnAllDesktops
flag for specific views during startup. This patch should
protect these corner cases.

BUG:447689
FIXED-IN:0.10.7
---
 app/view/view.cpp | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/app/view/view.cpp b/app/view/view.cpp
index cdd63c506..dce8097bb 100644
--- a/app/view/view.cpp
+++ b/app/view/view.cpp
@@ -98,10 +98,20 @@ View::View(Plasma::Corona *corona, QScreen *targetScreen, bool byPassX11WM)
         setFlags(flags);
     }
 
-    if (targetScreen)
+    if (KWindowSystem::isPlatformX11()) {
+        //! Enable OnAllDesktops during creation in order to protect corner cases that is ignored
+        //! during startup. Such corner case is bug #447689.
+        //! Best guess is that this is needed because OnAllDesktops is set through visibilitymanager
+        //! after containment has been assigned. That delay might lead wm ignoring the flag
+        //! until it is reapplied.
+        KWindowSystem::setOnAllDesktops(winId(), true);
+    }
+
+    if (targetScreen) {
         m_positioner->setScreenToFollow(targetScreen);
-    else
+    } else {
         m_positioner->setScreenToFollow(qGuiApp->primaryScreen());
+    }
 
     m_releaseGrabTimer.setInterval(400);
     m_releaseGrabTimer.setSingleShot(true);