fix #116,add protections in multi-screen

v0.6
Michail Vourlakos 8 years ago
parent e355cb1c42
commit e93fa6b2c6

@ -211,6 +211,7 @@ QRect DockCorona::availableScreenRect(int id) const
case Plasma::Types::TopEdge: case Plasma::Types::TopEdge:
available.setTopLeft({available.x(), dockRect.bottom()}); available.setTopLeft({available.x(), dockRect.bottom()});
break; break;
case Plasma::Types::BottomEdge: case Plasma::Types::BottomEdge:
available.setBottomLeft({available.x(), dockRect.top()}); 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 int DockCorona::screenForContainment(const Plasma::Containment *containment) const
{ {
for (auto *view : m_dockViews) { for (auto *view : m_dockViews) {
if (view && view->containment() && view->containment()->id() == containment->id()) if (view && view->containment() && view->containment() == containment)
if (view->screen()) if (view->screen())
return qGuiApp->screens().indexOf(view->screen()); return qGuiApp->screens().indexOf(view->screen());
} }

@ -135,12 +135,15 @@ void DockView::init()
void DockView::adaptToScreen(QScreen *screen) void DockView::adaptToScreen(QScreen *screen)
{ {
if (!screen || !containment()) { if (!screen || !containment() || this->screen() == screen) {
return; return;
} }
setScreen(screen); 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()) if (containment())
containment()->reactToScreenChange(); containment()->reactToScreenChange();
@ -296,6 +299,7 @@ void DockView::updatePosition()
switch (location()) { switch (location()) {
case Plasma::Types::TopEdge: case Plasma::Types::TopEdge:
screenGeometry = screen()->geometry(); screenGeometry = screen()->geometry();
if (m_drawShadows) { if (m_drawShadows) {
position = {screenGeometry.x() + length(screenGeometry.width()), screenGeometry.y()}; position = {screenGeometry.x() + length(screenGeometry.width()), screenGeometry.y()};
} else { } else {
@ -306,6 +310,7 @@ void DockView::updatePosition()
case Plasma::Types::BottomEdge: case Plasma::Types::BottomEdge:
screenGeometry = screen()->geometry(); screenGeometry = screen()->geometry();
if (m_drawShadows) { if (m_drawShadows) {
position = {screenGeometry.x() + length(screenGeometry.width()), position = {screenGeometry.x() + length(screenGeometry.width()),
screenGeometry.y() + screenGeometry.height() - cleanThickness screenGeometry.y() + screenGeometry.height() - cleanThickness
@ -318,6 +323,7 @@ void DockView::updatePosition()
case Plasma::Types::RightEdge: case Plasma::Types::RightEdge:
screenGeometry = corona()->availableScreenRect(containment()->screen()); screenGeometry = corona()->availableScreenRect(containment()->screen());
if (m_drawShadows && !mask().isNull()) { if (m_drawShadows && !mask().isNull()) {
position = {screenGeometry.x() + screenGeometry.width() - cleanThickness, position = {screenGeometry.x() + screenGeometry.width() - cleanThickness,
screenGeometry.y() + length(screenGeometry.height()) screenGeometry.y() + length(screenGeometry.height())
@ -330,6 +336,7 @@ void DockView::updatePosition()
case Plasma::Types::LeftEdge: case Plasma::Types::LeftEdge:
screenGeometry = corona()->availableScreenRect(containment()->screen()); screenGeometry = corona()->availableScreenRect(containment()->screen());
if (m_drawShadows && !mask().isNull()) { if (m_drawShadows && !mask().isNull()) {
position = {screenGeometry.x(), screenGeometry.y() + length(screenGeometry.height())}; position = {screenGeometry.x(), screenGeometry.y() + length(screenGeometry.height())};
} else { } else {

Loading…
Cancel
Save