1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-23 01:33:50 +03:00

update PLASMAPANEL geometry immediate after hiding

--behaveAsPlasmaPanel can now slide in/out as real windows
but after they hide there is a chance that their geometry
should be updated. This patch makes sure that this will
happen exactly before the BEHAVEASPLASMAPANEL starts
sliding-in.
This commit is contained in:
Michail Vourlakos 2020-03-19 22:12:59 +02:00
parent 25677a01b5
commit 4ad3880579
3 changed files with 63 additions and 6 deletions

View File

@ -22,6 +22,7 @@
// local
#include "effects.h"
#include "view.h"
#include "visibilitymanager.h"
#include "../lattecorona.h"
#include "../screenpool.h"
#include "../settings/universalsettings.h"
@ -178,9 +179,21 @@ void Positioner::init()
connect(qGuiApp, &QGuiApplication::screenAdded, this, &Positioner::screenChanged);
connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &Positioner::screenChanged);
connect(m_view, &Latte::View::visibilityChanged, this, &Positioner::initDelayedSignals);
initSignalingForLocationChangeSliding();
}
void Positioner::initDelayedSignals()
{
connect(m_view->visibility(), &ViewPart::VisibilityManager::isHiddenChanged, this, [&]() {
if (m_view->behaveAsPlasmaPanel() && !m_view->visibility()->isHidden() && qAbs(m_slideOffset)>0) {
//! ignore any checks to make sure the panel geometry is up-to-date
immediateSyncGeometry();
}
});
}
void Positioner::updateWaylandId()
{
QString validTitle = m_view->validTitle();
@ -375,9 +388,16 @@ void Positioner::syncGeometry()
return;
}
qDebug() << "syncGeometry() called...";
immediateSyncGeometry();
}
void Positioner::immediateSyncGeometry()
{
bool found{false};
qDebug() << "syncGeometry() called...";
qDebug() << "immediateSyncGeometry() called...";
//! before updating the positioning and geometry of the dock
//! we make sure that the dock is at the correct screen
@ -573,6 +593,17 @@ void Positioner::updatePosition(QRect availableScreenRect)
int screenEdgeMargin = (m_view->behaveAsPlasmaPanel() && m_view->screenEdgeMarginEnabled()) ? m_view->screenEdgeMargin() : 0;
if (m_view->behaveAsPlasmaPanel()) {
//! Update screenEdgeMargin to take into account slide_offset that is used
//! in real window animations for BEHAVEASPLASMAPANELS views
if (m_view->location() == Plasma::Types::TopEdge || m_view->location() == Plasma::Types::LeftEdge) {
screenEdgeMargin = screenEdgeMargin + qAbs(m_slideOffset);
} else {
screenEdgeMargin = screenEdgeMargin - qAbs(m_slideOffset);
}
}
switch (m_view->location()) {
case Plasma::Types::TopEdge:
if (m_view->behaveAsPlasmaPanel()) {
@ -619,7 +650,19 @@ void Positioner::updatePosition(QRect availableScreenRect)
<< m_view->location();
}
m_validGeometry.setTopLeft(position);
if (m_slideOffset == 0) {
//! update valid geometry in normal positioning
m_validGeometry.setTopLeft(position);
} else {
//! when sliding in/out update only the relevant axis for the screen_edge in
//! to not mess the calculations and the automatic geometry checkers that
//! View::Positioner is using.
if (m_view->formFactor() == Plasma::Types::Horizontal) {
m_validGeometry.moveLeft(position.x());
} else {
m_validGeometry.moveTop(position.y());
}
}
m_view->setPosition(position);
@ -644,7 +687,7 @@ void Positioner::setSlideOffset(int offset)
QPoint slidedTopLeft;
if (m_view->location() == Plasma::Types::TopEdge) {
int boundedY = qMax(m_view->screenGeometry().top() - (m_validGeometry.height() - 1), m_validGeometry.y() - qAbs(m_slideOffset));
int boundedY = qMax(m_view->screenGeometry().top() - (m_validGeometry.height() + 1), m_validGeometry.y() - qAbs(m_slideOffset));
slidedTopLeft = {m_validGeometry.x(), boundedY};
} else if (m_view->location() == Plasma::Types::BottomEdge) {
@ -656,7 +699,7 @@ void Positioner::setSlideOffset(int offset)
slidedTopLeft = {boundedX, m_validGeometry.y()};
} else if (m_view->location() == Plasma::Types::LeftEdge) {
int boundedX = qMax(m_view->screenGeometry().left() - (m_validGeometry.width() - 1), m_validGeometry.x() - qAbs(m_slideOffset));
int boundedX = qMax(m_view->screenGeometry().left() - (m_validGeometry.width() + 1), m_validGeometry.x() - qAbs(m_slideOffset));
slidedTopLeft = {boundedX, m_validGeometry.y()};
}

View File

@ -94,6 +94,8 @@ public slots:
void syncGeometry();
void initDelayedSignals();
signals:
void currentScreenChanged();
void edgeChanged();
@ -128,6 +130,10 @@ private slots:
void syncLatteViews();
void updateContainmentScreen();
//! direct geometry calculations without any protections or checks
//! that might prevent them. It must be called with care.
void immediateSyncGeometry();
private:
void init();
void initSignalingForLocationChangeSliding();

View File

@ -59,8 +59,16 @@ Item{
property bool inTempHiding: false
property int length: root.isVertical ? Screen.height : Screen.width //screenGeometry.height : screenGeometry.width
property int slidingOutToPos: ((plasmoid.location===PlasmaCore.Types.LeftEdge)||(plasmoid.location===PlasmaCore.Types.TopEdge)) ?
-thicknessNormal : thicknessNormal;
property int slidingOutToPos: {
if (root.behaveAsPlasmaPanel) {
var edgeMargin = screenEdgeMarginEnabled ? plasmoid.configuration.screenEdgeMargin : 0
root.isHorizontal ? root.height + edgeMargin - 1 : root.width + edgeMargin - 1;
} else {
var topOrLeftEdge = ((plasmoid.location===PlasmaCore.Types.LeftEdge)||(plasmoid.location===PlasmaCore.Types.TopEdge));
return (topOrLeftEdge ? -thicknessNormal : thicknessNormal);
}
}
property int thicknessAutoHidden: Latte.WindowSystem.compositingActive ? 2 : 1
property int thicknessMid: root.screenEdgeMargin + (1 + (0.65 * (root.maxZoomFactor-1)))*(root.iconSize+root.thickMargins+extraThickMask) //needed in some animations