1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-24 18:03:53 +03:00

Dodge visibility mode now ignores edge touches

--The new implementation for snapping needed to remove
the touching view edge from touching algorithm. The
windows trakers now provide two separate values for each
touching.
----First value is for regular window touches for which
their window geometry intersects with view published
absoluteGeometry
----Second value is for windows that are touching
view edge without intersecting with view geometry
This commit is contained in:
Michail Vourlakos 2020-05-17 11:42:09 +03:00
parent b4de1e3cad
commit b264854a98
8 changed files with 145 additions and 7 deletions

View File

@ -72,6 +72,12 @@ void CurrentScreenTracker::init()
}
});
connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::activeWindowTouchingEdgeChanged, this, [&](const Latte::View *view) {
if (m_latteView == view) {
emit activeWindowTouchingEdgeChanged();
}
});
connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::existsWindowActiveChanged, this, [&](const Latte::View *view) {
if (m_latteView == view) {
emit existsWindowActiveChanged();
@ -90,6 +96,12 @@ void CurrentScreenTracker::init()
}
});
connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::existsWindowTouchingEdgeChanged, this, [&](const Latte::View *view) {
if (m_latteView == view) {
emit existsWindowTouchingEdgeChanged();
}
});
connect(m_wm->windowsTracker(), &WindowSystem::Tracker::Windows::isTouchingBusyVerticalViewChanged, this, [&](const Latte::View *view) {
if (m_latteView == view) {
emit isTouchingBusyVerticalViewChanged();
@ -114,9 +126,11 @@ void CurrentScreenTracker::initSignalsForInformation()
emit lastActiveWindowChanged();
emit activeWindowMaximizedChanged();
emit activeWindowTouchingChanged();
emit activeWindowTouchingEdgeChanged();
emit existsWindowActiveChanged();
emit existsWindowMaximizedChanged();
emit existsWindowTouchingChanged();
emit existsWindowTouchingEdgeChanged();
emit activeWindowSchemeChanged();
emit touchingWindowSchemeChanged();
}
@ -131,6 +145,11 @@ bool CurrentScreenTracker::activeWindowTouching() const
return m_wm->windowsTracker()->activeWindowTouching(m_latteView);
}
bool CurrentScreenTracker::activeWindowTouchingEdge() const
{
return m_wm->windowsTracker()->activeWindowTouchingEdge(m_latteView);
}
bool CurrentScreenTracker::existsWindowActive() const
{
return m_wm->windowsTracker()->existsWindowActive(m_latteView);
@ -146,6 +165,11 @@ bool CurrentScreenTracker::existsWindowTouching() const
return m_wm->windowsTracker()->existsWindowTouching(m_latteView);
}
bool CurrentScreenTracker::existsWindowTouchingEdge() const
{
return m_wm->windowsTracker()->existsWindowTouchingEdge(m_latteView);
}
bool CurrentScreenTracker::isTouchingBusyVerticalView() const
{
return m_wm->windowsTracker()->isTouchingBusyVerticalView(m_latteView);

View File

@ -50,9 +50,11 @@ class CurrentScreenTracker : public QObject {
Q_OBJECT
Q_PROPERTY(bool activeWindowMaximized READ activeWindowMaximized NOTIFY activeWindowMaximizedChanged)
Q_PROPERTY(bool activeWindowTouching READ activeWindowTouching NOTIFY activeWindowTouchingChanged)
Q_PROPERTY(bool activeWindowTouchingEdge READ activeWindowTouchingEdge NOTIFY activeWindowTouchingEdgeChanged)
Q_PROPERTY(bool existsWindowActive READ existsWindowActive NOTIFY existsWindowActiveChanged)
Q_PROPERTY(bool existsWindowMaximized READ existsWindowMaximized NOTIFY existsWindowMaximizedChanged)
Q_PROPERTY(bool existsWindowTouching READ existsWindowTouching NOTIFY existsWindowTouchingChanged)
Q_PROPERTY(bool existsWindowTouchingEdge READ existsWindowTouchingEdge NOTIFY existsWindowTouchingEdgeChanged)
Q_PROPERTY(bool isTouchingBusyVerticalView READ isTouchingBusyVerticalView NOTIFY isTouchingBusyVerticalViewChanged)
Q_PROPERTY(Latte::WindowSystem::SchemeColors *activeWindowScheme READ activeWindowScheme NOTIFY activeWindowSchemeChanged)
Q_PROPERTY(Latte::WindowSystem::SchemeColors *touchingWindowScheme READ touchingWindowScheme NOTIFY touchingWindowSchemeChanged)
@ -65,9 +67,11 @@ public:
bool activeWindowMaximized() const;
bool activeWindowTouching() const;
bool activeWindowTouchingEdge() const;
bool existsWindowActive() const;
bool existsWindowMaximized() const;
bool existsWindowTouching() const;
bool existsWindowTouchingEdge() const;
bool isTouchingBusyVerticalView() const;
@ -82,9 +86,11 @@ public slots:
signals:
void activeWindowMaximizedChanged();
void activeWindowTouchingChanged();
void activeWindowTouchingEdgeChanged();
void existsWindowActiveChanged();
void existsWindowMaximizedChanged();
void existsWindowTouchingChanged();
void existsWindowTouchingEdgeChanged();
void isTouchingBusyVerticalViewChanged();
void activeWindowSchemeChanged();

View File

@ -74,6 +74,34 @@ void TrackedViewInfo::setExistsWindowTouching(bool touching)
m_existsWindowTouching = touching;
}
bool TrackedViewInfo::activeWindowTouchingEdge() const
{
return m_activeWindowTouchingEdge;
}
void TrackedViewInfo::setActiveWindowTouchingEdge(bool touching)
{
if (m_activeWindowTouchingEdge == touching) {
return;
}
m_activeWindowTouchingEdge = touching;
}
bool TrackedViewInfo::existsWindowTouchingEdge() const
{
return m_existsWindowTouchingEdge;
}
void TrackedViewInfo::setExistsWindowTouchingEdge(bool touching)
{
if (m_existsWindowTouchingEdge == touching) {
return;
}
m_existsWindowTouchingEdge = touching;
}
bool TrackedViewInfo::isTouchingBusyVerticalView() const
{
return m_isTouchingBusyVerticalView;

View File

@ -56,6 +56,12 @@ public:
bool existsWindowTouching() const;
void setExistsWindowTouching(bool touching);
bool activeWindowTouchingEdge() const;
void setActiveWindowTouchingEdge(bool touching);
bool existsWindowTouchingEdge() const;
void setExistsWindowTouchingEdge(bool touching);
bool isTouchingBusyVerticalView() const;
void setIsTouchingBusyVerticalView(bool touching);
@ -72,6 +78,8 @@ public:
private:
bool m_activeWindowTouching{false};
bool m_existsWindowTouching{false};
bool m_activeWindowTouchingEdge{false};
bool m_existsWindowTouchingEdge{false};
bool m_isTouchingBusyVerticalView{false};
QRect m_availableScreenGeometry;

View File

@ -155,8 +155,10 @@ void Windows::initViewHints(Latte::View *view)
setActiveWindowMaximized(view, false);
setActiveWindowTouching(view, false);
setActiveWindowTouchingEdge(view, false);
setExistsWindowActive(view, false);
setExistsWindowTouching(view, false);
setExistsWindowTouchingEdge(view, false);
setExistsWindowMaximized(view, false);
setIsTouchingBusyVerticalView(view, false);
setActiveWindowScheme(view, nullptr);
@ -342,6 +344,25 @@ void Windows::setActiveWindowTouching(Latte::View *view, bool activeTouching)
emit activeWindowTouchingChanged(view);
}
bool Windows::activeWindowTouchingEdge(Latte::View *view) const
{
if (!m_views.contains(view)) {
return false;
}
return m_views[view]->activeWindowTouchingEdge();
}
void Windows::setActiveWindowTouchingEdge(Latte::View *view, bool activeTouchingEdge)
{
if (!m_views.contains(view) || m_views[view]->activeWindowTouchingEdge() == activeTouchingEdge) {
return;
}
m_views[view]->setActiveWindowTouchingEdge(activeTouchingEdge);
emit activeWindowTouchingEdgeChanged(view);
}
bool Windows::existsWindowActive(Latte::View *view) const
{
if (!m_views.contains(view)) {
@ -399,6 +420,26 @@ void Windows::setExistsWindowTouching(Latte::View *view, bool windowTouching)
emit existsWindowTouchingChanged(view);
}
bool Windows::existsWindowTouchingEdge(Latte::View *view) const
{
if (!m_views.contains(view)) {
return false;
}
return m_views[view]->existsWindowTouchingEdge();
}
void Windows::setExistsWindowTouchingEdge(Latte::View *view, bool windowTouchingEdge)
{
if (!m_views.contains(view) || m_views[view]->existsWindowTouchingEdge() == windowTouchingEdge) {
return;
}
m_views[view]->setExistsWindowTouchingEdge(windowTouchingEdge);
emit existsWindowTouchingEdgeChanged(view);
}
bool Windows::isTouchingBusyVerticalView(Latte::View *view) const
{
if (!m_views.contains(view)) {
@ -823,7 +864,9 @@ void Windows::updateHints(Latte::View *view)
bool foundActive{false};
bool foundActiveInCurScreen{false};
bool foundActiveTouchInCurScreen{false};
bool foundActiveEdgeTouchInCurScreen{false};
bool foundTouchInCurScreen{false};
bool foundTouchEdgeInCurScreen{false};
bool foundMaximizedInCurScreen{false};
bool foundActiveGroupTouchInCurScreen{false};
@ -835,7 +878,9 @@ void Windows::updateHints(Latte::View *view)
WindowId maxWinId;
WindowId activeWinId;
WindowId touchWinId;
WindowId touchEdgeWinId;
WindowId activeTouchWinId;
WindowId activeTouchEdgeWinId;
//qDebug() << " -- TRACKING REPORT (SCREEN)--";
@ -875,7 +920,7 @@ void Windows::updateHints(Latte::View *view)
bool touchingViewEdge = isTouchingViewEdge(view, winfo);
bool touchingView = isTouchingView(view, winfo);
if (touchingViewEdge || touchingView) {
if (touchingView) {
if (winfo.isActive()) {
foundActiveTouchInCurScreen = true;
activeTouchWinId = winfo.wid();
@ -885,6 +930,16 @@ void Windows::updateHints(Latte::View *view)
}
}
if (touchingViewEdge) {
if (winfo.isActive()) {
foundActiveEdgeTouchInCurScreen = true;
activeTouchEdgeWinId = winfo.wid();
} else {
foundTouchEdgeInCurScreen = true;
touchEdgeWinId = winfo.wid();
}
}
//qDebug() << "TRACKING | ACTIVE:"<< foundActive << " ACT_CUR_SCR:" << foundTouchInCurScreen << " MAXIM:"<<foundMaximizedInCurScreen;
//qDebug() << "TRACKING | TOUCHING VIEW EDGE:"<< touchingViewEdge << " TOUCHING VIEW:" << foundTouchInCurScreen;
}
@ -921,7 +976,7 @@ void Windows::updateHints(Latte::View *view)
continue;
}
if (isTouchingViewEdge(view, winfo) || isTouchingView(view, winfo)) {
if (isTouchingView(view, winfo)) {
foundActiveGroupTouchInCurScreen = true;
break;
}
@ -942,19 +997,25 @@ void Windows::updateHints(Latte::View *view)
//! assign flags
setExistsWindowActive(view, foundActiveInCurScreen);
setActiveWindowTouching(view, foundActiveTouchInCurScreen || foundActiveGroupTouchInCurScreen);
setActiveWindowTouchingEdge(view, foundActiveEdgeTouchInCurScreen);
setActiveWindowMaximized(view, (maxWinId.toInt()>0 && (maxWinId == activeTouchWinId)));
setExistsWindowMaximized(view, foundMaximizedInCurScreen);
setExistsWindowTouching(view, (foundTouchInCurScreen || foundActiveTouchInCurScreen || foundActiveGroupTouchInCurScreen));
setExistsWindowTouchingEdge(view, (foundActiveEdgeTouchInCurScreen || foundTouchEdgeInCurScreen));
//! update color schemes for active and touching windows
setActiveWindowScheme(view, (foundActiveInCurScreen ? m_wm->schemesTracker()->schemeForWindow(activeWinId) : nullptr));
if (foundActiveTouchInCurScreen) {
setTouchingWindowScheme(view, m_wm->schemesTracker()->schemeForWindow(activeTouchWinId));
} else if (foundActiveEdgeTouchInCurScreen) {
setTouchingWindowScheme(view, m_wm->schemesTracker()->schemeForWindow(activeTouchEdgeWinId));
} else if (foundMaximizedInCurScreen) {
setTouchingWindowScheme(view, m_wm->schemesTracker()->schemeForWindow(maxWinId));
} else if (foundTouchInCurScreen) {
setTouchingWindowScheme(view, m_wm->schemesTracker()->schemeForWindow(touchWinId));
} else if (foundTouchEdgeInCurScreen) {
setTouchingWindowScheme(view, m_wm->schemesTracker()->schemeForWindow(touchEdgeWinId));
} else {
setTouchingWindowScheme(view, nullptr);
}
@ -970,6 +1031,7 @@ void Windows::updateHints(Latte::View *view)
//qDebug() << "TRACKING | activeWindowTouching: " << foundActiveTouchInCurScreen << " ,activeWindowMaximized: " << activeWindowMaximized(view);
//qDebug() << "TRACKING | existsWindowActive: " << foundActiveInCurScreen << " , existsWindowMaximized:" << existsWindowMaximized(view)
// << " , existsWindowTouching:"<<existsWindowTouching(view);
//qDebug() << "TRACKING | activeEdgeWindowTouch: " << activeWindowTouchingEdge(view) << " , existsEdgeWindowTouch:" << existsWindowTouchingEdge(view);
//qDebug() << "TRACKING | existsActiveGroupTouching: " << foundActiveGroupTouchInCurScreen;
}

View File

@ -68,9 +68,11 @@ public:
bool activeWindowMaximized(Latte::View *view) const;
bool activeWindowTouching(Latte::View *view) const;
bool activeWindowTouchingEdge(Latte::View *view) const;
bool existsWindowActive(Latte::View *view) const;
bool existsWindowMaximized(Latte::View *view) const;
bool existsWindowTouching(Latte::View *view) const;
bool existsWindowTouchingEdge(Latte::View *view) const;
bool isTouchingBusyVerticalView(Latte::View *view) const;
SchemeColors *activeWindowScheme(Latte::View *view) const;
SchemeColors *touchingWindowScheme(Latte::View *view) const;
@ -97,9 +99,11 @@ signals:
void enabledChanged(const Latte::View *view);
void activeWindowMaximizedChanged(const Latte::View *view);
void activeWindowTouchingChanged(const Latte::View *view);
void activeWindowTouchingEdgeChanged(const Latte::View *view);
void existsWindowActiveChanged(const Latte::View *view);
void existsWindowMaximizedChanged(const Latte::View *view);
void existsWindowTouchingChanged(const Latte::View *view);
void existsWindowTouchingEdgeChanged(const Latte::View *view);
void isTouchingBusyVerticalViewChanged(const Latte::View *view);
void activeWindowSchemeChanged(const Latte::View *view);
void touchingWindowSchemeChanged(const Latte::View *view);
@ -144,9 +148,11 @@ private:
void setActiveWindowMaximized(Latte::View *view, bool activeMaximized);
void setActiveWindowTouching(Latte::View *view, bool activeTouching);
void setActiveWindowTouchingEdge(Latte::View *view, bool activeTouchingEdge);
void setExistsWindowActive(Latte::View *view, bool windowActive);
void setExistsWindowMaximized(Latte::View *view, bool windowMaximized);
void setExistsWindowTouching(Latte::View *view, bool windowTouching);
void setExistsWindowTouchingEdge(Latte::View *view, bool windowTouchingEdge);
void setIsTouchingBusyVerticalView(Latte::View *view, bool viewTouching);
void setActiveWindowScheme(Latte::View *view, WindowSystem::SchemeColors *scheme);
void setTouchingWindowScheme(Latte::View *view, WindowSystem::SchemeColors *scheme);

View File

@ -85,8 +85,8 @@ Loader{
if (root.windowColors === LatteContainment.Types.TouchingWindowColors && latteView.windowsTracker.currentScreen.touchingWindowScheme) {
//! we must track touching windows and when they are not ative
//! the active window scheme is used for convenience
if (latteView.windowsTracker.currentScreen.existsWindowTouching
&& !latteView.windowsTracker.currentScreen.activeWindowTouching
if (latteView.windowsTracker.currentScreen.existsWindowTouching || latteView.windowsTracker.currentScreen.existsWindowTouchingEdge
&& !(latteView.windowsTracker.currentScreen.activeWindowTouching || latteView.windowsTracker.currentScreen.activeWindowTouchingEdge)
&& latteView.windowsTracker.currentScreen.activeWindowScheme) {
return latteView.windowsTracker.currentScreen.activeWindowScheme;
}

View File

@ -145,7 +145,9 @@ Item {
property bool editMode: editModeVisual.inEditMode
property bool windowIsTouching: latteView && latteView.windowsTracker
&& (latteView.windowsTracker.currentScreen.activeWindowTouching || hasExpandedApplet)
&& (latteView.windowsTracker.currentScreen.activeWindowTouching
|| latteView.windowsTracker.currentScreen.activeWindowTouchingEdge
|| hasExpandedApplet)
property bool forceSolidPanel: (latteView && latteView.visibility
&& LatteCore.WindowSystem.compositingActive
@ -153,7 +155,8 @@ Item {
&& userShowPanelBackground
&& ( (plasmoid.configuration.solidBackgroundForMaximized
&& !(hasExpandedApplet && !plasmaBackgroundForPopups)
&& latteView.windowsTracker.currentScreen.existsWindowTouching)
&& (latteView.windowsTracker.currentScreen.existsWindowTouching
|| latteView.windowsTracker.currentScreen.existsWindowTouchingEdge))
|| (hasExpandedApplet && plasmaBackgroundForPopups) ))
|| solidBusyForTouchingBusyVerticalView
|| plasmaStyleBusyForTouchingBusyVerticalView
@ -164,7 +167,8 @@ Item {
&& LatteCore.WindowSystem.compositingActive
&& !inConfigureAppletsMode
&& !forceSolidPanel
&& !latteView.windowsTracker.currentScreen.existsWindowTouching
&& !(latteView.windowsTracker.currentScreen.existsWindowTouching
|| latteView.windowsTracker.currentScreen.existsWindowTouchingEdge)
&& !(windowColors === LatteContainment.Types.ActiveWindowColors && selectedWindowsTracker.existsWindowActive)
property bool forcePanelForBusyBackground: userShowPanelBackground && (root.themeColors === LatteContainment.Types.SmartThemeColors)