Allow initializing gtk integration before QApplication
This commit is contained in:
parent
19b6f6e9a1
commit
53fd3fce84
2 changed files with 44 additions and 51 deletions
|
@ -13,11 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "platform/linux/linux_gdk_helper.h"
|
||||
#include "platform/linux/linux_gtk_file_dialog.h"
|
||||
#include "platform/linux/linux_open_with_dialog.h"
|
||||
#include "platform/linux/specific_linux.h"
|
||||
#include "ui/platform/ui_platform_utility.h"
|
||||
#include "core/sandbox.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "core/application.h"
|
||||
|
||||
namespace Platform {
|
||||
namespace internal {
|
||||
|
@ -47,30 +42,6 @@ bool GetImageFromClipboardSupported() {
|
|||
&& (gdk_atom_intern != nullptr);
|
||||
}
|
||||
|
||||
void SetScaleFactor() {
|
||||
Core::Sandbox::Instance().customEnterFromEventLoop([] {
|
||||
const auto integration = GtkIntegration::Instance();
|
||||
const auto ratio = Core::Sandbox::Instance().devicePixelRatio();
|
||||
if (!integration || ratio > 1.) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto scaleFactor = integration->scaleFactor().value_or(1);
|
||||
if (scaleFactor == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(("GTK scale factor: %1").arg(scaleFactor));
|
||||
cSetScreenScale(style::CheckScale(scaleFactor * 100));
|
||||
});
|
||||
}
|
||||
|
||||
void DarkModeChanged() {
|
||||
Core::Sandbox::Instance().customEnterFromEventLoop([] {
|
||||
Core::App().settings().setSystemDarkMode(IsDarkMode());
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
GtkIntegration::GtkIntegration() {
|
||||
|
@ -161,24 +132,6 @@ void GtkIntegration::load() {
|
|||
LOAD_GTK_SYMBOL(Library(), "gtk_app_chooser_get_type", gtk_app_chooser_get_type);
|
||||
|
||||
Loaded = true;
|
||||
|
||||
SetScaleFactor();
|
||||
|
||||
BaseGtkIntegration::Instance()->connectToSetting(
|
||||
"gtk-theme-name",
|
||||
DarkModeChanged);
|
||||
|
||||
if (BaseGtkIntegration::Instance()->checkVersion(3, 0, 0)) {
|
||||
BaseGtkIntegration::Instance()->connectToSetting(
|
||||
"gtk-application-prefer-dark-theme",
|
||||
DarkModeChanged);
|
||||
}
|
||||
|
||||
if (BaseGtkIntegration::Instance()->checkVersion(3, 12, 0)) {
|
||||
BaseGtkIntegration::Instance()->connectToSetting(
|
||||
"gtk-decoration-layout",
|
||||
Ui::Platform::NotifyTitleControlsLayoutChanged);
|
||||
}
|
||||
}
|
||||
|
||||
bool GtkIntegration::loaded() const {
|
||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/platform/base_platform_info.h"
|
||||
#include "base/platform/linux/base_linux_xcb_utilities.h"
|
||||
#include "base/platform/linux/base_linux_gtk_integration.h"
|
||||
#include "ui/platform/ui_platform_utility.h"
|
||||
#include "platform/linux/linux_desktop_environment.h"
|
||||
#include "platform/linux/linux_gtk_integration.h"
|
||||
#include "platform/linux/linux_wayland_integration.h"
|
||||
|
@ -17,9 +18,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "lang/lang_keys.h"
|
||||
#include "mainwindow.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "core/sandbox.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "core/update_checker.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "core/application.h"
|
||||
|
||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
#include "platform/linux/linux_notification_service_watcher.h"
|
||||
|
@ -347,6 +350,28 @@ bool GenerateDesktopFile(
|
|||
}
|
||||
}
|
||||
|
||||
void SetGtkScaleFactor() {
|
||||
const auto integration = GtkIntegration::Instance();
|
||||
const auto ratio = Core::Sandbox::Instance().devicePixelRatio();
|
||||
if (!integration || ratio > 1.) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto scaleFactor = integration->scaleFactor().value_or(1);
|
||||
if (scaleFactor == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(("GTK scale factor: %1").arg(scaleFactor));
|
||||
cSetScreenScale(style::CheckScale(scaleFactor * 100));
|
||||
}
|
||||
|
||||
void DarkModeChanged() {
|
||||
Core::Sandbox::Instance().customEnterFromEventLoop([] {
|
||||
Core::App().settings().setSystemDarkMode(IsDarkMode());
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void SetWatchingMediaKeys(bool watching) {
|
||||
|
@ -851,9 +876,6 @@ bool OpenSystemSettings(SystemSettingsType type) {
|
|||
namespace ThirdParty {
|
||||
|
||||
void start() {
|
||||
DEBUG_LOG(("Icon theme: %1").arg(QIcon::themeName()));
|
||||
DEBUG_LOG(("Fallback icon theme: %1").arg(QIcon::fallbackThemeName()));
|
||||
|
||||
if (const auto integration = BaseGtkIntegration::Instance()) {
|
||||
integration->load();
|
||||
}
|
||||
|
@ -862,6 +884,24 @@ void start() {
|
|||
integration->load();
|
||||
}
|
||||
|
||||
SetGtkScaleFactor();
|
||||
|
||||
BaseGtkIntegration::Instance()->connectToSetting(
|
||||
"gtk-theme-name",
|
||||
DarkModeChanged);
|
||||
|
||||
if (BaseGtkIntegration::Instance()->checkVersion(3, 0, 0)) {
|
||||
BaseGtkIntegration::Instance()->connectToSetting(
|
||||
"gtk-application-prefer-dark-theme",
|
||||
DarkModeChanged);
|
||||
}
|
||||
|
||||
if (BaseGtkIntegration::Instance()->checkVersion(3, 12, 0)) {
|
||||
BaseGtkIntegration::Instance()->connectToSetting(
|
||||
"gtk-decoration-layout",
|
||||
Ui::Platform::NotifyTitleControlsLayoutChanged);
|
||||
}
|
||||
|
||||
// wait for interface announce to know if native window frame is supported
|
||||
if (const auto integration = WaylandIntegration::Instance()) {
|
||||
integration->waitForInterfaceAnnounce();
|
||||
|
|
Loading…
Reference in a new issue