fix #116,add protections in multi-screen

pull/1/head
Michail Vourlakos 8 years ago
parent 73923eac71
commit 3ab252339c

@ -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<Plasma::Types::Location> 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());
}

@ -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;
}

Loading…
Cancel
Save