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

provide stable struts thickness

--when a floating view is hiding its screen gap
there is no reason for struts to be added
during that phase. Published struts could be
the final expected window position in that case.

BUG:431255
This commit is contained in:
Michail Vourlakos 2021-01-07 15:02:16 +02:00
parent f8cce7acfa
commit 9d3ebca4af
3 changed files with 50 additions and 10 deletions

View File

@ -178,6 +178,22 @@ VisibilityManager::~VisibilityManager()
}
}
//! Struts
int VisibilityManager::strutsThickness() const
{
return m_strutsThickness;
}
void VisibilityManager::setStrutsThickness(int thickness)
{
if (m_strutsThickness == thickness) {
return;
}
m_strutsThickness = thickness;
emit strutsThicknessChanged();
}
Types::Visibility VisibilityManager::mode() const
{
return m_mode;
@ -254,7 +270,7 @@ void VisibilityManager::setMode(Latte::Types::Visibility mode)
updateStrutsBasedOnLayoutsAndActivities();
}
m_connections[base] = connect(m_latteView, &Latte::View::normalThicknessChanged, this, [&]() {
m_connections[base] = connect(this, &VisibilityManager::strutsThicknessChanged, this, [&]() {
updateStrutsBasedOnLayoutsAndActivities();
});
@ -392,29 +408,26 @@ QRect VisibilityManager::acceptableStruts()
{
QRect calcs;
int screenEdgeMargin = (m_latteView->behaveAsPlasmaPanel() && m_latteView->screenEdgeMarginEnabled()) ? m_latteView->screenEdgeMargin() : 0;
int shownThickness = m_latteView->normalThickness() + screenEdgeMargin;
switch (m_latteView->location()) {
case Plasma::Types::TopEdge: {
calcs = QRect(m_latteView->x(), m_latteView->screenGeometry().top(), m_latteView->width(), shownThickness);
calcs = QRect(m_latteView->x(), m_latteView->screenGeometry().top(), m_latteView->width(), m_strutsThickness);
break;
}
case Plasma::Types::BottomEdge: {
int y = m_latteView->screenGeometry().bottom() - shownThickness + 1 /* +1, is needed in order to not leave a gap at screen_edge*/;
calcs = QRect(m_latteView->x(), y, m_latteView->width(), shownThickness);
int y = m_latteView->screenGeometry().bottom() - m_strutsThickness + 1 /* +1, is needed in order to not leave a gap at screen_edge*/;
calcs = QRect(m_latteView->x(), y, m_latteView->width(), m_strutsThickness);
break;
}
case Plasma::Types::LeftEdge: {
calcs = QRect(m_latteView->screenGeometry().left(), m_latteView->y(), shownThickness, m_latteView->height());
calcs = QRect(m_latteView->screenGeometry().left(), m_latteView->y(), m_strutsThickness, m_latteView->height());
break;
}
case Plasma::Types::RightEdge: {
int x = m_latteView->screenGeometry().right() - shownThickness + 1 /* +1, is needed in order to not leave a gap at screen_edge*/;
calcs = QRect(x, m_latteView->y(), shownThickness, m_latteView->height());
int x = m_latteView->screenGeometry().right() - m_strutsThickness + 1 /* +1, is needed in order to not leave a gap at screen_edge*/;
calcs = QRect(x, m_latteView->y(), m_strutsThickness, m_latteView->height());
break;
}
}

View File

@ -69,6 +69,9 @@ class VisibilityManager : public QObject
Q_PROPERTY(int timerShow READ timerShow WRITE setTimerShow NOTIFY timerShowChanged)
Q_PROPERTY(int timerHide READ timerHide WRITE setTimerHide NOTIFY timerHideChanged)
//! Struts
Q_PROPERTY(int strutsThickness READ strutsThickness WRITE setStrutsThickness NOTIFY strutsThicknessChanged)
public:
static const QRect ISHIDDENMASK;
@ -109,6 +112,10 @@ public:
bool supportsKWinEdges() const;
//! Struts
int strutsThickness() const;
void setStrutsThickness(int thickness);
//! Used mostly to show / hide Sidebars
void toggleHiddenState();
@ -139,6 +146,7 @@ signals:
void isHiddenChanged();
void hidingIsBlockedChanged();
void containsMouseChanged();
void strutsThicknessChanged();
void timerShowChanged();
void timerHideChanged();
@ -221,6 +229,8 @@ private:
int m_timerHideInterval{700};
Plasma::Types::Location m_frameExtentsLocation{Plasma::Types::BottomEdge};
int m_strutsThickness{0};
QStringList m_blockHidingEvents;
QRect m_publishedStruts;

View File

@ -304,6 +304,23 @@ Item{
value: plasmoid.configuration.isStickedOnBottomEdge
}
//! View::VisibilityManager
Binding{
target: latteView && latteView.visibility ? latteView.visibility : null
property: "strutsThickness"
when: latteView && latteView.visibility
value: {
var isCapableToHideScreenGap = root.screenEdgeMarginEnabled && plasmoid.configuration.hideFloatingGapForMaximized
if (root.behaveAsPlasmaPanel) {
return isCapableToHideScreenGap ? thicknessAsPanel : metrics.mask.screenEdge + thicknessAsPanel;
}
var edgeThickness = isCapableToHideScreenGap ? 0 : metrics.mask.screenEdge;
return edgeThickness + metrics.mask.thickness.maxNormalForItemsWithoutScreenEdge;
}
}
//! View::WindowsTracker bindings
Binding{
target: latteView && latteView.windowsTracker ? latteView.windowsTracker : null