diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 63f3684ed..e0c19cdf9 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -54,6 +54,7 @@ jobs: defines: - "" - "DESKTOP_APP_DISABLE_DBUS_INTEGRATION" + - "TDESKTOP_DISABLE_GTK_INTEGRATION" env: GIT: "https://github.com" diff --git a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp index a05155bfe..a4ca9421b 100644 --- a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp @@ -130,11 +130,12 @@ bool NativeSupported(Type type = Type::ReadFile) { // or if QT_QPA_PLATFORMTHEME=(gtk2|gtk3) // or if portals is used and operation is to open folder // and portal doesn't support folder choosing - return Platform::UseGtkFileDialog() - && (Platform::DesktopEnvironment::IsGtkBased() + return (Platform::DesktopEnvironment::IsGtkBased() || Platform::IsGtkIntegrationForced() || Platform::UseXDGDesktopPortal()) - && (!Platform::UseXDGDesktopPortal() + && ((!Platform::UseXDGDesktopPortal() && + ((!Platform::InFlatpak() && !Platform::InSnap()) + || Platform::IsGtkIntegrationForced())) || (type == Type::ReadFolder && !Platform::CanOpenDirectoryWithPortal())) && Platform::internal::GdkHelperLoaded() && (Libs::gtk_widget_hide_on_delete != nullptr) diff --git a/Telegram/SourceFiles/platform/linux/linux_libs.cpp b/Telegram/SourceFiles/platform/linux/linux_libs.cpp index 34866c500..1bd03703c 100644 --- a/Telegram/SourceFiles/platform/linux/linux_libs.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_libs.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "platform/linux/linux_libs.h" +#include "base/platform/base_platform_info.h" #include "platform/linux/linux_xlib_helper.h" #include "platform/linux/linux_gdk_helper.h" #include "platform/linux/specific_linux.h" @@ -114,8 +115,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 wayland and x11")); - gdk_set_allowed_backends("wayland,x11"); + if(Platform::IsWayland()) { + DEBUG_LOG(("Limit allowed GDK backends to wayland,x11")); + gdk_set_allowed_backends("wayland,x11"); + } else { + DEBUG_LOG(("Limit allowed GDK backends to x11,wayland")); + gdk_set_allowed_backends("x11,wayland"); + } } // gtk_init will reset the Xlib error handler, and that causes diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 18bf746d3..061c7b163 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -682,14 +682,6 @@ bool IsGtkIntegrationForced() { return false; } -bool UseGtkFileDialog() { -#ifdef TDESKTOP_USE_GTK_FILE_DIALOG - return true; -#else // TDESKTOP_USE_GTK_FILE_DIALOG - return false; -#endif // !TDESKTOP_USE_GTK_FILE_DIALOG -} - bool IsQtPluginsBundled() { #ifdef DESKTOP_APP_USE_PACKAGED_LAZY return true; @@ -1210,6 +1202,11 @@ void start() { qunsetenv("QT_QPA_PLATFORMTHEME"); qunsetenv("QT_STYLE_OVERRIDE"); + + // Don't allow qgtk3 to init gtk earlier than us + if (DesktopEnvironment::IsGtkBased()) { + QApplication::setDesktopSettingsAware(false); + } } if (!UseGtkIntegration()) { @@ -1241,10 +1238,10 @@ void start() { if((IsStaticBinary() || InAppImage() - || InSnap() - || UseGtkFileDialog() || IsQtPluginsBundled()) - && !InFlatpak()) { + // it is handled by Qt for flatpak and snap + && !InFlatpak() + && !InSnap()) { LOG(("Checking for XDG Desktop Portal...")); // this can give us a chance to use // a proper file dialog for current session diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.h b/Telegram/SourceFiles/platform/linux/specific_linux.h index 696031678..3a7064a50 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.h +++ b/Telegram/SourceFiles/platform/linux/specific_linux.h @@ -26,7 +26,6 @@ bool InAppImage(); bool IsStaticBinary(); bool UseGtkIntegration(); bool IsGtkIntegrationForced(); -bool UseGtkFileDialog(); bool IsQtPluginsBundled(); bool IsXDGDesktopPortalPresent(); diff --git a/Telegram/cmake/telegram_options.cmake b/Telegram/cmake/telegram_options.cmake index c3fad735f..27cbd588c 100644 --- a/Telegram/cmake/telegram_options.cmake +++ b/Telegram/cmake/telegram_options.cmake @@ -5,7 +5,6 @@ # https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL option(TDESKTOP_USE_FONTCONFIG_FALLBACK "Use custom fonts.conf (Linux only)." OFF) -option(TDESKTOP_USE_GTK_FILE_DIALOG "Use custom code for GTK file dialog (Linux only)." OFF) option(TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME "Disable automatic 'tg://' URL scheme handler registration." ${DESKTOP_APP_USE_PACKAGED}) option(TDESKTOP_DISABLE_NETWORK_PROXY "Disable all code for working through Socks5 or MTProxy." OFF) option(TDESKTOP_DISABLE_GTK_INTEGRATION "Disable all code for GTK integration (Linux only)." OFF) @@ -43,14 +42,6 @@ if (TDESKTOP_API_ID STREQUAL "0" OR TDESKTOP_API_HASH STREQUAL "") " ") endif() -if (NOT DESKTOP_APP_USE_PACKAGED) - set(TDESKTOP_USE_GTK_FILE_DIALOG ON) -endif() - -if (TDESKTOP_USE_GTK_FILE_DIALOG) - set(TDESKTOP_DISABLE_GTK_INTEGRATION OFF) -endif() - if (DESKTOP_APP_DISABLE_SPELLCHECK) target_compile_definitions(Telegram PRIVATE TDESKTOP_DISABLE_SPELLCHECK) else() @@ -69,10 +60,6 @@ if (TDESKTOP_USE_FONTCONFIG_FALLBACK) target_compile_definitions(Telegram PRIVATE TDESKTOP_USE_FONTCONFIG_FALLBACK) endif() -if (TDESKTOP_USE_GTK_FILE_DIALOG) - target_compile_definitions(Telegram PRIVATE TDESKTOP_USE_GTK_FILE_DIALOG) -endif() - if (TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME) target_compile_definitions(Telegram PRIVATE TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME) endif() diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 69682630b..a0c7ae0a7 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -101,7 +101,6 @@ parts: - -DTDESKTOP_API_ID=611335 - -DTDESKTOP_API_HASH=d524b414d21f4d37f08684c1df41ac9c - -DDESKTOP_APP_USE_PACKAGED_LAZY=ON - - -DTDESKTOP_USE_GTK_FILE_DIALOG=ON - -DDESKTOP_APP_QTWAYLANDCLIENT_PRIVATE_HEADERS=$SNAPCRAFT_STAGE/usr/include/$SNAPCRAFT_ARCH_TRIPLET/qt5/QtWaylandClient/5.12.8 override-pull: | snapcraftctl pull