From e93fa6b2c6c5a4be054d2f04ce17392c6f42e924 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 12 Feb 2017 01:59:09 +0200 Subject: [PATCH] fix #116,add protections in multi-screen --- app/dockcorona.cpp | 15 ++++++++------- app/dockview.cpp | 15 +++++++++++---- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/app/dockcorona.cpp b/app/dockcorona.cpp index 1ef957034..e05f1ad4c 100644 --- a/app/dockcorona.cpp +++ b/app/dockcorona.cpp @@ -203,17 +203,18 @@ QRect DockCorona::availableScreenRect(int id) const if (view && view->containment() && view->screen() == screen) { auto dockRect = view->absGeometry(); - // Usually availableScreenRect is used by the desktop, - // but Latte dont have desktop, then here just - // need calculate available space for top and bottom location, - // because the left and right are those who dodge others docks + // Usually availableScreenRect is used by the desktop, + // but Latte dont have desktop, then here just + // need calculate available space for top and bottom location, + // because the left and right are those who dodge others docks switch (view->location()) { case Plasma::Types::TopEdge: available.setTopLeft({available.x(), dockRect.bottom()}); - break; + break; + case Plasma::Types::BottomEdge: available.setBottomLeft({available.x(), dockRect.top()}); - break; + break; } } } @@ -302,7 +303,7 @@ QList DockCorona::freeEdges(int screen) const int DockCorona::screenForContainment(const Plasma::Containment *containment) const { for (auto *view : m_dockViews) { - if (view && view->containment() && view->containment()->id() == containment->id()) + if (view && view->containment() && view->containment() == containment) if (view->screen()) return qGuiApp->screens().indexOf(view->screen()); } diff --git a/app/dockview.cpp b/app/dockview.cpp index e374548ea..3e7b6f3b4 100644 --- a/app/dockview.cpp +++ b/app/dockview.cpp @@ -113,7 +113,7 @@ void DockView::init() connect(this, &DockView::screenGeometryChanged, this, &DockView::syncGeometry); connect(this, &QQuickWindow::widthChanged, this, &DockView::widthChanged); connect(this, &QQuickWindow::heightChanged, this, &DockView::heightChanged); - connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, [&](){ + connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, [&]() { if (formFactor() == Plasma::Types::Vertical) syncGeometry(); }); @@ -135,12 +135,15 @@ void DockView::init() void DockView::adaptToScreen(QScreen *screen) { - if (!screen || !containment()) { + if (!screen || !containment() || this->screen() == screen) { return; } setScreen(screen); + //FIXME:: This code in a multi-screen environment that + //primary screen is not set to 0 it creates an endless + //showing loop at startup (catch-up race) between screen:0 and primaryScreen if (containment()) containment()->reactToScreenChange(); @@ -271,7 +274,7 @@ void DockView::setLocalDockGeometry(const QRect &geometry) void DockView::updateAbsDockGeometry(const QRect &localDockGeometry) { QRect absGeometry {x() + localDockGeometry.x(), y() + localDockGeometry.y() - , localDockGeometry.width() - 1, localDockGeometry.height() - 1}; + , localDockGeometry.width() - 1, localDockGeometry.height() - 1}; if (m_absGeometry == absGeometry) return; @@ -296,6 +299,7 @@ void DockView::updatePosition() switch (location()) { case Plasma::Types::TopEdge: screenGeometry = screen()->geometry(); + if (m_drawShadows) { position = {screenGeometry.x() + length(screenGeometry.width()), screenGeometry.y()}; } else { @@ -306,6 +310,7 @@ void DockView::updatePosition() case Plasma::Types::BottomEdge: screenGeometry = screen()->geometry(); + if (m_drawShadows) { position = {screenGeometry.x() + length(screenGeometry.width()), screenGeometry.y() + screenGeometry.height() - cleanThickness @@ -318,6 +323,7 @@ void DockView::updatePosition() case Plasma::Types::RightEdge: screenGeometry = corona()->availableScreenRect(containment()->screen()); + if (m_drawShadows && !mask().isNull()) { position = {screenGeometry.x() + screenGeometry.width() - cleanThickness, screenGeometry.y() + length(screenGeometry.height()) @@ -330,6 +336,7 @@ void DockView::updatePosition() case Plasma::Types::LeftEdge: screenGeometry = corona()->availableScreenRect(containment()->screen()); + if (m_drawShadows && !mask().isNull()) { position = {screenGeometry.x(), screenGeometry.y() + length(screenGeometry.height())}; } else { @@ -557,7 +564,7 @@ bool DockView::tasksPresent() return false; } -VisibilityManager * DockView::visibility() const +VisibilityManager *DockView::visibility() const { return m_visibility; }