Skip to content

Commit 90fd5fc

Browse files
authored
Remove QT+GNOME+Wayland 'xcb' hack on fixed Qt versions (flameshot-org#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
1 parent 7346d5b commit 90fd5fc

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/main.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,28 @@
3737
// source: https://github.com/ksnip/ksnip/issues/416
3838
void wayland_hacks()
3939
{
40-
// Workaround to https://github.com/ksnip/ksnip/issues/416
40+
int suffixIndex;
4141
DesktopInfo info;
42-
if (info.windowManager() == DesktopInfo::GNOME) {
43-
qputenv("QT_QPA_PLATFORM", "xcb");
42+
43+
const char* qt_version = qVersion();
44+
45+
QVersionNumber targetVersion(5, 15, 2);
46+
QString string(qt_version);
47+
QVersionNumber currentVersion =
48+
QVersionNumber::fromString(string, &suffixIndex);
49+
50+
if (currentVersion < targetVersion) {
51+
if (info.windowManager() == DesktopInfo::GNOME) {
52+
qWarning()
53+
<< "Qt versions lower than" << targetVersion.toString()
54+
<< "on GNOME using Wayland have a bug when accessing the "
55+
"clipboard."
56+
<< "Your version is" << currentVersion.toString()
57+
<< "so we're forcing QT_QPA_PLATFORM to 'xcb'."
58+
<< "To use native Wayland, please upgrade your Qt version to"
59+
<< targetVersion.toString() << "or higher";
60+
qputenv("QT_QPA_PLATFORM", "xcb");
61+
}
4462
}
4563
}
4664
#endif

0 commit comments

Comments
 (0)