28bool QEglFSKmsGbmDevice::open()
31 Q_ASSERT(m_gbm_device ==
nullptr);
33 int fd = qt_safe_open(devicePath().toLocal8Bit().constData(), O_RDWR | O_CLOEXEC);
35 qErrnoWarning(
"Could not open DRM device %s", qPrintable(devicePath()));
39 qCDebug(qLcEglfsKmsDebug) <<
"Creating GBM device for file descriptor" << fd
40 <<
"obtained from" << devicePath();
41 m_gbm_device = gbm_create_device(fd);
43 qErrnoWarning(
"Could not create GBM device");
51 if (usesEventReader()) {
52 qCDebug(qLcEglfsKmsDebug,
"Using dedicated drm event reading thread");
53 m_eventReader.create(
this);
55 qCDebug(qLcEglfsKmsDebug,
"Not using dedicated drm event reading thread; "
56 "threaded multi-screen setups may experience problems");
106void QEglFSKmsGbmDevice::createGlobalCursor(QEglFSKmsGbmScreen *screen)
108 if (!m_globalCursor && screenConfig()->hwCursor()) {
109 qCDebug(qLcEglfsKmsDebug,
"Creating new global GBM mouse cursor");
110 m_globalCursor =
new QEglFSKmsGbmCursor(screen);
114QPlatformScreen *QEglFSKmsGbmDevice::createScreen(
const QKmsOutput &output)
116 QEglFSKmsGbmScreen *screen =
new QEglFSKmsGbmScreen(
this, output,
false);
128 QTimer::singleShot(1, [screen,
this](){
129 createGlobalCursor(screen);
142void QEglFSKmsGbmDevice::registerScreenCloning(QPlatformScreen *screen,
143 QPlatformScreen *screenThisScreenClones,
144 const QList<QPlatformScreen *> &screensCloningThisScreen)
146 QEglFSKmsGbmScreen *gbmScreen =
static_cast<QEglFSKmsGbmScreen *>(screen);
147 gbmScreen->initCloning(screenThisScreenClones, screensCloningThisScreen);
150void QEglFSKmsGbmDevice::registerScreen(QPlatformScreen *screen,
152 const QPoint &virtualPos,
153 const QList<QPlatformScreen *> &virtualSiblings)
155 QEglFSKmsDevice::registerScreen(screen, isPrimary, virtualPos, virtualSiblings);
156 if (screenConfig()->hwCursor() && m_globalCursor)
157 m_globalCursor->reevaluateVisibilityForScreens();
160void QEglFSKmsGbmDevice::unregisterScreen(QPlatformScreen *screen)
165 if (m_globalCursor && screen == m_globalCursor->screen()) {
166 qCDebug(qLcEglfsKmsDebug) <<
"Destroying global GBM mouse cursor due to unregistering"
167 <<
"it's screen - will probably be recreated right away";
168 delete m_globalCursor;
169 m_globalCursor =
nullptr;
171 QList<QPlatformScreen *> siblings = screen->virtualSiblings();
172 siblings.removeOne(screen);
173 if (siblings.count() > 0) {
174 QEglFSKmsGbmScreen *kmsScreen =
static_cast<QEglFSKmsGbmScreen *>(siblings.first());
175 m_globalCursor =
new QEglFSKmsGbmCursor(kmsScreen);
176 qCDebug(qLcEglfsKmsDebug) <<
"Creating new global GBM mouse cursor on sibling screen";
178 qCWarning(qLcEglfsKmsDebug) <<
"Couldn't find a sibling to recreate"
179 <<
"the GBM mouse cursor - it might vanish";
183 QEglFSKmsDevice::unregisterScreen(screen);