From f43d1b56c7f1fe008e51a9796f2006e1fd355f58 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Tue, 7 May 2019 22:06:00 +0300 Subject: [PATCH] fix crash concerning WORKAROUND for KWIN --KWin hides some Views without reason when Activities are closed under Multiple mode. This crash fixes these kind of crashes. --- app/view/view.cpp | 54 ++++++++++++++++++++++++++++++++--------------- app/view/view.h | 8 ++++++- 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/app/view/view.cpp b/app/view/view.cpp index b543c9037..4cfa4d696 100644 --- a/app/view/view.cpp +++ b/app/view/view.cpp @@ -148,6 +148,14 @@ View::~View() { m_inDelete = true; + //! clear managedLayout connections + m_visibleHackTimer1.stop(); + m_visibleHackTimer2.stop(); + for (auto &c : connectionsManagedLayout) { + disconnect(c); + } + + //! unload indicators if (m_indicator) { m_indicator->unloadIndicators(); } @@ -833,27 +841,39 @@ void View::setManagedLayout(Layout::GenericLayout *layout) } }); - //!IMPORTANT!!! ::: This fixes a bug when closing an Activity all docks from all Activities are - //! disappearing! With this they reappear!!! + //! BEGIN OF KWIN HACK + //! IMPORTANT ::: Fixing KWin Faulty Behavior that KWin hides ALL Views when an Activity stops + //! with no reason!! + + m_visibleHackTimer1.setInterval(100); + m_visibleHackTimer2.setInterval(1500); + m_visibleHackTimer1.setSingleShot(true); + m_visibleHackTimer2.setSingleShot(true); + connectionsManagedLayout[5] = connect(this, &QWindow::visibleChanged, this, [&]() { - if (!isVisible() && m_managedLayout) { - QTimer::singleShot(100, [this]() { - if (m_managedLayout && containment() && !containment()->destroyed()) { - setVisible(true); - applyActivitiesToWindows(); - emit activitiesChanged(); - } - }); + if (m_managedLayout && !inDelete() & !isVisible()) { + m_visibleHackTimer1.start(); + m_visibleHackTimer2.start(); + } + }); - QTimer::singleShot(1500, [this]() { - if (m_managedLayout && containment() && !containment()->destroyed()) { - setVisible(true); - applyActivitiesToWindows(); - emit activitiesChanged(); - } - }); + connectionsManagedLayout[6] = connect(&m_visibleHackTimer1, &QTimer::timeout, this, [&]() { + if (m_managedLayout && !inDelete() & !isVisible()) { + setVisible(true); + applyActivitiesToWindows(); + emit activitiesChanged(); } }); + + connectionsManagedLayout[7] = connect(&m_visibleHackTimer2, &QTimer::timeout, this, [&]() { + if (m_managedLayout && !inDelete() && !isVisible()) { + setVisible(true); + applyActivitiesToWindows(); + emit activitiesChanged(); + } + }); + + //! END OF KWIN HACK } emit managedLayoutChanged(); diff --git a/app/view/view.h b/app/view/view.h index da3a63643..78f732068 100644 --- a/app/view/view.h +++ b/app/view/view.h @@ -306,6 +306,12 @@ private: QRect m_localGeometry; QRect m_absoluteGeometry; + //! HACK: Timers in order to handle KWin faulty + //! behavior that hides Views when closing Activities + //! with no actual reason + QTimer m_visibleHackTimer1; + QTimer m_visibleHackTimer2; + Layout::GenericLayout *m_managedLayout{nullptr}; QPointer m_configView; @@ -317,7 +323,7 @@ private: QPointer m_windowsTracker; //! Connections to release and bound for the managed layout - std::array connectionsManagedLayout; + std::array connectionsManagedLayout; QPointer m_corona;