Allow GDK wayland backend when Telegram is running under Wayland

and make sure that it never tries to load gtk2 under wayland, it can
lead to Telegram crashing
This commit is contained in:
John Zimmermann 2019-09-08 09:31:40 +03:00 committed by John Preston
parent 428a501bac
commit fd4f384c3b

View file

@ -106,8 +106,13 @@ 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
DEBUG_LOG(("Limit allowed GDK backends to x11"));
gdk_set_allowed_backends("x11");
if(QApplication::platformName().startsWith(qsl("wayland"), Qt::CaseInsensitive)) {
DEBUG_LOG(("Limit allowed GDK backends to wayland"));
gdk_set_allowed_backends("wayland");
} else if (QApplication::platformName() == qsl("xcb")) {
DEBUG_LOG(("Limit allowed GDK backends to x11"));
gdk_set_allowed_backends("x11");
}
}
DEBUG_LOG(("Library gtk functions loaded!"));
@ -228,6 +233,7 @@ void start() {
bool gtkLoaded = false;
bool indicatorLoaded = false;
bool isWayland = QApplication::platformName().startsWith(qsl("wayland"), Qt::CaseInsensitive);
QLibrary lib_gtk, lib_indicator;
if (loadLibrary(lib_indicator, "ayatana-appindicator3", 1) || loadLibrary(lib_indicator, "appindicator3", 1)) {
if (loadLibrary(lib_gtk, "gtk-3", 0)) {
@ -235,7 +241,7 @@ void start() {
indicatorLoaded = setupAppIndicator(lib_indicator);
}
}
if (!gtkLoaded || !indicatorLoaded) {
if ((!gtkLoaded || !indicatorLoaded) && !isWayland) {
if (loadLibrary(lib_indicator, "ayatana-appindicator", 1) || loadLibrary(lib_indicator, "appindicator", 1)) {
if (loadLibrary(lib_gtk, "gtk-x11-2.0", 0)) {
gtkLoaded = indicatorLoaded = false;
@ -250,7 +256,7 @@ void start() {
if (loadLibrary(lib_gtk, "gtk-3", 0)) {
gtkLoaded = setupGtkBase(lib_gtk);
}
if (!gtkLoaded && loadLibrary(lib_gtk, "gtk-x11-2.0", 0)) {
if (!gtkLoaded && !isWayland && loadLibrary(lib_gtk, "gtk-x11-2.0", 0)) {
gtkLoaded = setupGtkBase(lib_gtk);
}
}