Commit 96c0e7ff authored by Ilya Fedin's avatar Ilya Fedin
Browse files

telegram-desktop: port to new darwin SDK handling

parent 85b023ca
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@
  };

  patches = [
    ./macos.patch
    ./macos-opengl.patch
    ./macos-qt5.patch
    (fetchpatch {
+0 −171
Original line number Diff line number Diff line
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
+4 −46
Original line number Diff line number Diff line
@@ -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:
+0 −145
Original line number Diff line number Diff line
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() {
+4 −21
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@
  mesa,
  libdrm,
  libGL,
  darwin,
  apple-sdk_15,
  unstableGitUpdater,
}:

@@ -102,26 +102,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 { };

Loading