From f63a0ad658877266e5324ac1f044347a3c3793d1 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Tue, 14 May 2019 17:40:44 +0300 Subject: [PATCH] update/improve hack part of screenghostwindow --related to KWin faulty behavior for visibility --- app/view/screenedgeghostwindow.cpp | 78 +++++++++++++++++++----------- app/view/screenedgeghostwindow.h | 8 +++ app/view/visibilitymanager.cpp | 6 +++ 3 files changed, 64 insertions(+), 28 deletions(-) diff --git a/app/view/screenedgeghostwindow.cpp b/app/view/screenedgeghostwindow.cpp index 9a8bf468f..dfedf30fc 100644 --- a/app/view/screenedgeghostwindow.cpp +++ b/app/view/screenedgeghostwindow.cpp @@ -82,31 +82,41 @@ ScreenEdgeGhostWindow::ScreenEdgeGhostWindow(Latte::View *view) : if (!KWindowSystem::isPlatformWayland()) { - connect(this, &QWindow::visibleChanged, this, [&]() { - //! IMPORTANT!!! ::: This fixes a bug when closing an Activity all views from all Activities are - //! disappearing! With this they reappear!!! - if (m_latteView && m_latteView->layout()) { - if (!isVisible()) { - QTimer::singleShot(100, [this]() { - if (!m_inDelete && m_latteView && m_latteView->layout() && !isVisible()) { - setVisible(true); - } - }); - - QTimer::singleShot(1500, [this]() { - if (!m_inDelete && m_latteView && m_latteView->layout() && !isVisible()) { - setVisible(true); - } - }); - } else { - //! For some reason when the window is hidden in the edge under X11 afterwards - //! is losing its window flags - if (!m_inDelete) { - KWindowSystem::setType(winId(), NET::Dock); - KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager); - KWindowSystem::setOnAllDesktops(winId(), true); - } - } + //! IMPORTANT!!! ::: This fixes a bug when closing an Activity all views from all Activities are + //! disappearing! With this code parts they reappear!!! + m_visibleHackTimer1.setInterval(400); + m_visibleHackTimer2.setInterval(2500); + m_visibleHackTimer1.setSingleShot(true); + m_visibleHackTimer2.setSingleShot(true); + + connectionsHack << connect(this, &QWindow::visibleChanged, this, [&]() { + if (!m_inDelete && m_latteView && m_latteView->layout() && !isVisible()) { + m_visibleHackTimer1.start(); + m_visibleHackTimer2.start(); + } else if (!m_inDelete) { + //! For some reason when the window is hidden in the edge under X11 afterwards + //! is losing its window flags + KWindowSystem::setType(winId(), NET::Dock); + KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager); + KWindowSystem::setOnAllDesktops(winId(), true); + } + }); + + connectionsHack << connect(&m_visibleHackTimer1, &QTimer::timeout, this, [&]() { + if (!m_inDelete && m_latteView && m_latteView->layout() && !isVisible()) { + setVisible(true); + //qDebug() << "Ghost Edge:: Enforce reshow from timer 1..."; + } else { + //qDebug() << "Ghost Edge:: No needed reshow from timer 1..."; + } + }); + + connectionsHack << connect(&m_visibleHackTimer2, &QTimer::timeout, this, [&]() { + if (!m_inDelete && m_latteView && m_latteView->layout() && !isVisible()) { + setVisible(true); + //qDebug() << "Ghost Edge:: Enforce reshow from timer 2..."; + } else { + //qDebug() << "Ghost Edge:: No needed reshow from timer 2..."; } }); } @@ -124,6 +134,13 @@ ScreenEdgeGhostWindow::~ScreenEdgeGhostWindow() m_inDelete = true; m_latteView = nullptr; + // clear mode + m_visibleHackTimer1.stop(); + m_visibleHackTimer2.stop(); + for (auto &c : connectionsHack) { + disconnect(c); + } + if (m_shellSurface) { delete m_shellSurface; } @@ -147,7 +164,12 @@ KWayland::Client::PlasmaShellSurface *ScreenEdgeGhostWindow::surface() void ScreenEdgeGhostWindow::updateGeometry() { QRect newGeometry; - int thickness{KWindowSystem::compositingActive() ? 4 : 2}; + int thickness; + if (KWindowSystem::compositingActive()) { + thickness == 4; + } else { + thickness == 2; + }; if (m_latteView->location() == Plasma::Types::BottomEdge) { newGeometry.setX(m_latteView->absoluteGeometry().left()); @@ -179,8 +201,8 @@ void ScreenEdgeGhostWindow::updateGeometry() void ScreenEdgeGhostWindow::fixGeometry() { if (!m_calculatedGeometry.isEmpty() - && (m_calculatedGeometry.x() != x() || m_calculatedGeometry.y() != y() - || m_calculatedGeometry.width() != width() || m_calculatedGeometry.height() != height())) { + && (m_calculatedGeometry.x() != x() || m_calculatedGeometry.y() != y() + || m_calculatedGeometry.width() != width() || m_calculatedGeometry.height() != height())) { setMinimumSize(m_calculatedGeometry.size()); setMaximumSize(m_calculatedGeometry.size()); resize(m_calculatedGeometry.size()); diff --git a/app/view/screenedgeghostwindow.h b/app/view/screenedgeghostwindow.h index 3516d05a6..b76b21d76 100644 --- a/app/view/screenedgeghostwindow.h +++ b/app/view/screenedgeghostwindow.h @@ -98,6 +98,14 @@ private: QTimer m_delayedMouseTimer; QTimer m_fixGeometryTimer; + //! 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; + //! Connections for the KWin visibility hack + QList connectionsHack; + Latte::View *m_latteView{nullptr}; KWayland::Client::PlasmaShellSurface *m_shellSurface{nullptr}; diff --git a/app/view/visibilitymanager.cpp b/app/view/visibilitymanager.cpp index fbf6049d1..7fd7f3a27 100644 --- a/app/view/visibilitymanager.cpp +++ b/app/view/visibilitymanager.cpp @@ -244,6 +244,7 @@ void VisibilityManager::updateStrutsBasedOnLayoutsAndActivities() && m_latteView->layout()->isCurrent()); if (m_corona->layoutsManager()->memoryUsage() == Types::SingleLayout || multipleLayoutsAndCurrent) { + qDebug() << "UPDATING struts for ::: " << m_latteView->layout()->name(); QRect computedStruts = acceptableStruts(); if (m_publishedStruts != computedStruts) { @@ -251,6 +252,11 @@ void VisibilityManager::updateStrutsBasedOnLayoutsAndActivities() m_wm->setViewStruts(*m_latteView, m_publishedStruts, m_latteView->location()); } } else { + if (m_latteView->layout()) { + qDebug() << "REMOVING struts for ::: " << m_latteView->layout()->name(); + } else { + qDebug() << "REMOVING struts from NULL layout..."; + } m_publishedStruts = QRect(); m_wm->removeViewStruts(*m_latteView); }