xcb: Handle screen siblings in QXcbVirtualDesktop

Change-Id: I2f3c3ad75bb3914667cf6f27dc2d91aac103607b
Reviewed-by: Błażej Szczygieł <spaz16@wp.pl>
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
This commit is contained in:
Alexander Volkov 2015-11-05 18:31:32 +03:00
parent 874aaa6ea0
commit 8beec99899
3 changed files with 17 additions and 15 deletions

View File

@ -263,8 +263,7 @@ void QXcbConnection::updateScreens(const xcb_randr_notify_event_t *event)
// Known screen removed -> delete it
m_screens.removeOne(screen);
foreach (QXcbScreen *otherScreen, m_screens)
otherScreen->removeVirtualSibling((QPlatformScreen *) screen);
virtualDesktop->removeScreen(screen);
QXcbIntegration::instance()->destroyScreen(screen);
@ -283,9 +282,7 @@ void QXcbConnection::updateScreens(const xcb_randr_notify_event_t *event)
qCDebug(lcQpaScreen) << "output" << screen->name() << "is connected and enabled";
screen->setPrimary(checkOutputIsPrimary(output.window, output.output));
foreach (QXcbScreen *otherScreen, m_screens)
if (otherScreen->root() == output.window)
otherScreen->addVirtualSibling(screen);
virtualDesktop->addScreen(screen);
m_screens << screen;
QXcbIntegration::instance()->screenAdded(screen, screen->isPrimary());
@ -308,8 +305,7 @@ void QXcbConnection::updateScreens(const xcb_randr_notify_event_t *event)
if (outputInfo->crtc == XCB_NONE) {
qCDebug(lcQpaScreen) << "output" << screen->name() << "has been disabled";
m_screens.removeOne(screen);
foreach (QXcbScreen *otherScreen, m_screens)
otherScreen->removeVirtualSibling((QPlatformScreen *) screen);
virtualDesktop->removeScreen(screen);
QXcbIntegration::instance()->destroyScreen(screen);
} else {
qCDebug(lcQpaScreen) << "output" << screen->name() << "has been temporarily disabled for the mode switch";
@ -443,8 +439,7 @@ void QXcbConnection::initializeScreens()
}
}
}
foreach (QPlatformScreen* s, siblings)
((QXcbScreen*)s)->setVirtualSiblings(siblings);
virtualDesktop->setScreens(siblings);
xcb_screen_next(&it);
++xcbScreenNumber;
} // for each xcb screen
@ -460,7 +455,7 @@ void QXcbConnection::initializeScreens()
QXcbVirtualDesktop *virtualDesktop = m_virtualDesktops.value(0);
if (virtualDesktop && !hasOutputs && !virtualDesktop->size().isEmpty() && m_screens.isEmpty()) {
QXcbScreen *screen = createScreen(virtualDesktop, 0, Q_NULLPTR);
screen->setVirtualSiblings(QList<QPlatformScreen *>() << screen);
virtualDesktop->setScreens(QList<QPlatformScreen *>() << screen);
m_screens << screen;
primaryScreen = screen;
primaryScreen->setPrimary(true);

View File

@ -74,6 +74,11 @@ QXcbScreen *QXcbVirtualDesktop::screenAt(const QPoint &pos) const
return Q_NULLPTR;
}
void QXcbVirtualDesktop::addScreen(QPlatformScreen *s)
{
((QXcbScreen *) s)->isPrimary() ? m_screens.prepend(s) : m_screens.append(s);
}
QXcbXSettings *QXcbVirtualDesktop::xSettings() const
{
if (!m_xSettings) {

View File

@ -68,6 +68,11 @@ public:
xcb_window_t root() const { return m_screen->root; }
QXcbScreen *screenAt(const QPoint &pos) const;
QList<QPlatformScreen *> screens() const { return m_screens; }
void setScreens(QList<QPlatformScreen *> sl) { m_screens = sl; }
void removeScreen(QPlatformScreen *s) { m_screens.removeOne(s); }
void addScreen(QPlatformScreen *s);
QXcbXSettings *xSettings() const;
bool compositingActive() const;
@ -78,6 +83,7 @@ public:
private:
xcb_screen_t *m_screen;
int m_number;
QList<QPlatformScreen *> m_screens;
QXcbXSettings *m_xSettings;
xcb_atom_t m_net_wm_cm_atom;
@ -110,10 +116,7 @@ public:
QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
qreal refreshRate() const Q_DECL_OVERRIDE { return m_refreshRate; }
Qt::ScreenOrientation orientation() const Q_DECL_OVERRIDE { return m_orientation; }
QList<QPlatformScreen *> virtualSiblings() const Q_DECL_OVERRIDE { return m_siblings; }
void setVirtualSiblings(QList<QPlatformScreen *> sl) { m_siblings = sl; }
void removeVirtualSibling(QPlatformScreen *s) { m_siblings.removeOne(s); }
void addVirtualSibling(QPlatformScreen *s) { ((QXcbScreen *) s)->isPrimary() ? m_siblings.prepend(s) : m_siblings.append(s); }
QList<QPlatformScreen *> virtualSiblings() const Q_DECL_OVERRIDE { return m_virtualDesktop->screens(); }
QXcbVirtualDesktop *virtualDesktop() const { return m_virtualDesktop; }
void setPrimary(bool primary) { m_primary = primary; }
@ -171,7 +174,6 @@ private:
QRect m_availableGeometry;
QSize m_virtualSize;
QSizeF m_virtualSizeMillimeters;
QList<QPlatformScreen *> m_siblings;
Qt::ScreenOrientation m_orientation;
QString m_windowManagerName;
bool m_syncRequestSupported;