=== modified file 'libunity-2d-private/src/unity2dpanel.cpp' --- libunity-2d-private/src/unity2dpanel.cpp 2011-09-27 13:58:46 +0000 +++ libunity-2d-private/src/unity2dpanel.cpp 2011-12-10 22:48:37 +0000 @@ -27,6 +27,7 @@ // Qt #include #include +#include #include #include #include @@ -44,6 +45,7 @@ Unity2dPanel::Edge m_edge; mutable IndicatorsManager* m_indicatorsManager; QHBoxLayout* m_layout; + int m_screen; QPropertyAnimation* m_slideInAnimation; QPropertyAnimation* m_slideOutAnimation; bool m_useStrut; @@ -97,7 +99,11 @@ void updateGeometry() { QDesktopWidget* desktop = QApplication::desktop(); - const QRect screen = desktop->screenGeometry(q); + // use the screen number set by moveEvent(): at the time + // showEvent() is called, the screen number associated with + // this widget might not have been updated to reflect the + // final position. + const QRect screen = desktop->screenGeometry(m_screen); const QRect available = desktop->availableGeometry(q); QRect rect; @@ -105,7 +111,7 @@ case Unity2dPanel::LeftEdge: if (QApplication::isLeftToRight()) { rect = QRect(screen.left(), available.top(), q->width(), available.height()); - rect.moveLeft(m_delta); + rect.moveLeft(screen.left() + m_delta); } else { rect = QRect(screen.right() - q->width(), available.top(), q->width(), available.height()); rect.moveRight(screen.right() - m_delta); @@ -113,7 +119,7 @@ break; case Unity2dPanel::TopEdge: rect = QRect(screen.left(), screen.top(), screen.width(), q->height()); - rect.moveTop(m_delta); + rect.moveTop(screen.top() + m_delta); break; } @@ -148,6 +154,8 @@ : QWidget(parent) , d(new Unity2dPanelPrivate) { + QDesktopWidget* desktop = QApplication::desktop(); + d->q = this; d->m_edge = Unity2dPanel::TopEdge; d->m_indicatorsManager = 0; @@ -157,6 +165,7 @@ d->m_layout = new QHBoxLayout(this); d->m_layout->setMargin(0); d->m_layout->setSpacing(0); + d->m_screen = desktop->primaryScreen(); d->m_slideInAnimation = new QPropertyAnimation(this); d->m_slideInAnimation->setTargetObject(this); @@ -179,7 +188,7 @@ setAutoFillBackground(true); } - connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), SLOT(slotWorkAreaResized(int))); + connect(desktop, SIGNAL(workAreaResized(int)), SLOT(slotWorkAreaResized(int))); } Unity2dPanel::~Unity2dPanel() @@ -219,6 +228,13 @@ d->m_slideOutAnimation->setEndValue(-panelSize()); } +void Unity2dPanel::moveEvent(QMoveEvent* event) +{ + QWidget::moveEvent(event); + QDesktopWidget* desktop = QApplication::desktop(); + d->m_screen = desktop->screenNumber(event->pos()); +} + void Unity2dPanel::resizeEvent(QResizeEvent* event) { QWidget::resizeEvent(event); === modified file 'libunity-2d-private/src/unity2dpanel.h' --- libunity-2d-private/src/unity2dpanel.h 2011-09-28 13:08:41 +0000 +++ libunity-2d-private/src/unity2dpanel.h 2011-12-10 22:29:15 +0000 @@ -93,6 +93,7 @@ virtual void showEvent(QShowEvent*); virtual void resizeEvent(QResizeEvent*); virtual void paintEvent(QPaintEvent*); + virtual void moveEvent(QMoveEvent *); private Q_SLOTS: void slotWorkAreaResized(int screen); === modified file 'panel/app/panelmanager.cpp' --- panel/app/panelmanager.cpp 2011-09-27 13:58:46 +0000 +++ panel/app/panelmanager.cpp 2011-12-10 22:43:25 +0000 @@ -122,8 +122,10 @@ for(int i = 0; i < desktop->screenCount(); ++i) { Unity2dPanel* panel = instantiatePanel(i); m_panels.append(panel); - panel->show(); + // perform move() first, so that the destination screen is known by the time + // show() is called and the edge length is computed. panel->move(desktop->screenGeometry(i).topLeft()); + panel->show(); } connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int))); @@ -198,8 +200,8 @@ panel = instantiatePanel(leftmost); m_panels.append(panel); } - panel->show(); panel->move(desktop->screenGeometry(leftmost).topLeft()); + panel->show(); /* Update the position of other existing panels, and instantiate new panels as needed. */ @@ -214,8 +216,8 @@ panel = instantiatePanel(screen); m_panels.append(panel); } + panel->move(desktop->screenGeometry(screen).topLeft()); panel->show(); - panel->move(desktop->screenGeometry(screen).topLeft()); ++i; } }