From 1e144fc3e742b1f8c0b7e71a7f5c843348d1315c Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 9 May 2020 12:26:33 +0300 Subject: [PATCH] solution for Unity style layouts top view shadow --when a vertical view that acts as a unity-style one is activated, it sends a signal to top view to update their visibility in order to stay on top --- app/lattecorona.h | 1 + app/view/positioner.cpp | 13 ------------- app/view/view.cpp | 34 ++++++++++++++++++++++++++++++++++ app/view/view.h | 4 ++++ 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/app/lattecorona.h b/app/lattecorona.h index b46d6ed77..460030220 100644 --- a/app/lattecorona.h +++ b/app/lattecorona.h @@ -177,6 +177,7 @@ signals: void raiseViewsTemporaryChanged(); void availableScreenRectChangedFrom(Latte::View *origin); void availableScreenRegionChangedFrom(Latte::View *origin); + void verticalUnityViewHasFocus(); private slots: void alternativesVisibilityChanged(bool visible); diff --git a/app/view/positioner.cpp b/app/view/positioner.cpp index 181854ed8..be00af735 100644 --- a/app/view/positioner.cpp +++ b/app/view/positioner.cpp @@ -526,19 +526,6 @@ QRect Positioner::maximumNormalGeometry() break; } - //! this is needed in order to preserve that the top dock will be above - //! the others in case flag bypasswindowmanagerhint hasn't be set, - //! such a case is the AlwaysVisible mode - //! NO IDEA what this is trying to solve... It must be updated and checked - //! if this IS STILL NEEDED - if (m_view->location() == Plasma::Types::TopEdge - && m_view->visibility()->mode() != Latte::Types::WindowsCanCover - && m_view->visibility()->mode() != Latte::Types::WindowsAlwaysCover) { - KWindowSystem::setState(m_view->winId(), NET::KeepAbove); - } else { - // KWindowSystem::clearState(m_view->winId(), NET::KeepAbove); - } - return maxGeometry; } diff --git a/app/view/view.cpp b/app/view/view.cpp index 4be662955..2ca5a4816 100644 --- a/app/view/view.cpp +++ b/app/view/view.cpp @@ -248,6 +248,7 @@ void View::init(Plasma::Containment *plasma_containment) connect(this, &View::availableScreenRectChangedFrom, m_corona, &Latte::Corona::availableScreenRectChangedFrom); connect(this, &View::availableScreenRegionChangedFrom, m_corona, &Latte::Corona::availableScreenRegionChangedFrom); connect(m_corona, &Latte::Corona::availableScreenRectChangedFrom, this, &View::availableScreenRectChangedFromSlot); + connect(m_corona, &Latte::Corona::verticalUnityViewHasFocus, this, &View::topViewAlwaysOnTop); connect(this, &View::byPassWMChanged, this, &View::saveConfig); connect(this, &View::isPreferredForShortcutsChanged, this, &View::saveConfig); @@ -269,6 +270,8 @@ void View::init(Plasma::Containment *plasma_containment) connect(m_contextMenu, &ViewPart::ContextMenu::menuChanged, this, &View::contextMenuIsShownChanged); + connect(m_interface, &ViewPart::ContainmentInterface::hasExpandedAppletChanged, this, &View::verticalUnityViewHasFocus); + //! View sends this signal in order to avoid crashes from ViewPart::Indicator when the view is recreated connect(m_corona->indicatorFactory(), &Latte::Indicator::Factory::indicatorChanged, this, [&](const QString &indicatorId) { emit indicatorPluginChanged(indicatorId); @@ -330,6 +333,7 @@ void View::disconnectSensitiveSignals() disconnect(this, &View::availableScreenRectChangedFrom, m_corona, &Latte::Corona::availableScreenRectChangedFrom); disconnect(this, &View::availableScreenRegionChangedFrom, m_corona, &Latte::Corona::availableScreenRegionChangedFrom); disconnect(m_corona, &Latte::Corona::availableScreenRectChangedFrom, this, &View::availableScreenRectChangedFromSlot); + disconnect(m_corona, &Latte::Corona::verticalUnityViewHasFocus, this, &View::topViewAlwaysOnTop); setLayout(nullptr); } @@ -1472,6 +1476,34 @@ bool View::isHighestPriorityView() { return false; } +//! BEGIN: WORKAROUND order to force top panels always on top and above left/right panels +void View::topViewAlwaysOnTop() +{ + if (!m_visibility) { + return; + } + + if (location() == Plasma::Types::TopEdge + && m_visibility->mode() != Latte::Types::WindowsCanCover + && m_visibility->mode() != Latte::Types::WindowsAlwaysCover) { + //! this is needed in order to preserve that the top dock will be above others. + //! Unity layout paradigm is a good example for this. The top panel shadow + //! should be always on top compared to left panel + m_visibility->setViewOnFrontLayer(); + } +} + +void View::verticalUnityViewHasFocus() +{ + if (formFactor() == Plasma::Types::Vertical + && (y() != screenGeometry().y()) + && ( (m_alignment == Latte::Types::Justify && m_maxLength == 1.0) + ||(m_alignment == Latte::Types::Top && m_offset == 0.0) )) { + emit m_corona->verticalUnityViewHasFocus(); + } +} +//! END: WORKAROUND + //!BEGIN overriding context menus behavior void View::mousePressEvent(QMouseEvent *event) { @@ -1481,6 +1513,8 @@ void View::mousePressEvent(QMouseEvent *event) PlasmaQuick::ContainmentView::mousePressEvent(event); updateTransientWindowsTracking(); } + + verticalUnityViewHasFocus(); } //!END overriding context menus behavior diff --git a/app/view/view.h b/app/view/view.h index d71e0259a..e0ce0d512 100644 --- a/app/view/view.h +++ b/app/view/view.h @@ -338,6 +338,10 @@ private slots: void addTransientWindow(QWindow *window); void removeTransientWindow(const bool &visible); + //! workaround in order for top panels to be always on top + void topViewAlwaysOnTop(); + void verticalUnityViewHasFocus(); + void restoreConfig(); void saveConfig();