mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
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:
committed by
John Preston
parent
428a501bac
commit
fd4f384c3b
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user