27bool QEglFSKmsGbmDevice::open()
30 Q_ASSERT(m_gbm_device ==
nullptr);
32 int fd = qt_safe_open(devicePath().toLocal8Bit().constData(), O_RDWR | O_CLOEXEC);
34 qErrnoWarning(
"Could not open DRM device %s", qPrintable(devicePath()));
38 qCDebug(qLcEglfsKmsDebug) <<
"Creating GBM device for file descriptor" << fd
39 <<
"obtained from" << devicePath();
40 m_gbm_device = gbm_create_device(fd);
42 qErrnoWarning(
"Could not create GBM device");
50 if (usesEventReader()) {
51 qCDebug(qLcEglfsKmsDebug,
"Using dedicated drm event reading thread");
52 m_eventReader.create(
this);
54 qCDebug(qLcEglfsKmsDebug,
"Not using dedicated drm event reading thread; "
55 "threaded multi-screen setups may experience problems");
105void QEglFSKmsGbmDevice::createGlobalCursor(QEglFSKmsGbmScreen *screen)
107 if (!m_globalCursor && screenConfig()->hwCursor()) {
108 qCDebug(qLcEglfsKmsDebug,
"Creating new global GBM mouse cursor");
109 m_globalCursor =
new QEglFSKmsGbmCursor(screen);
113QPlatformScreen *QEglFSKmsGbmDevice::createScreen(
const QKmsOutput &output)
115 QEglFSKmsGbmScreen *screen =
new QEglFSKmsGbmScreen(
this, output,
false);
127 QTimer::singleShot(1, [screen,
this](){
128 createGlobalCursor(screen);
141void QEglFSKmsGbmDevice::registerScreenCloning(QPlatformScreen *screen,
142 QPlatformScreen *screenThisScreenClones,
143 const QList<QPlatformScreen *> &screensCloningThisScreen)
145 QEglFSKmsGbmScreen *gbmScreen =
static_cast<QEglFSKmsGbmScreen *>(screen);
146 gbmScreen->initCloning(screenThisScreenClones, screensCloningThisScreen);
149void QEglFSKmsGbmDevice::registerScreen(QPlatformScreen *screen,
151 const QPoint &virtualPos,
152 const QList<QPlatformScreen *> &virtualSiblings)
154 QEglFSKmsDevice::registerScreen(screen, isPrimary, virtualPos, virtualSiblings);
155 if (screenConfig()->hwCursor() && m_globalCursor)
156 m_globalCursor->reevaluateVisibilityForScreens();
159void QEglFSKmsGbmDevice::unregisterScreen(QPlatformScreen *screen)
164 if (m_globalCursor && screen == m_globalCursor->screen()) {
165 qCDebug(qLcEglfsKmsDebug) <<
"Destroying global GBM mouse cursor due to unregistering"
166 <<
"it's screen - will probably be recreated right away";
167 delete m_globalCursor;
168 m_globalCursor =
nullptr;
170 QList<QPlatformScreen *> siblings = screen->virtualSiblings();
171 siblings.removeOne(screen);
172 if (siblings.count() > 0) {
173 QEglFSKmsGbmScreen *kmsScreen =
static_cast<QEglFSKmsGbmScreen *>(siblings.first());
174 m_globalCursor =
new QEglFSKmsGbmCursor(kmsScreen);
175 qCDebug(qLcEglfsKmsDebug) <<
"Creating new global GBM mouse cursor on sibling screen";
177 qCWarning(qLcEglfsKmsDebug) <<
"Couldn't find a sibling to recreate"
178 <<
"the GBM mouse cursor - it might vanish";
182 QEglFSKmsDevice::unregisterScreen(screen);