Remove QT+GNOME+Wayland 'xcb' hack on fixed Qt versions (#3683)

* Bypass the Qt GNOME/Wayland workaround on fixed Qt versions

We implement code on GNOME desktops to force the
QT_QPA_PLATFORM to be 'xcb'; this works around a
clipboard-related bug on GNOME+Wayland+Qt.

This bug was fixed (or worked around) in Qt 5.15.2,
so we implement a version check; if the runtime Qt
version is < 5.15.2, still force the workaround;
otherwise, we don't need the workaround so we skip
it.

* Reformat with clang-format
This commit is contained in:
Daniel Fox
2025-05-10 18:07:12 -07:00
committed by GitHub
parent 7346d5bfe7
commit 90fd5fcb2e

View File

@@ -37,10 +37,28 @@
// source: https://github.com/ksnip/ksnip/issues/416
void wayland_hacks()
{
// Workaround to https://github.com/ksnip/ksnip/issues/416
int suffixIndex;
DesktopInfo info;
if (info.windowManager() == DesktopInfo::GNOME) {
qputenv("QT_QPA_PLATFORM", "xcb");
const char* qt_version = qVersion();
QVersionNumber targetVersion(5, 15, 2);
QString string(qt_version);
QVersionNumber currentVersion =
QVersionNumber::fromString(string, &suffixIndex);
if (currentVersion < targetVersion) {
if (info.windowManager() == DesktopInfo::GNOME) {
qWarning()
<< "Qt versions lower than" << targetVersion.toString()
<< "on GNOME using Wayland have a bug when accessing the "
"clipboard."
<< "Your version is" << currentVersion.toString()
<< "so we're forcing QT_QPA_PLATFORM to 'xcb'."
<< "To use native Wayland, please upgrade your Qt version to"
<< targetVersion.toString() << "or higher";
qputenv("QT_QPA_PLATFORM", "xcb");
}
}
}
#endif