2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Disable Qt's integration mechanism on GTK-based DE to avoid early GTK loading

This also removes TDESKTOP_USE_GTK_FILE_DIALOG since it doesn't forces GTK dialog for anyone and there is no reason to leave it

TDESKTOP_DISABLE_GTK_INTEGRATION can be also tested via action now
This commit is contained in:
Ilya Fedin
2020-08-04 19:47:01 +04:00
committed by John Preston
parent 1de1747c38
commit 786bedf271
7 changed files with 21 additions and 31 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -26,7 +26,6 @@ bool InAppImage();
bool IsStaticBinary();
bool UseGtkIntegration();
bool IsGtkIntegrationForced();
bool UseGtkFileDialog();
bool IsQtPluginsBundled();
bool IsXDGDesktopPortalPresent();