telegram-desktop: port to new darwin SDK handling (#353228)

This commit is contained in:
Weijia Wang 2024-11-03 16:26:14 +01:00 committed by GitHub
commit 9ee8d70965
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 11 additions and 459 deletions

View File

@ -54,8 +54,6 @@ in
};
patches = [
./macos.patch
./macos-opengl.patch
./macos-qt5.patch
(fetchpatch {
url = "https://gitlab.com/mnauw/cppgir/-/commit/c8bb1c6017a6f7f2e47bd10543aea6b3ec69a966.patch";

View File

@ -1,66 +0,0 @@
diff --git a/Telegram/SourceFiles/media/view/media_view_pip.cpp b/Telegram/SourceFiles/media/view/media_view_pip.cpp
index 655e7cf410..c356acbffe 100644
--- a/Telegram/SourceFiles/media/view/media_view_pip.cpp
+++ b/Telegram/SourceFiles/media/view/media_view_pip.cpp
@@ -1333,7 +1333,7 @@ void Pip::setupStreaming() {
Ui::GL::ChosenRenderer Pip::chooseRenderer(
Ui::GL::Capabilities capabilities) {
const auto use = Platform::IsMac()
- ? true
+ ? false
: capabilities.transparency;
LOG(("OpenGL: %1 (PipPanel)").arg(Logs::b(use)));
if (use) {
Submodule Telegram/lib_ui contains modified content
diff --git a/Telegram/lib_ui/ui/gl/gl_detection.cpp b/Telegram/lib_ui/ui/gl/gl_detection.cpp
index 150eb8b..c7ce9f9 100644
--- a/Telegram/lib_ui/ui/gl/gl_detection.cpp
+++ b/Telegram/lib_ui/ui/gl/gl_detection.cpp
@@ -236,7 +236,7 @@ Capabilities CheckCapabilities(QWidget *widget, bool avoidWidgetCreation) {
Backend ChooseBackendDefault(Capabilities capabilities) {
const auto use = ::Platform::IsMac()
- ? true
+ ? false
: ::Platform::IsWindows()
? capabilities.supported
: capabilities.transparency;
diff --git a/Telegram/lib_ui/ui/platform/mac/ui_window_mac.mm b/Telegram/lib_ui/ui/platform/mac/ui_window_mac.mm
index 7b29363..22c4fb3 100644
--- a/Telegram/lib_ui/ui/platform/mac/ui_window_mac.mm
+++ b/Telegram/lib_ui/ui/platform/mac/ui_window_mac.mm
@@ -16,7 +16,6 @@
#include <QtCore/QAbstractNativeEventFilter>
#include <QtGui/QWindow>
#include <QtGui/QtEvents>
-#include <QOpenGLWidget>
#include <Cocoa/Cocoa.h>
@interface WindowObserver : NSObject {
@@ -138,7 +137,6 @@ public:
private:
void init();
- void initOpenGL();
void resolveWeakPointers();
void revalidateWeakPointers() const;
void initCustomTitle();
@@ -272,10 +270,6 @@ void WindowHelper::Private::enforceStyle() {
}
}
-void WindowHelper::Private::initOpenGL() {
- auto forceOpenGL = std::make_unique<QOpenGLWidget>(_owner->window());
-}
-
void WindowHelper::Private::resolveWeakPointers() {
if (!_owner->window()->winId()) {
_owner->window()->createWinId();
@@ -338,7 +332,6 @@ void WindowHelper::Private::initCustomTitle() {
}
void WindowHelper::Private::init() {
- initOpenGL();
resolveWeakPointers();
initCustomTitle();
}

View File

@ -1,171 +0,0 @@
diff --git a/Telegram/SourceFiles/platform/mac/overlay_widget_mac.mm b/Telegram/SourceFiles/platform/mac/overlay_widget_mac.mm
index ef544803e9..69c61b3139 100644
--- a/Telegram/SourceFiles/platform/mac/overlay_widget_mac.mm
+++ b/Telegram/SourceFiles/platform/mac/overlay_widget_mac.mm
@@ -97,9 +97,11 @@ void MacOverlayWidgetHelper::updateStyles(bool fullscreen) {
[window setTitleVisibility:NSWindowTitleHidden];
[window setTitlebarAppearsTransparent:YES];
[window setStyleMask:[window styleMask] | NSWindowStyleMaskFullSizeContentView];
+#if 0
if (@available(macOS 12.0, *)) {
_data->topNotchSkip = [[window screen] safeAreaInsets].top;
}
+#endif
}
void MacOverlayWidgetHelper::refreshButtons(bool fullscreen) {
Submodule Telegram/lib_base contains modified content
diff --git a/Telegram/lib_base/base/platform/mac/base_battery_saving_mac.mm b/Telegram/lib_base/base/platform/mac/base_battery_saving_mac.mm
index 7ce90d3..dac3c2c 100644
--- a/Telegram/lib_base/base/platform/mac/base_battery_saving_mac.mm
+++ b/Telegram/lib_base/base/platform/mac/base_battery_saving_mac.mm
@@ -138,6 +138,7 @@ BatterySaving::BatterySaving(Fn<void()> changedCallback) {
_observer = [[LowPowerModeObserver alloc] initWithCallback:std::move(wrapped)];
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+#if 0
if (@available(macOS 12.0, *)) {
[center
addObserver: _observer
@@ -145,6 +146,7 @@ BatterySaving::BatterySaving(Fn<void()> changedCallback) {
name: NSProcessInfoPowerStateDidChangeNotification
object: nil];
}
+#endif
[center
addObserver: _observer
selector: @selector(powerStateChanged:)
@@ -178,11 +180,13 @@ std::optional<bool> BatterySaving::enabled() const {
return std::nullopt;
}
NSProcessInfo *info = [NSProcessInfo processInfo];
+#if 0
if (@available(macOS 12.0, *)) {
if ([info isLowPowerModeEnabled]) {
return true;
}
}
+#endif
const auto state = DetectBatteryState();
if (!state.has || !state.draining) {
return false;
Submodule Telegram/lib_webrtc contains modified content
diff --git a/Telegram/lib_webrtc/webrtc/platform/mac/webrtc_environment_mac.mm b/Telegram/lib_webrtc/webrtc/platform/mac/webrtc_environment_mac.mm
index 7521c08..5e22da2 100644
--- a/Telegram/lib_webrtc/webrtc/platform/mac/webrtc_environment_mac.mm
+++ b/Telegram/lib_webrtc/webrtc/platform/mac/webrtc_environment_mac.mm
@@ -364,6 +364,7 @@ EnvironmentMac::EnvironmentMac(not_null<EnvironmentDelegate*> delegate)
DefaultCaptureDeviceChangedMonitor.registerEnvironment(this);
AudioDeviceListChangedMonitor.registerEnvironment(this);
+#if 0
if (@available(macOS 14.0, *)) {
const auto weak = base::make_weak(this);
id block = [^(BOOL shouldBeMuted){
@@ -387,6 +388,7 @@ EnvironmentMac::EnvironmentMac(not_null<EnvironmentDelegate*> delegate)
setInputMuteStateChangeHandler:block
error:nil];
}
+#endif
}
EnvironmentMac::~EnvironmentMac() {
@@ -537,15 +539,18 @@ void EnvironmentMac::devicesRequested(DeviceType type) {
}
void EnvironmentMac::setCaptureMuted(bool muted) {
+#if 0
if (@available(macOS 14.0, *)) {
if (!_captureMuteNotification) {
const auto value = muted ? YES : NO;
[[AVAudioApplication sharedInstance] setInputMuted:value error:nil];
}
}
+#endif
}
void EnvironmentMac::captureMuteSubscribe() {
+#if 0
if (@available(macOS 14.0, *)) {
id observer = [[InputMuteObserver alloc] init];
[[[NSWorkspace sharedWorkspace] notificationCenter]
@@ -578,6 +583,7 @@ void EnvironmentMac::captureMuteSubscribe() {
[observer release];
});
}
+#endif
}
void EnvironmentMac::captureMuteUnsubscribe() {
@@ -595,6 +601,7 @@ void EnvironmentMac::captureMuteRestartAdm() {
void EnvironmentMac::setCaptureMuteTracker(
not_null<CaptureMuteTracker*> tracker,
bool track) {
+#if 0
if (@available(macOS 14.0, *)) {
if (track) {
if (!_captureMuteTracker) {
@@ -619,6 +626,7 @@ void EnvironmentMac::setCaptureMuteTracker(
}
}
}
+#endif
}
std::unique_ptr<Environment> CreateEnvironment(
Submodule Telegram/lib_webview contains modified content
diff --git a/Telegram/lib_webview/webview/platform/mac/webview_mac.mm b/Telegram/lib_webview/webview/platform/mac/webview_mac.mm
index e7808fc..34020f0 100644
--- a/Telegram/lib_webview/webview/platform/mac/webview_mac.mm
+++ b/Telegram/lib_webview/webview/platform/mac/webview_mac.mm
@@ -334,6 +334,7 @@ Instance::Instance(Config config) {
_handler = [[Handler alloc] initWithMessageHandler:config.messageHandler navigationStartHandler:config.navigationStartHandler navigationDoneHandler:config.navigationDoneHandler dialogHandler:config.dialogHandler dataRequested:handleDataRequest];
_dataRequestHandler = std::move(config.dataRequestHandler);
[configuration setURLSchemeHandler:_handler forURLScheme:stdToNS(kDataUrlScheme)];
+#if 0
if (@available(macOS 14, *)) {
if (config.userDataToken != LegacyStorageIdToken().toStdString()) {
NSUUID *uuid = UuidFromToken(config.userDataToken);
@@ -341,10 +342,13 @@ Instance::Instance(Config config) {
[uuid release];
}
}
+#endif
_webview = [[WKWebView alloc] initWithFrame:NSZeroRect configuration:configuration];
+#if 0
if (@available(macOS 13.3, *)) {
_webview.inspectable = config.debug ? YES : NO;
}
+#endif
[_manager addScriptMessageHandler:_handler name:@"external"];
[_webview setNavigationDelegate:_handler];
[_webview setUIDelegate:_handler];
@@ -700,10 +704,12 @@ void *Instance::winId() {
}
void Instance::setOpaqueBg(QColor opaqueBg) {
+#if 0
if (@available(macOS 12.0, *)) {
[_webview setValue: @NO forKey: @"drawsBackground"];
[_webview setUnderPageBackgroundColor:[NSColor clearColor]];
}
+#endif
}
void Instance::resizeToWindow() {
@@ -739,6 +745,7 @@ std::string GenerateStorageToken() {
}
void ClearStorageDataByToken(const std::string &token) {
+#if 0
if (@available(macOS 14, *)) {
if (!token.empty() && token != LegacyStorageIdToken().toStdString()) {
if (NSUUID *uuid = UuidFromToken(token)) {
@@ -754,6 +761,7 @@ void ClearStorageDataByToken(const std::string &token) {
}
}
}
+#endif
}
} // namespace Webview

View File

@ -6,7 +6,6 @@
, cmake
, ninja
, clang
, lld
, python3
, wrapQtAppsHook
, tg_owt ? callPackage ./tg_owt.nix { inherit stdenv; }
@ -38,7 +37,7 @@
, glib-networking
, webkitgtk_4_1
, libicns
, darwin
, apple-sdk_15
, nix-update-script
}:
@ -61,10 +60,6 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-frz425V5eRulNVxCf457TWQAzU/f9/szD/sx3/LYQ2Y=";
};
patches = [
./macos.patch
];
postPatch = lib.optionalString stdenv.hostPlatform.isLinux ''
substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioInputALSA.cpp \
--replace-fail '"libasound.so.2"' '"${alsa-lib}/lib/libasound.so.2"'
@ -98,8 +93,6 @@ stdenv.mkDerivation (finalAttrs: {
gobject-introspection
] ++ lib.optionals (stdenv.hostPlatform.isLinux && withWebKitGTK) [
wrapGAppsHook3
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
lld
];
buildInputs = [
@ -130,45 +123,10 @@ stdenv.mkDerivation (finalAttrs: {
] ++ lib.optionals (stdenv.hostPlatform.isLinux && withWebKitGTK) [
glib-networking
webkitgtk_4_1
] ++ lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk_11_0.frameworks; [
Cocoa
CoreFoundation
CoreServices
CoreText
CoreGraphics
CoreMedia
OpenGL
AudioUnit
ApplicationServices
Foundation
AGL
Security
SystemConfiguration
Carbon
AudioToolbox
VideoToolbox
VideoDecodeAcceleration
AVFoundation
CoreAudio
CoreVideo
CoreMediaIO
QuartzCore
AppKit
CoreWLAN
WebKit
IOKit
GSS
MediaPlayer
IOSurface
Metal
NaturalLanguage
LocalAuthentication
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
apple-sdk_15
libicns
]);
env = lib.optionalAttrs stdenv.hostPlatform.isDarwin {
NIX_CFLAGS_LINK = "-fuse-ld=lld";
};
];
cmakeFlags = [
# We're allowed to used the API ID of the Snap package:

View File

@ -1,145 +0,0 @@
diff --git a/Telegram/SourceFiles/platform/mac/overlay_widget_mac.mm b/Telegram/SourceFiles/platform/mac/overlay_widget_mac.mm
index ef544803e9..69c61b3139 100644
--- a/Telegram/SourceFiles/platform/mac/overlay_widget_mac.mm
+++ b/Telegram/SourceFiles/platform/mac/overlay_widget_mac.mm
@@ -97,9 +97,11 @@ void MacOverlayWidgetHelper::updateStyles(bool fullscreen) {
[window setTitleVisibility:NSWindowTitleHidden];
[window setTitlebarAppearsTransparent:YES];
[window setStyleMask:[window styleMask] | NSWindowStyleMaskFullSizeContentView];
+#if 0
if (@available(macOS 12.0, *)) {
_data->topNotchSkip = [[window screen] safeAreaInsets].top;
}
+#endif
}
void MacOverlayWidgetHelper::refreshButtons(bool fullscreen) {
Submodule Telegram/lib_base contains modified content
diff --git a/Telegram/lib_base/base/platform/mac/base_battery_saving_mac.mm b/Telegram/lib_base/base/platform/mac/base_battery_saving_mac.mm
index 7ce90d3..dac3c2c 100644
--- a/Telegram/lib_base/base/platform/mac/base_battery_saving_mac.mm
+++ b/Telegram/lib_base/base/platform/mac/base_battery_saving_mac.mm
@@ -138,6 +138,7 @@ BatterySaving::BatterySaving(Fn<void()> changedCallback) {
_observer = [[LowPowerModeObserver alloc] initWithCallback:std::move(wrapped)];
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+#if 0
if (@available(macOS 12.0, *)) {
[center
addObserver: _observer
@@ -145,6 +146,7 @@ BatterySaving::BatterySaving(Fn<void()> changedCallback) {
name: NSProcessInfoPowerStateDidChangeNotification
object: nil];
}
+#endif
[center
addObserver: _observer
selector: @selector(powerStateChanged:)
@@ -178,11 +180,13 @@ std::optional<bool> BatterySaving::enabled() const {
return std::nullopt;
}
NSProcessInfo *info = [NSProcessInfo processInfo];
+#if 0
if (@available(macOS 12.0, *)) {
if ([info isLowPowerModeEnabled]) {
return true;
}
}
+#endif
const auto state = DetectBatteryState();
if (!state.has || !state.draining) {
return false;
Submodule Telegram/lib_webrtc contains modified content
diff --git a/Telegram/lib_webrtc/webrtc/platform/mac/webrtc_environment_mac.mm b/Telegram/lib_webrtc/webrtc/platform/mac/webrtc_environment_mac.mm
index 7521c08..5e22da2 100644
--- a/Telegram/lib_webrtc/webrtc/platform/mac/webrtc_environment_mac.mm
+++ b/Telegram/lib_webrtc/webrtc/platform/mac/webrtc_environment_mac.mm
@@ -364,6 +364,7 @@ EnvironmentMac::EnvironmentMac(not_null<EnvironmentDelegate*> delegate)
DefaultCaptureDeviceChangedMonitor.registerEnvironment(this);
AudioDeviceListChangedMonitor.registerEnvironment(this);
+#if 0
if (@available(macOS 14.0, *)) {
const auto weak = base::make_weak(this);
id block = [^(BOOL shouldBeMuted){
@@ -387,6 +388,7 @@ EnvironmentMac::EnvironmentMac(not_null<EnvironmentDelegate*> delegate)
setInputMuteStateChangeHandler:block
error:nil];
}
+#endif
}
EnvironmentMac::~EnvironmentMac() {
@@ -537,15 +539,18 @@ void EnvironmentMac::devicesRequested(DeviceType type) {
}
void EnvironmentMac::setCaptureMuted(bool muted) {
+#if 0
if (@available(macOS 14.0, *)) {
if (!_captureMuteNotification) {
const auto value = muted ? YES : NO;
[[AVAudioApplication sharedInstance] setInputMuted:value error:nil];
}
}
+#endif
}
void EnvironmentMac::captureMuteSubscribe() {
+#if 0
if (@available(macOS 14.0, *)) {
id observer = [[InputMuteObserver alloc] init];
[[[NSWorkspace sharedWorkspace] notificationCenter]
@@ -578,6 +583,7 @@ void EnvironmentMac::captureMuteSubscribe() {
[observer release];
});
}
+#endif
}
void EnvironmentMac::captureMuteUnsubscribe() {
@@ -595,6 +601,7 @@ void EnvironmentMac::captureMuteRestartAdm() {
void EnvironmentMac::setCaptureMuteTracker(
not_null<CaptureMuteTracker*> tracker,
bool track) {
+#if 0
if (@available(macOS 14.0, *)) {
if (track) {
if (!_captureMuteTracker) {
@@ -619,6 +626,7 @@ void EnvironmentMac::setCaptureMuteTracker(
}
}
}
+#endif
}
std::unique_ptr<Environment> CreateEnvironment(
Submodule Telegram/lib_webview contains modified content
diff --git a/Telegram/lib_webview/webview/platform/mac/webview_mac.mm b/Telegram/lib_webview/webview/platform/mac/webview_mac.mm
index 738e574..80ff5f0 100644
--- a/Telegram/lib_webview/webview/platform/mac/webview_mac.mm
+++ b/Telegram/lib_webview/webview/platform/mac/webview_mac.mm
@@ -314,9 +314,11 @@ Instance::Instance(Config config) {
_dataRequestHandler = std::move(config.dataRequestHandler);
[configuration setURLSchemeHandler:_handler forURLScheme:stdToNS(kDataUrlScheme)];
_webview = [[WKWebView alloc] initWithFrame:NSZeroRect configuration:configuration];
+#if 0
if (@available(macOS 13.3, *)) {
_webview.inspectable = config.debug ? YES : NO;
}
+#endif
[_manager addScriptMessageHandler:_handler name:@"external"];
[_webview setNavigationDelegate:_handler];
[_webview setUIDelegate:_handler];
@@ -658,10 +660,12 @@ void *Instance::winId() {
}
void Instance::setOpaqueBg(QColor opaqueBg) {
+#if 0
if (@available(macOS 12.0, *)) {
[_webview setValue: @NO forKey: @"drawsBackground"];
[_webview setUnderPageBackgroundColor:[NSColor clearColor]];
}
+#endif
}
void Instance::resizeToWindow() {

View File

@ -27,7 +27,7 @@
mesa,
libdrm,
libGL,
darwin,
apple-sdk_15,
unstableGitUpdater,
}:
@ -89,26 +89,9 @@ stdenv.mkDerivation {
libdrm
libGL
]
++ lib.optionals stdenv.hostPlatform.isDarwin (
with darwin.apple_sdk.frameworks;
[
Cocoa
AppKit
IOKit
IOSurface
Foundation
AVFoundation
CoreMedia
VideoToolbox
CoreGraphics
CoreVideo
OpenGL
Metal
MetalKit
CoreFoundation
ApplicationServices
]
);
++ lib.optionals stdenv.hostPlatform.isDarwin [
apple-sdk_15
];
passthru.updateScript = unstableGitUpdater { };

View File

@ -41,7 +41,6 @@ telegram-desktop.overrideAttrs (old: rec {
homepage = "https://github.com/TDesktop-x64/tdesktop";
changelog = "https://github.com/TDesktop-x64/tdesktop/releases/tag/v${version}";
maintainers = with maintainers; [ clot27 ];
mainProgram = "telegram-desktop";
broken = stdenv.hostPlatform.isDarwin;
mainProgram = if stdenv.hostPlatform.isLinux then "telegram-desktop" else "Telegram";
};
})

View File

@ -30218,11 +30218,7 @@ with pkgs;
kondo = callPackage ../applications/misc/kondo { };
kotatogram-desktop = callPackage ../applications/networking/instant-messengers/telegram/kotatogram-desktop {
stdenv = if stdenv.hostPlatform.isDarwin
then overrideSDK stdenv "11.0"
else stdenv;
};
kotatogram-desktop = callPackage ../applications/networking/instant-messengers/telegram/kotatogram-desktop { };
kotatogram-desktop-with-webkit = callPackage ../applications/networking/instant-messengers/telegram/kotatogram-desktop/with-webkit.nix { };
@ -32531,7 +32527,7 @@ with pkgs;
telegram-desktop = kdePackages.callPackage ../applications/networking/instant-messengers/telegram/telegram-desktop {
stdenv = if stdenv.hostPlatform.isDarwin
then overrideSDK stdenv "11.0"
then llvmPackages_19.stdenv
else stdenv;
};