diff --git a/shell/panelshadows.cpp b/shell/panelshadows.cpp --- a/shell/panelshadows.cpp +++ b/shell/panelshadows.cpp @@ -168,6 +168,16 @@ } } +void PanelShadows::setEnabledBorders(const QWindow *window, Plasma::FrameSvg::EnabledBorders enabledBorders) +{ + if (!window || !d->m_windows.contains(window)) { + return; + } + + d->updateShadow(window, enabledBorders); +} + + void PanelShadows::Private::windowDestroyed(QObject *deletedObject) { m_windows.remove(static_cast(deletedObject)); diff --git a/shell/panelshadows_p.h b/shell/panelshadows_p.h --- a/shell/panelshadows_p.h +++ b/shell/panelshadows_p.h @@ -38,6 +38,8 @@ void addWindow(const QWindow *window, Plasma::FrameSvg::EnabledBorders enabledBorders = Plasma::FrameSvg::AllBorders); void removeWindow(const QWindow *window); + void setEnabledBorders(const QWindow *window, Plasma::FrameSvg::EnabledBorders enabledBorders = Plasma::FrameSvg::AllBorders); + bool enabled() const; private: diff --git a/shell/panelview.h b/shell/panelview.h --- a/shell/panelview.h +++ b/shell/panelview.h @@ -78,6 +78,12 @@ Q_PROPERTY(int distance READ distance WRITE setDistance NOTIFY distanceChanged) /** + * The borders that should have a shadow + * @since 5.7 + */ + Q_PROPERTY(Plasma::FrameSvg::EnabledBorders enabledBorders READ enabledBorders NOTIFY enabledBordersChanged) + + /** * informations about the screen in which the panel is in */ Q_PROPERTY(QScreen *screen READ screen WRITE setScreen NOTIFY screenChangedProxy) @@ -125,6 +131,8 @@ int distance() const; void setDistance(int dist); + Plasma::FrameSvg::EnabledBorders enabledBorders() const; + VisibilityMode visibilityMode() const; void setVisibilityMode(PanelView::VisibilityMode mode); @@ -154,6 +162,7 @@ void maximumLengthChanged(); void minimumLengthChanged(); void distanceChanged(); + void enabledBordersChanged(); //QWindow does not have a property for screen. Adding this property requires re-implementing the signal void screenChangedProxy(QScreen *screen); @@ -184,6 +193,7 @@ QPointF positionAdjustedForContainment(const QPointF &point) const; void setupWaylandIntegration(); bool edgeActivated() const; + void updateEnabledBorders(); int m_offset; int m_maxLength; @@ -201,6 +211,7 @@ QTimer m_unhideTimer; //only for the mask, not to actually paint Plasma::FrameSvg *m_background; + Plasma::FrameSvg::EnabledBorders m_enabledBorders = Plasma::FrameSvg::AllBorders; KWayland::Client::PlasmaShellSurface *m_shellSurface; QWeakPointer m_lastScreen; diff --git a/shell/panelview.cpp b/shell/panelview.cpp --- a/shell/panelview.cpp +++ b/shell/panelview.cpp @@ -105,7 +105,6 @@ qmlRegisterType(); rootContext()->setContextProperty(QStringLiteral("panel"), this); setSource(QUrl::fromLocalFile(m_corona->kPackage().filePath("views", QStringLiteral("Panel.qml")))); - PanelShadows::self()->addWindow(this); } PanelView::~PanelView() @@ -293,6 +292,11 @@ positionPanel(); } +Plasma::FrameSvg::EnabledBorders PanelView::enabledBorders() const +{ + return m_enabledBorders; +} + void PanelView::setVisibilityMode(PanelView::VisibilityMode mode) { if (m_visibilityMode == mode) { @@ -359,6 +363,8 @@ } KWindowEffects::slideWindow(winId(), slideLocation, -1); + + updateEnabledBorders(); } QRect PanelView::geometryByDistance(int distance) const @@ -651,7 +657,7 @@ void PanelView::showEvent(QShowEvent *event) { - PanelShadows::self()->addWindow(this); + PanelShadows::self()->addWindow(this, enabledBorders()); PlasmaQuick::ContainmentView::showEvent(event); //When the screen is set, the screen is recreated internally, so we need to @@ -831,37 +837,7 @@ m_background->setImagePath(QStringLiteral("widgets/panel-background")); } - Plasma::FrameSvg::EnabledBorders borders = Plasma::FrameSvg::AllBorders; - switch (location()) { - case Plasma::Types::TopEdge: - borders &= ~Plasma::FrameSvg::TopBorder; - break; - case Plasma::Types::LeftEdge: - borders &= ~Plasma::FrameSvg::LeftBorder; - break; - case Plasma::Types::RightEdge: - borders &= ~Plasma::FrameSvg::RightBorder; - break; - case Plasma::Types::BottomEdge: - borders &= ~Plasma::FrameSvg::BottomBorder; - break; - default: - break; - } - - if (x() <= screen()->geometry().x()) { - borders &= ~Plasma::FrameSvg::LeftBorder; - } - if (x() + width() >= screen()->geometry().x() + screen()->geometry().width()) { - borders &= ~Plasma::FrameSvg::RightBorder; - } - if (y() <= screen()->geometry().y()) { - borders &= ~Plasma::FrameSvg::TopBorder; - } - if (y() + height() >= screen()->geometry().y() + screen()->geometry().height()) { - borders &= ~Plasma::FrameSvg::BottomBorder; - } - m_background->setEnabledBorders(borders); + m_background->setEnabledBorders(enabledBorders()); m_background->resizeFrame(size()); setMask(m_background->mask()); @@ -1071,5 +1047,48 @@ return m_visibilityMode == PanelView::AutoHide || m_visibilityMode == LetWindowsCover; } +void PanelView::updateEnabledBorders() +{ + Plasma::FrameSvg::EnabledBorders borders = Plasma::FrameSvg::AllBorders; + + switch (location()) { + case Plasma::Types::TopEdge: + borders &= ~Plasma::FrameSvg::TopBorder; + break; + case Plasma::Types::LeftEdge: + borders &= ~Plasma::FrameSvg::LeftBorder; + break; + case Plasma::Types::RightEdge: + borders &= ~Plasma::FrameSvg::RightBorder; + break; + case Plasma::Types::BottomEdge: + borders &= ~Plasma::FrameSvg::BottomBorder; + break; + default: + break; + } + + if (x() <= screen()->geometry().x()) { + borders &= ~Plasma::FrameSvg::LeftBorder; + } + if (x() + width() >= screen()->geometry().x() + screen()->geometry().width()) { + borders &= ~Plasma::FrameSvg::RightBorder; + } + if (y() <= screen()->geometry().y()) { + borders &= ~Plasma::FrameSvg::TopBorder; + } + if (y() + height() >= screen()->geometry().y() + screen()->geometry().height()) { + borders &= ~Plasma::FrameSvg::BottomBorder; + } + + if (m_enabledBorders != borders) { + + PanelShadows::self()->setEnabledBorders(this, borders); + + m_enabledBorders = borders; + emit enabledBordersChanged(); + } +} + #include "moc_panelview.cpp"