enhance background solidness when touching window

--When the user has chosen a solid background when
there are windows touching the Latte panel then in
such case windows that are touching the panel not
just at the edge but at the at any point of the latte
panel are also considered as touching windows
--The "snapped" term that was used before in the
visibilitymanager was changed to "touching"
pull/4/head
Michail Vourlakos 6 years ago
parent e6192a084c
commit ad3b5abeaf

@ -614,6 +614,8 @@ void VisibilityManager::checkAllWindows()
bool VisibilityManager::intersects(const WindowInfoWrap &winfo)
{
return (!winfo.isMinimized()
&& wm->isOnCurrentDesktop(winfo.wid())
&& wm->isOnCurrentActivity(winfo.wid())
&& winfo.geometry().intersects(m_viewGeometry)
&& !winfo.isShaded());
}
@ -819,7 +821,7 @@ void VisibilityManager::setEnabledDynamicBackground(bool active)
// ATTENTION: this was creating a crash under wayland environment through the blur effect
// setExistsWindowMaximized(false);
// setExistsWindowSnapped(false);
// setExistsWindowTouching(false);
}
emit enabledDynamicBackgroundChanged();
@ -841,20 +843,20 @@ void VisibilityManager::setExistsWindowMaximized(bool windowMaximized)
emit existsWindowMaximizedChanged();
}
bool VisibilityManager::existsWindowSnapped() const
bool VisibilityManager::existsWindowTouching() const
{
return windowIsSnappedFlag;
return windowIsTouchingFlag;
}
void VisibilityManager::setExistsWindowSnapped(bool windowSnapped)
void VisibilityManager::setExistsWindowTouching(bool windowTouching)
{
if (windowIsSnappedFlag == windowSnapped) {
if (windowIsTouchingFlag == windowTouching) {
return;
}
windowIsSnappedFlag = windowSnapped;
windowIsTouchingFlag = windowTouching;
emit existsWindowSnappedChanged();
emit existsWindowTouchingChanged();
}
SchemeColors *VisibilityManager::touchingWindowScheme() const
@ -885,59 +887,6 @@ void VisibilityManager::updateAvailableScreenGeometry()
if (tempAvailableScreenGeometry != availableScreenGeometry) {
availableScreenGeometry = tempAvailableScreenGeometry;
snappedWindowsGeometries.clear();
//! for top view the snapped geometries would be
int halfWidth1 = std::floor(availableScreenGeometry.width() / 2);
int halfWidth2 = availableScreenGeometry.width() - halfWidth1;
int halfHeight1 = std::floor((availableScreenGeometry.height()) / 2);
int halfHeight2 = availableScreenGeometry.height() - halfHeight1;
int x1 = availableScreenGeometry.x();
int x2 = availableScreenGeometry.x() + halfWidth1;
int y1 = availableScreenGeometry.y();
int y2 = availableScreenGeometry.y() + halfHeight1;
QRect snap1;
QRect snap2;
QRect snap3;
QRect snap4;
if (m_latteView->formFactor() == Plasma::Types::Horizontal) {
if (m_latteView->location() == Plasma::Types::TopEdge) {
snap1 = QRect(x1, y1, halfWidth1, halfHeight1);
snap3 = QRect(x2, y1, halfWidth2, halfHeight1);
} else if ((m_latteView->location() == Plasma::Types::BottomEdge)) {
snap1 = QRect(x1, y2, halfWidth1, halfHeight2);
snap3 = QRect(x2, y2, halfWidth2, halfHeight2);
}
snap2 = QRect(x1, y1, halfWidth1, availableScreenGeometry.height());
snap4 = QRect(x2, y1, halfWidth2, availableScreenGeometry.height());
} else if (m_latteView->formFactor() == Plasma::Types::Vertical) {
QRect snap5;
if (m_latteView->location() == Plasma::Types::LeftEdge) {
snap1 = QRect(x1, y1, halfWidth1, halfHeight1);
snap3 = QRect(x1, y2, halfWidth1, halfHeight2);
snap5 = QRect(x1, y1, halfWidth1, availableScreenGeometry.height());
} else if ((m_latteView->location() == Plasma::Types::RightEdge)) {
snap1 = QRect(x2, y1, halfWidth2, halfHeight1);
snap3 = QRect(x2, y2, halfWidth2, halfHeight2);
snap5 = QRect(x2, y1, halfWidth2, availableScreenGeometry.height());
}
snap2 = QRect(x1, y1, availableScreenGeometry.width(), halfHeight1);
snap4 = QRect(x1, y2, availableScreenGeometry.width(), halfHeight2);
snappedWindowsGeometries.append(snap5);
}
snappedWindowsGeometries.append(snap1);
snappedWindowsGeometries.append(snap2);
snappedWindowsGeometries.append(snap3);
snappedWindowsGeometries.append(snap4);
updateDynamicBackgroundWindowFlags();
}
}
@ -984,14 +933,14 @@ bool VisibilityManager::isTouchingPanelEdge(const WindowInfoWrap &winfo)
void VisibilityManager::updateDynamicBackgroundWindowFlags()
{
bool foundSnap{false};
bool foundTouch{false};
bool foundMaximized{false};
//! the notification window is not sending a remove signal and creates windows of geometry (0x0 0,0),
//! maybe a garbage collector here is a good idea!!!
bool existsFaultyWindow{false};
WindowId maxWinId;
WindowId snapWinId;
WindowId touchWinId;
for (const auto &winfo : windows) {
if (isMaximizedInCurrentScreen(winfo)) {
@ -999,9 +948,9 @@ void VisibilityManager::updateDynamicBackgroundWindowFlags()
maxWinId = winfo.wid();
}
if (winfo.isActive() && isTouchingPanelEdge(winfo)) {
foundSnap = true;
snapWinId = winfo.wid();
if (winfo.isActive() && (isTouchingPanelEdge(winfo) || (intersects(winfo)))) {
foundTouch = true;
touchWinId = winfo.wid();
}
if (!existsFaultyWindow && winfo.geometry() == QRect(0, 0, 0, 0)) {
@ -1011,38 +960,18 @@ void VisibilityManager::updateDynamicBackgroundWindowFlags()
//qDebug() << "window geometry ::: " << winfo.geometry();
}
//! active windows that are touching the panel edge should have a higher priority
//! this is why are identified first
if (!foundSnap) {
for (const auto &winfo : windows) {
if ((winfo.isKeepAbove() && isTouchingPanelEdge(winfo))
|| (!winfo.isActive() && snappedWindowsGeometries.contains(winfo.geometry()))) {
foundSnap = true;
snapWinId = winfo.wid();
break;
}
}
}
if (existsFaultyWindow) {
cleanupFaultyWindows();
}
/*if (!foundMaximized && !foundSnap) {
qDebug() << "SCREEN GEOMETRY : " << availableScreenGeometry;
qDebug() << "SNAPS ::: " << snappedWindowsGeometries;
}
qDebug() << " FOUND ::: " << foundMaximized << foundSnap;*/
setExistsWindowMaximized(foundMaximized);
setExistsWindowSnapped(foundSnap);
setExistsWindowTouching(foundTouch);
//! update color scheme for touching window
if (foundSnap) {
//! first the snap one because that would mean it is active
setTouchingWindowScheme(wm->schemeForWindow(snapWinId));
if (foundTouch) {
//! first the touching one because that would mean it is active
setTouchingWindowScheme(wm->schemeForWindow(touchWinId));
} else if (foundMaximized) {
setTouchingWindowScheme(wm->schemeForWindow(maxWinId));
} else {

@ -60,7 +60,7 @@ class VisibilityManager : public QObject
//! Dynamic Background Feature (needed options)
Q_PROPERTY(bool enabledDynamicBackground READ enabledDynamicBackground WRITE setEnabledDynamicBackground NOTIFY enabledDynamicBackgroundChanged)
Q_PROPERTY(bool existsWindowMaximized READ existsWindowMaximized NOTIFY existsWindowMaximizedChanged)
Q_PROPERTY(bool existsWindowSnapped READ existsWindowSnapped NOTIFY existsWindowSnappedChanged)
Q_PROPERTY(bool existsWindowTouching READ existsWindowTouching NOTIFY existsWindowTouchingChanged)
Q_PROPERTY(SchemeColors *touchingWindowScheme READ touchingWindowScheme NOTIFY touchingWindowSchemeChanged)
//! KWin Edges Support Options
@ -105,7 +105,7 @@ public:
void setEnabledDynamicBackground(bool active);
bool existsWindowMaximized() const;
bool existsWindowSnapped() const;
bool existsWindowTouching() const;
SchemeColors *touchingWindowScheme() const;
@ -137,7 +137,7 @@ signals:
//! Dynamic Background signals (from options)
void enabledDynamicBackgroundChanged();
void existsWindowMaximizedChanged();
void existsWindowSnappedChanged();
void existsWindowTouchingChanged();
//! KWin Edges Support signals
void enableKWinEdgesChanged();
@ -160,7 +160,7 @@ private:
//! Dynamic Background Feature
void setExistsWindowMaximized(bool windowMaximized);
void setExistsWindowSnapped(bool windowSnapped);
void setExistsWindowTouching(bool windowTouching);
void setTouchingWindowScheme(SchemeColors *scheme);
void updateAvailableScreenGeometry();
void updateDynamicBackgroundWindowFlags();
@ -207,10 +207,9 @@ private:
//! Dynamic Background flags and needed information
bool enabledDynamicBackgroundFlag{false};
bool windowIsSnappedFlag{false};
bool windowIsTouchingFlag{false};
bool windowIsMaximizedFlag{false};
QRect availableScreenGeometry;
QList<QRect> snappedWindowsGeometries;
std::array<QMetaObject::Connection, 7> connectionsDynBackground;
WindowId lastActiveWindowWid;
SchemeColors *touchingScheme{nullptr};

@ -44,7 +44,7 @@ Loader{
readonly property color minimizedDotColor: themeTextColorBrightness > 127.5 ? Qt.darker(theme.textColor, 1.7) : Qt.lighter(theme.textColor, 7)
property bool mustBeShown: active && (!root.forceSolidPanel || forceSolidnessAndColorize)
//! when forceSemiTransparentPanel is enabled because of snapped or maximized etc. windows
//! when forceSemiTransparentPanel is enabled because of touching or maximized etc. windows
//! then the colorizer could be enabled for low panel transparency levels (<40%)
&& (!userShowPanelBackground || !forceSemiTransparentPanel || (forceSemiTransparentPanel && root.panelTransparency<40))
&& !maximizedWindowTitleBarBehavesAsPanelBackground

@ -87,7 +87,7 @@ DragDrop.DropArea {
property bool disablePanelShadowMaximized: plasmoid.configuration.disablePanelShadowForMaximized && Latte.WindowSystem.compositingActive
property bool drawShadowsExternal: panelShadowsActive && behaveAsPlasmaPanel && !visibilityManager.inTempHiding
property bool editMode: editModeVisual.inEditMode
property bool windowIsTouching: latteView && latteView.visibility && (latteView.visibility.existsWindowMaximized || latteView.visibility.existsWindowSnapped || hasExpandedApplet)
property bool windowIsTouching: latteView && latteView.visibility && (latteView.visibility.existsWindowMaximized || latteView.visibility.existsWindowTouching || hasExpandedApplet)
property bool forceSemiTransparentPanel: Latte.WindowSystem.compositingActive && !root.editMode
&& ((!plasmoid.configuration.solidBackgroundForMaximized && plasmoid.configuration.backgroundOnlyOnMaximized && windowIsTouching)
@ -97,7 +97,7 @@ DragDrop.DropArea {
&& latteView && latteView.visibility
&& Latte.WindowSystem.compositingActive
&& !root.editMode
&& (latteView.visibility.existsWindowMaximized || latteView.visibility.existsWindowSnapped || hasExpandedApplet
&& (latteView.visibility.existsWindowMaximized || latteView.visibility.existsWindowTouching || hasExpandedApplet
|| showAppletsNumbers || showMetaBadge))
|| !Latte.WindowSystem.compositingActive
@ -105,7 +105,7 @@ DragDrop.DropArea {
&& latteView && latteView.visibility
&& Latte.WindowSystem.compositingActive
&& !root.editMode
&& !(latteView.visibility.existsWindowMaximized || latteView.visibility.existsWindowSnapped)
&& !(latteView.visibility.existsWindowMaximized || latteView.visibility.existsWindowTouching)
&& !(hasExpandedApplet && zoomFactor===1 && plasmoid.configuration.panelSize===100)
property bool forcePanelForBusyBackground: root.forceTransparentPanel && colorizerManager.mustBeShown && colorizerManager.backgroundIsBusy
@ -114,7 +114,7 @@ DragDrop.DropArea {
property bool forceColorizer: Latte.WindowSystem.compositingActive && plasmoid.configuration.colorizeTransparentPanels
property bool forceColorizeFromActiveWindowScheme: plasmoid.configuration.colorizeFromActiveWindowScheme && !editMode
&& (latteView && latteView.visibility && latteView.visibility.touchingWindowScheme
&& (latteView.visibility.existsWindowMaximized || latteView.visibility.existsWindowSnapped)
&& (latteView.visibility.existsWindowMaximized || latteView.visibility.existsWindowTouching)
&& !hasExpandedApplet)
property bool maximizedWindowTitleBarBehavesAsPanelBackground: latteView && latteView.visibility

Loading…
Cancel
Save