1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-03-09 16:58:16 +03:00

new Effects API for config windows subtract region

This commit is contained in:
Michail Vourlakos 2020-05-16 21:37:50 +03:00
parent 741eedfc3c
commit 6f3367225d
7 changed files with 115 additions and 9 deletions

View File

@ -249,7 +249,7 @@ void Effects::forceMaskRedraw()
void Effects::setSubtractedMaskRegion(const QString &regionid, const QRegion &region)
{
if (!m_subtractedMaskRegions.contains(regionid) || m_subtractedMaskRegions[regionid] != region) {
if (m_subtractedMaskRegions.contains(regionid) && m_subtractedMaskRegions[regionid] == region) {
return;
}
@ -269,7 +269,7 @@ void Effects::removeSubtractedMaskRegion(const QString &regionid)
void Effects::setUnitedMaskRegion(const QString &regionid, const QRegion &region)
{
if (!m_unitedMaskRegions.contains(regionid) || m_unitedMaskRegions[regionid] != region) {
if (m_unitedMaskRegions.contains(regionid) && m_unitedMaskRegions[regionid] == region) {
return;
}

View File

@ -357,9 +357,54 @@ void PrimaryConfigView::syncGeometry()
setMinimumSize(size);
resize(size);
updateViewMask();
emit m_latteView->configWindowGeometryChanged();
}
void PrimaryConfigView::updateViewMask()
{
bool environmentState = (KWindowSystem::isPlatformX11() && KWindowSystem::compositingActive());
if (!environmentState) {
return;
}
int x, y, thickness, length;
QRegion area;
thickness = m_latteView->effects()->editShadow();
if (m_latteView->formFactor() == Plasma::Types::Vertical) {
length = m_geometryWhenVisible.height();
} else {
length = m_geometryWhenVisible.width();
}
if (m_latteView->formFactor() == Plasma::Types::Horizontal) {
x = m_geometryWhenVisible.x() - m_latteView->x();
} else {
y = m_geometryWhenVisible.y() - m_latteView->y();
}
if (m_latteView->location() == Plasma::Types::BottomEdge) {
y = m_latteView->height() - m_latteView->editThickness() - m_latteView->effects()->editShadow();
} else if (m_latteView->location() == Plasma::Types::TopEdge) {
y = m_latteView->editThickness();
} else if (m_latteView->location() == Plasma::Types::LeftEdge) {
x = m_latteView->editThickness();
} else if (m_latteView->location() == Plasma::Types::RightEdge) {
x = m_latteView->width() - m_latteView->editThickness() - m_latteView->effects()->editShadow();
}
if (m_latteView->formFactor() == Plasma::Types::Horizontal) {
area = QRect(x, y, length, thickness);
} else {
area = QRect(x, y, thickness, length);
}
m_latteView->effects()->setSubtractedMaskRegion(validTitle(), area);
}
void PrimaryConfigView::syncSlideEffect()
{
if (!m_latteView || !m_latteView->containment()) {
@ -415,6 +460,7 @@ void PrimaryConfigView::showEvent(QShowEvent *ev)
QTimer::singleShot(400, this, &PrimaryConfigView::syncGeometry);
updateShowInlineProperties();
updateViewMask();
emit showSignal();
@ -439,6 +485,8 @@ void PrimaryConfigView::hideEvent(QHideEvent *ev)
m_latteView->containment()->setUserConfiguring(false);
}
m_latteView->effects()->removeSubtractedMaskRegion(validTitle());
const auto mode = m_latteView->visibility()->mode();
if ((mode == Types::AlwaysVisible || mode == Types::WindowsGoBelow)

View File

@ -140,6 +140,8 @@ private slots:
void setShowInlineProperties(bool show);
void updateViewMask();
void loadConfig();
void saveConfig();

View File

@ -191,10 +191,6 @@ void SecondaryConfigView::syncGeometry()
}
const QSize size(rootObject()->width(), rootObject()->height());
setMaximumSize(size);
setMinimumSize(size);
resize(size);
const auto location = m_latteView->containment()->location();
const auto scrGeometry = m_latteView->screenGeometry();
const auto availGeometry = m_parent->availableScreenGeometry();
@ -244,7 +240,13 @@ void SecondaryConfigView::syncGeometry()
updateEnabledBorders();
m_geometryWhenVisible = QRect(position.x(), position.y(), size.width(), size.height());
auto geometry = QRect(position.x(), position.y(), size.width(), size.height());
if (m_geometryWhenVisible == geometry) {
return;
}
m_geometryWhenVisible = geometry;
setPosition(position);
@ -252,6 +254,12 @@ void SecondaryConfigView::syncGeometry()
m_shellSurface->setPosition(position);
}
setMaximumSize(size);
setMinimumSize(size);
resize(size);
updateViewMask();
//! after placement request to activate the main config window in order to avoid
//! rare cases of closing settings window from secondaryConfigView->focusOutEvent
if (m_parent && KWindowSystem::isPlatformX11()) {
@ -259,6 +267,50 @@ void SecondaryConfigView::syncGeometry()
}
}
void SecondaryConfigView::updateViewMask()
{
bool environmentState = (KWindowSystem::isPlatformX11() && KWindowSystem::compositingActive());
if (!environmentState) {
return;
}
int x, y, thickness, length;
QRegion area;
thickness = m_latteView->effects()->editShadow();
if (m_latteView->formFactor() == Plasma::Types::Vertical) {
length = m_geometryWhenVisible.height();
} else {
length = m_geometryWhenVisible.width();
}
if (m_latteView->formFactor() == Plasma::Types::Horizontal) {
x = m_geometryWhenVisible.x() - m_latteView->x();
} else {
y = m_geometryWhenVisible.y() - m_latteView->y();
}
if (m_latteView->location() == Plasma::Types::BottomEdge) {
y = m_latteView->height() - m_latteView->editThickness() - m_latteView->effects()->editShadow();
} else if (m_latteView->location() == Plasma::Types::TopEdge) {
y = m_latteView->editThickness();
} else if (m_latteView->location() == Plasma::Types::LeftEdge) {
x = m_latteView->editThickness();
} else if (m_latteView->location() == Plasma::Types::RightEdge) {
x = m_latteView->width() - m_latteView->editThickness() - m_latteView->effects()->editShadow();
}
if (m_latteView->formFactor() == Plasma::Types::Horizontal) {
area = QRect(x, y, length, thickness);
} else {
area = QRect(x, y, thickness, length);
}
m_latteView->effects()->setSubtractedMaskRegion(validTitle(), area);
}
void SecondaryConfigView::syncSlideEffect()
{
if (!m_latteView || !m_latteView->containment()) {
@ -309,6 +361,7 @@ void SecondaryConfigView::showEvent(QShowEvent *ev)
m_screenSyncTimer.start();
QTimer::singleShot(400, this, &SecondaryConfigView::syncGeometry);
updateViewMask();
emit showSignal();
}
@ -392,6 +445,8 @@ bool SecondaryConfigView::event(QEvent *e)
void SecondaryConfigView::hideConfigWindow()
{
m_latteView->effects()->removeSubtractedMaskRegion(validTitle());
if (m_shellSurface) {
//!NOTE: Avoid crash in wayland environment with qt5.9
close();

View File

@ -101,6 +101,7 @@ protected:
private slots:
void updateEnabledBorders();
void updateWaylandId();
void updateViewMask();
private:
void setupWaylandIntegration();

View File

@ -697,7 +697,7 @@ FocusScope {
shadowOpacity: Math.max(0.35, maxOpacity)
shadowDirection: plasmoid.location
visible: !LatteCore.WindowSystem.isPlatformWayland && LatteCore.WindowSystem.compositingActive && latteView.effects.settingsMaskSubtracted
visible: !LatteCore.WindowSystem.isPlatformWayland && LatteCore.WindowSystem.compositingActive
readonly property real maxOpacity: LatteCore.WindowSystem.compositingActive && !plasmoid.configuration.inConfigureAppletsMode ?
plasmoid.configuration.editBackgroundOpacity : 1

View File

@ -84,7 +84,7 @@ FocusScope {
shadowOpacity: Math.max(0.35, maxOpacity)
shadowDirection: plasmoid.location
visible: !LatteCore.WindowSystem.isPlatformWayland && LatteCore.WindowSystem.compositingActive && latteView.effects.settingsMaskSubtracted
visible: !LatteCore.WindowSystem.isPlatformWayland && LatteCore.WindowSystem.compositingActive
readonly property real maxOpacity: LatteCore.WindowSystem.compositingActive && !plasmoid.configuration.inConfigureAppletsMode ?
plasmoid.configuration.editBackgroundOpacity : 1