Skip to content

Commit cf44ef8

Browse files
committed
Force XCB under Linux Wayland
Due to an QT issue under Wayland, QLog sets QT_QPA_PLATFORM to xcb
1 parent 5c7fcf3 commit cf44ef8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

core/main.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,22 @@ static void debugMessageOutput(QtMsgType type, const QMessageLogContext &context
390390
}
391391
}
392392

393+
#ifdef Q_OS_LINUX
394+
void wayland_hacks()
395+
{
396+
// due to QT's issue, Dock widget is not working (cannot be docked) under QT5, < ?6.7? on Linux
397+
// Therefore it is necessary to force set XCB (X11)
398+
const QByteArray &sessionType = qgetenv("XDG_SESSION_TYPE").toLower();
399+
const QByteArray &disableXCBFallback = qgetenv("QLOG_DISABLE_XCB");
400+
if ( sessionType.contains("wayland")
401+
&& disableXCBFallback == QByteArray() )
402+
{
403+
qInfo() << "Force XCB";
404+
qputenv("QT_QPA_PLATFORM", "xcb");
405+
}
406+
}
407+
#endif
408+
393409
int main(int argc, char* argv[])
394410
{
395411

@@ -398,6 +414,9 @@ int main(int argc, char* argv[])
398414
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
399415
#endif
400416

417+
#ifdef Q_OS_LINUX
418+
wayland_hacks();
419+
#endif
401420

402421
bool stylePresent = false;
403422

0 commit comments

Comments
 (0)