From c240f7a012fee783cb932cc334b999c2defaa238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Sun, 21 Jun 2015 01:23:25 +0200 Subject: [PATCH] do the hide-is-move dance w/ desktopgrid buttons the (old) button effect windows used to be unreferenced with the re-invocation of the effect. because we stopped deleting/recreating the window, this approach failed and the effect window was never deleted. Unreferencing the window at proper occasion (see new hide location) coked up - guess what - the exact same "texture is junk" issue as for the QtQuick close button in present windows... So we resort to the exact same stupid "hide by moving" solution as we have there. BUG: 348577 FIXED-IN: 5.4 REVIEW: 124136 --- effects/desktopgrid/desktopgrid.cpp | 57 ++++++++++++++++++++--------- effects/desktopgrid/desktopgrid.h | 7 ++++ 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/effects/desktopgrid/desktopgrid.cpp b/effects/desktopgrid/desktopgrid.cpp index 759ecaf4ba..50b2cce7a1 100644 --- a/effects/desktopgrid/desktopgrid.cpp +++ b/effects/desktopgrid/desktopgrid.cpp @@ -278,8 +278,16 @@ void DesktopGridEffect::paintWindow(EffectWindow* w, int mask, QRegion region, W if (isUsingPresentWindows() && w == windowMove && wasWindowMove) { return; // will be painted on top of all other windows } - if (m_desktopButtonsViews.values().contains(w)) - return; // will be painted on top of all other windows + for (QHash< DesktopButtonsView*, EffectWindow*>::const_iterator it = m_desktopButtonsViews.constBegin(), + end = m_desktopButtonsViews.constEnd(); + it != end; ++it) { + if (it.value() == w) { + if (!activated && timeline.currentValue() < 0.05) { + it.key()->hide(); + } + return; // will be painted on top of all other windows + } + } qreal xScale = data.xScale(); qreal yScale = data.yScale(); @@ -416,13 +424,6 @@ void DesktopGridEffect::slotWindowClosed(EffectWindow* w) } } } - for (QHash< DesktopButtonsView*, EffectWindow*>::iterator it = m_desktopButtonsViews.begin(); - it != m_desktopButtonsViews.end(); ++it) { - if (it.value() && it.value() == w) { - w->refWindow(); - break; - } - } effects->addRepaintFull(); } @@ -433,8 +434,7 @@ void DesktopGridEffect::slotWindowDeleted(EffectWindow* w) for (QHash< DesktopButtonsView*, EffectWindow*>::iterator it = m_desktopButtonsViews.begin(); it != m_desktopButtonsViews.end(); ++it) { if (it.value() && it.value() == w) { - it.key()->deleteLater(); - m_desktopButtonsViews.erase(it); + it.value() = nullptr; break; } } @@ -1053,10 +1053,6 @@ void DesktopGridEffect::setActive(bool active) } } setHighlightedDesktop(effects->currentDesktop()); // Ensure selected desktop is highlighted - for (QHash< DesktopButtonsView*, EffectWindow*>::iterator it = m_desktopButtonsViews.begin(); - it != m_desktopButtonsViews.end(); ++it) { - it.key()->hide(); - } } effects->addRepaintFull(); } @@ -1134,14 +1130,12 @@ void DesktopGridEffect::setup() view->setAddDesktopEnabled(enableAdd); view->setRemoveDesktopEnabled(enableRemove); const QRect screenRect = effects->clientArea(FullScreenArea, i, 1); + view->show(); // pseudo show must happen before geometry changes view->setGeometry(screenRect.right() + 1 - view->width(), screenRect.bottom() + 1 - view->height(), view->width(), view->height()); - view->show(); } while (it != m_desktopButtonsViews.end()) { - if (*it && (*it)->isDeleted()) - (*it)->unrefWindow(); DesktopButtonsView *view = it.key(); it = m_desktopButtonsViews.erase(it); view->deleteLater(); @@ -1402,6 +1396,8 @@ bool DesktopGridEffect::isRelevantWithPresentWindows(EffectWindow *w) const ************************************************/ DesktopButtonsView::DesktopButtonsView(QWindow *parent) : QQuickView(parent) + , m_visible(false) + , m_posIsValid(false) { setFlags(Qt::X11BypassWindowManagerHint); setColor(Qt::transparent); @@ -1440,6 +1436,31 @@ void DesktopButtonsView::setRemoveDesktopEnabled(bool enable) rootContext()->setContextProperty(QStringLiteral("remove"), QVariant(enable)); } +bool DesktopButtonsView::isVisible() const +{ + return m_visible; +} + +void DesktopButtonsView::show() +{ + if (!m_visible && m_posIsValid) { + setPosition(m_pos); + m_posIsValid = false; + } + m_visible = true; + QQuickView::show(); +} + +void DesktopButtonsView::hide() +{ + if (!m_posIsValid) { + m_pos = position(); + m_posIsValid = true; + setPosition(-width(), -height()); + } + m_visible = false; +} + } // namespace #include "desktopgrid.moc" diff --git a/effects/desktopgrid/desktopgrid.h b/effects/desktopgrid/desktopgrid.h index 9c31b6729e..5a4e17437b 100644 --- a/effects/desktopgrid/desktopgrid.h +++ b/effects/desktopgrid/desktopgrid.h @@ -40,9 +40,16 @@ public: void windowInputMouseEvent(QMouseEvent* e); void setAddDesktopEnabled(bool enable); void setRemoveDesktopEnabled(bool enable); + bool isVisible() const; + void show(); + void hide(); Q_SIGNALS: void addDesktop(); void removeDesktop(); +private: + bool m_visible; + QPoint m_pos; + bool m_posIsValid; }; class DesktopGridEffect