mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-10 21:18:19 +03:00
add a dock geometry validator
-- under X11 it was identified that windows many times especially under screen changes dont end up at the correct position and size. This vailidator(timer) will enforce repositionings and resizes every 500ms if the window hasnt end up to correct values and until this is achieved.
This commit is contained in:
parent
fa2bc5bae9
commit
f287d37ac0
@ -121,6 +121,14 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool dockWindo
|
|||||||
m_screenSyncTimer.setInterval(2000);
|
m_screenSyncTimer.setInterval(2000);
|
||||||
connect(&m_screenSyncTimer, &QTimer::timeout, this, &DockView::reconsiderScreen);
|
connect(&m_screenSyncTimer, &QTimer::timeout, this, &DockView::reconsiderScreen);
|
||||||
|
|
||||||
|
//! under X11 it was identified that windows many times especially under screen changes
|
||||||
|
//! dont end up at the correct position and size. This timer will enforce repositionings
|
||||||
|
//! and resizes every 500ms if the window hasnt end up to correct values and until this
|
||||||
|
//! is achieved
|
||||||
|
m_validateGeometryTimer.setSingleShot(true);
|
||||||
|
m_validateGeometryTimer.setInterval(500);
|
||||||
|
connect(&m_validateGeometryTimer, &QTimer::timeout, this, &DockView::syncGeometry);
|
||||||
|
|
||||||
auto *dockCorona = qobject_cast<DockCorona *>(this->corona());
|
auto *dockCorona = qobject_cast<DockCorona *>(this->corona());
|
||||||
|
|
||||||
if (dockCorona) {
|
if (dockCorona) {
|
||||||
@ -180,13 +188,18 @@ void DockView::init()
|
|||||||
connect(qGuiApp, &QGuiApplication::screenAdded, this, &DockView::screenChanged);
|
connect(qGuiApp, &QGuiApplication::screenAdded, this, &DockView::screenChanged);
|
||||||
connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &DockView::screenChanged);
|
connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &DockView::screenChanged);
|
||||||
connect(this, &DockView::screenGeometryChanged, this, &DockView::syncGeometry);
|
connect(this, &DockView::screenGeometryChanged, this, &DockView::syncGeometry);
|
||||||
|
|
||||||
connect(this, &QQuickWindow::xChanged, this, &DockView::xChanged);
|
connect(this, &QQuickWindow::xChanged, this, &DockView::xChanged);
|
||||||
|
connect(this, &QQuickWindow::xChanged, this, &DockView::validateDockGeometry);
|
||||||
connect(this, &QQuickWindow::xChanged, this, &DockView::updateAbsDockGeometry);
|
connect(this, &QQuickWindow::xChanged, this, &DockView::updateAbsDockGeometry);
|
||||||
connect(this, &QQuickWindow::yChanged, this, &DockView::yChanged);
|
connect(this, &QQuickWindow::yChanged, this, &DockView::yChanged);
|
||||||
|
connect(this, &QQuickWindow::yChanged, this, &DockView::validateDockGeometry);
|
||||||
connect(this, &QQuickWindow::yChanged, this, &DockView::updateAbsDockGeometry);
|
connect(this, &QQuickWindow::yChanged, this, &DockView::updateAbsDockGeometry);
|
||||||
connect(this, &QQuickWindow::widthChanged, this, &DockView::widthChanged);
|
connect(this, &QQuickWindow::widthChanged, this, &DockView::widthChanged);
|
||||||
|
connect(this, &QQuickWindow::widthChanged, this, &DockView::validateDockGeometry);
|
||||||
connect(this, &QQuickWindow::widthChanged, this, &DockView::updateAbsDockGeometry);
|
connect(this, &QQuickWindow::widthChanged, this, &DockView::updateAbsDockGeometry);
|
||||||
connect(this, &QQuickWindow::heightChanged, this, &DockView::heightChanged);
|
connect(this, &QQuickWindow::heightChanged, this, &DockView::heightChanged);
|
||||||
|
connect(this, &QQuickWindow::heightChanged, this, &DockView::validateDockGeometry);
|
||||||
connect(this, &QQuickWindow::heightChanged, this, &DockView::updateAbsDockGeometry);
|
connect(this, &QQuickWindow::heightChanged, this, &DockView::updateAbsDockGeometry);
|
||||||
|
|
||||||
connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, &DockView::availableScreenRectChanged);
|
connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, &DockView::availableScreenRectChanged);
|
||||||
@ -447,6 +460,10 @@ void DockView::setScreenToFollow(QScreen *screen, bool updateScreenId)
|
|||||||
//! correct screen
|
//! correct screen
|
||||||
void DockView::reconsiderScreen()
|
void DockView::reconsiderScreen()
|
||||||
{
|
{
|
||||||
|
if (m_inDelete) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
qDebug() << " Delayer ";
|
qDebug() << " Delayer ";
|
||||||
|
|
||||||
foreach (auto scr, qGuiApp->screens()) {
|
foreach (auto scr, qGuiApp->screens()) {
|
||||||
@ -718,36 +735,40 @@ QRect DockView::maximumNormalGeometry()
|
|||||||
|
|
||||||
void DockView::resizeWindow(QRect availableScreenRect)
|
void DockView::resizeWindow(QRect availableScreenRect)
|
||||||
{
|
{
|
||||||
|
QSize screenSize = this->screen()->size();
|
||||||
|
QSize size = (formFactor() == Plasma::Types::Vertical) ? QSize(maxThickness(), availableScreenRect.height()) : QSize(screenSize.width(), maxThickness());
|
||||||
|
|
||||||
if (formFactor() == Plasma::Types::Vertical) {
|
if (formFactor() == Plasma::Types::Vertical) {
|
||||||
//qDebug() << "MAXIMUM RECT :: " << maximumRect << " - AVAILABLE RECT :: " << availableRect;
|
//qDebug() << "MAXIMUM RECT :: " << maximumRect << " - AVAILABLE RECT :: " << availableRect;
|
||||||
QSize size{maxThickness(), availableScreenRect.height()};
|
|
||||||
|
|
||||||
if (m_behaveAsPlasmaPanel) {
|
if (m_behaveAsPlasmaPanel) {
|
||||||
size.setWidth(normalThickness());
|
size.setWidth(normalThickness());
|
||||||
size.setHeight(static_cast<int>(maxLength() * availableScreenRect.height()));
|
size.setHeight(static_cast<int>(maxLength() * availableScreenRect.height()));
|
||||||
}
|
}
|
||||||
|
|
||||||
setMinimumSize(size);
|
|
||||||
setMaximumSize(size);
|
|
||||||
resize(size);
|
|
||||||
} else {
|
} else {
|
||||||
QSize screenSize = this->screen()->size();
|
|
||||||
QSize size{screenSize.width(), maxThickness()};
|
|
||||||
|
|
||||||
if (m_behaveAsPlasmaPanel) {
|
if (m_behaveAsPlasmaPanel) {
|
||||||
size.setWidth(static_cast<int>(maxLength() * screenSize.width()));
|
size.setWidth(static_cast<int>(maxLength() * screenSize.width()));
|
||||||
size.setHeight(normalThickness());
|
size.setHeight(normalThickness());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_validGeometry.setSize(size);
|
||||||
|
|
||||||
setMinimumSize(size);
|
setMinimumSize(size);
|
||||||
setMaximumSize(size);
|
setMaximumSize(size);
|
||||||
resize(size);
|
resize(size);
|
||||||
|
|
||||||
if (corona())
|
if (formFactor() == Plasma::Types::Horizontal && corona()) {
|
||||||
emit corona()->availableScreenRectChanged();
|
emit corona()->availableScreenRectChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DockView::validateDockGeometry()
|
||||||
|
{
|
||||||
|
if (geometry() != m_validGeometry) {
|
||||||
|
m_validateGeometryTimer.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QRect DockView::localGeometry() const
|
QRect DockView::localGeometry() const
|
||||||
{
|
{
|
||||||
return m_localGeometry;
|
return m_localGeometry;
|
||||||
@ -848,6 +869,8 @@ void DockView::updatePosition(QRect availableScreenRect)
|
|||||||
<< location();
|
<< location();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_validGeometry.setTopLeft(position);
|
||||||
|
|
||||||
setPosition(position);
|
setPosition(position);
|
||||||
|
|
||||||
if (m_shellSurface) {
|
if (m_shellSurface) {
|
||||||
@ -857,7 +880,7 @@ void DockView::updatePosition(QRect availableScreenRect)
|
|||||||
|
|
||||||
inline void DockView::syncGeometry()
|
inline void DockView::syncGeometry()
|
||||||
{
|
{
|
||||||
if (!(this->screen() && this->containment()))
|
if (!(this->screen() && this->containment()) || m_inDelete)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool found{false};
|
bool found{false};
|
||||||
|
@ -304,6 +304,7 @@ private slots:
|
|||||||
void statusChanged(Plasma::Types::ItemStatus);
|
void statusChanged(Plasma::Types::ItemStatus);
|
||||||
void screenChanged(QScreen *screen);
|
void screenChanged(QScreen *screen);
|
||||||
void updateEffects();
|
void updateEffects();
|
||||||
|
void validateDockGeometry();
|
||||||
|
|
||||||
void restoreConfig();
|
void restoreConfig();
|
||||||
void saveConfig();
|
void saveConfig();
|
||||||
@ -346,6 +347,9 @@ private:
|
|||||||
QRect m_localGeometry;
|
QRect m_localGeometry;
|
||||||
QRect m_absGeometry;
|
QRect m_absGeometry;
|
||||||
QRect m_maskArea;
|
QRect m_maskArea;
|
||||||
|
//! it is used in order to enforce X11 to never miss window geometry
|
||||||
|
QRect m_validGeometry;
|
||||||
|
|
||||||
Layout *m_managedLayout{nullptr};
|
Layout *m_managedLayout{nullptr};
|
||||||
QPointer<PlasmaQuick::ConfigView> m_configView;
|
QPointer<PlasmaQuick::ConfigView> m_configView;
|
||||||
|
|
||||||
@ -356,6 +360,7 @@ private:
|
|||||||
QString m_screenToFollowId;
|
QString m_screenToFollowId;
|
||||||
|
|
||||||
QTimer m_screenSyncTimer;
|
QTimer m_screenSyncTimer;
|
||||||
|
QTimer m_validateGeometryTimer;
|
||||||
|
|
||||||
//! Connections to release and bound for the managed layout
|
//! Connections to release and bound for the managed layout
|
||||||
std::array<QMetaObject::Connection, 4> connectionsManagedLayout;
|
std::array<QMetaObject::Connection, 4> connectionsManagedLayout;
|
||||||
|
Loading…
Reference in New Issue
Block a user