Load gtk2 even on Wayland

This commit is contained in:
Ilya Fedin 2020-05-30 19:35:18 +04:00 committed by John Preston
parent 4c546156da
commit 7ac78be984
1 changed files with 4 additions and 4 deletions

View File

@ -125,10 +125,11 @@ bool setupGtkBase(QLibrary &lib_gtk) {
// Otherwise we get segfault in Ubuntu 17.04 in gtk_init_check() call.
// See https://github.com/telegramdesktop/tdesktop/issues/3176
// See https://github.com/telegramdesktop/tdesktop/issues/3162
if(QGuiApplication::platformName().startsWith(qsl("wayland"), Qt::CaseInsensitive)) {
if(QGuiApplication::platformName().startsWith(qsl("wayland"), Qt::CaseInsensitive)
&& !lib_gtk.fileName().contains("gtk-x11-2.0")) {
DEBUG_LOG(("Limit allowed GDK backends to wayland"));
gdk_set_allowed_backends("wayland");
} else if (QGuiApplication::platformName() == qsl("xcb")) {
} else {
DEBUG_LOG(("Limit allowed GDK backends to x11"));
gdk_set_allowed_backends("x11");
}
@ -239,13 +240,12 @@ void start() {
DEBUG_LOG(("Loading libraries"));
bool gtkLoaded = false;
bool isWayland = QGuiApplication::platformName().startsWith(qsl("wayland"), Qt::CaseInsensitive);
QLibrary lib_gtk;
if (loadLibrary(lib_gtk, "gtk-3", 0)) {
gtkLoaded = setupGtkBase(lib_gtk);
}
if (!gtkLoaded && !isWayland && loadLibrary(lib_gtk, "gtk-x11-2.0", 0)) {
if (!gtkLoaded && loadLibrary(lib_gtk, "gtk-x11-2.0", 0)) {
gtkLoaded = setupGtkBase(lib_gtk);
}