add backgroundHints for the panel view

Summary:
This patch adds a variable called "backgroundHints"
which can be used with (NoBackground) through qml
in order to enable/disable the KWin effects for
a specific panel and the panel shadows in case the
effects are disabled.
Currently these effects are (Blur and Background Contrast)

Reviewers: #plasma, #davidedmundson

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D3282

FEATURE: 368384
wilder-5.14
Michail Vourlakos 9 years ago
parent 658f205203
commit 341a534e9d
  1. 98
      shell/panelview.cpp
  2. 12
      shell/panelview.h

@ -62,6 +62,7 @@ PanelView::PanelView(ShellCorona *corona, QScreen *targetScreen, QWindow *parent
m_corona(corona),
m_visibilityMode(NormalPanel),
m_background(0),
m_backgroundHints(Plasma::Types::StandardBackground),
m_shellSurface(nullptr),
m_initCompleted(false)
{
@ -76,6 +77,7 @@ PanelView::PanelView(ShellCorona *corona, QScreen *targetScreen, QWindow *parent
setFlags(Qt::FramelessWindowHint|Qt::WindowDoesNotAcceptFocus);
connect(&m_theme, &Plasma::Theme::themeChanged, this, &PanelView::themeChanged);
connect(this, SIGNAL(backgroundHintsChanged()), this, SLOT(themeChanged()));
m_positionPaneltimer.setSingleShot(true);
m_positionPaneltimer.setInterval(150);
@ -290,6 +292,22 @@ void PanelView::setDistance(int dist)
positionPanel();
}
Plasma::Types::BackgroundHints PanelView::backgroundHints() const
{
return m_backgroundHints;
}
void PanelView::setBackgroundHints(Plasma::Types::BackgroundHints hint)
{
if (m_backgroundHints == hint) {
return;
}
m_backgroundHints = hint;
emit backgroundHintsChanged();
}
Plasma::FrameSvg::EnabledBorders PanelView::enabledBorders() const
{
return m_enabledBorders;
@ -1056,11 +1074,16 @@ void PanelView::updateStruts()
void PanelView::themeChanged()
{
KWindowEffects::enableBlurBehind(winId(), true);
KWindowEffects::enableBackgroundContrast(winId(), m_theme.backgroundContrastEnabled(),
m_theme.backgroundContrast(),
m_theme.backgroundIntensity(),
m_theme.backgroundSaturation());
if (m_backgroundHints == Plasma::Types::NoBackground) {
KWindowEffects::enableBlurBehind(winId(), false);
KWindowEffects::enableBackgroundContrast(winId(), false);
} else {
KWindowEffects::enableBlurBehind(winId(), true);
KWindowEffects::enableBackgroundContrast(winId(), m_theme.backgroundContrastEnabled(),
m_theme.backgroundContrast(),
m_theme.backgroundIntensity(),
m_theme.backgroundSaturation());
}
updateMask();
}
@ -1147,39 +1170,46 @@ 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 (m_backgroundHints == Plasma::Types::NoBackground) {
borders = Plasma::FrameSvg::NoBorder;
} else {
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() <= m_screenToFollow->geometry().x()) {
borders &= ~Plasma::FrameSvg::LeftBorder;
}
if (x() + width() >= m_screenToFollow->geometry().x() + m_screenToFollow->geometry().width()) {
borders &= ~Plasma::FrameSvg::RightBorder;
}
if (y() <= m_screenToFollow->geometry().y()) {
borders &= ~Plasma::FrameSvg::TopBorder;
}
if (y() + height() >= m_screenToFollow->geometry().y() + m_screenToFollow->geometry().height()) {
borders &= ~Plasma::FrameSvg::BottomBorder;
if (x() <= m_screenToFollow->geometry().x()) {
borders &= ~Plasma::FrameSvg::LeftBorder;
}
if (x() + width() >= m_screenToFollow->geometry().x() + m_screenToFollow->geometry().width()) {
borders &= ~Plasma::FrameSvg::RightBorder;
}
if (y() <= m_screenToFollow->geometry().y()) {
borders &= ~Plasma::FrameSvg::TopBorder;
}
if (y() + height() >= m_screenToFollow->geometry().y() + m_screenToFollow->geometry().height()) {
borders &= ~Plasma::FrameSvg::BottomBorder;
}
}
if (m_enabledBorders != borders) {
PanelShadows::self()->setEnabledBorders(this, borders);
if (m_backgroundHints == Plasma::Types::NoBackground) {
PanelShadows::self()->removeWindow(this);
} else {
PanelShadows::self()->setEnabledBorders(this, borders);
}
m_enabledBorders = borders;
emit enabledBordersChanged();

@ -77,6 +77,13 @@ class PanelView : public PlasmaQuick::ContainmentView
*/
Q_PROPERTY(int distance READ distance WRITE setDistance NOTIFY distanceChanged)
/**
* support NoBackground in order to disable blur/contrast effects and remove
* the panel shadows
* @since 5.9
*/
Q_PROPERTY(Plasma::Types::BackgroundHints backgroundHints WRITE setBackgroundHints READ backgroundHints NOTIFY backgroundHintsChanged)
/**
* The borders that should have a shadow
* @since 5.7
@ -131,6 +138,9 @@ public:
int distance() const;
void setDistance(int dist);
Plasma::Types::BackgroundHints backgroundHints() const;
void setBackgroundHints(Plasma::Types::BackgroundHints hint);
Plasma::FrameSvg::EnabledBorders enabledBorders() const;
VisibilityMode visibilityMode() const;
@ -168,6 +178,7 @@ Q_SIGNALS:
void maximumLengthChanged();
void minimumLengthChanged();
void distanceChanged();
void backgroundHintsChanged();
void enabledBordersChanged();
//QWindow does not have a property for screen. Adding this property requires re-implementing the signal
@ -220,6 +231,7 @@ private:
QTimer m_unhideTimer;
//only for the mask, not to actually paint
Plasma::FrameSvg *m_background;
Plasma::Types::BackgroundHints m_backgroundHints;
Plasma::FrameSvg::EnabledBorders m_enabledBorders = Plasma::FrameSvg::AllBorders;
KWayland::Client::PlasmaShellSurface *m_shellSurface;
QPointer<QScreen> m_lastScreen;

Loading…
Cancel
Save