From 55fb7aeb680c6470725c6523359da1e769513972 Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Mon, 2 Mar 2026 18:28:21 +0300 Subject: [PATCH] feat: implement streamer mode on macOS --- Telegram/CMakeLists.txt | 2 +- .../platform/streamer_mode_mac.cpp | 32 ------------- .../platform/streamer_mode_mac.mm | 45 +++++++++++++++++++ .../ayu/ui/settings/settings_appearance.cpp | 4 +- 4 files changed, 48 insertions(+), 35 deletions(-) delete mode 100644 Telegram/SourceFiles/ayu/features/streamer_mode/platform/streamer_mode_mac.cpp create mode 100644 Telegram/SourceFiles/ayu/features/streamer_mode/platform/streamer_mode_mac.mm diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 226fa3ad39..b85c0a62d2 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -208,7 +208,7 @@ set(ayugram_files ayu/features/streamer_mode/platform/streamer_mode_win.h ayu/features/streamer_mode/platform/streamer_mode_linux.cpp ayu/features/streamer_mode/platform/streamer_mode_linux.h - ayu/features/streamer_mode/platform/streamer_mode_mac.cpp + ayu/features/streamer_mode/platform/streamer_mode_mac.mm ayu/features/streamer_mode/platform/streamer_mode_mac.h ayu/features/streamer_mode/streamer_mode.cpp ayu/features/streamer_mode/streamer_mode.h diff --git a/Telegram/SourceFiles/ayu/features/streamer_mode/platform/streamer_mode_mac.cpp b/Telegram/SourceFiles/ayu/features/streamer_mode/platform/streamer_mode_mac.cpp deleted file mode 100644 index 018450d34f..0000000000 --- a/Telegram/SourceFiles/ayu/features/streamer_mode/platform/streamer_mode_mac.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// This is the source code of AyuGram for Desktop. -// -// We do not and cannot prevent the use of our code, -// but be respectful and credit the original author. -// -// Copyright @Radolyn, 2026 - -#include "ayu/features/streamer_mode/platform/streamer_mode_mac.h" - -#include "window/window_controller.h" - -namespace AyuFeatures::StreamerMode::Impl { - -void enableHook() { - -} - -void disableHook() { - -} - -void hideWidgetWindow(QWidget *widget) -{ - -} - -void showWidgetWindow(QWidget *widget) -{ - -} - -} diff --git a/Telegram/SourceFiles/ayu/features/streamer_mode/platform/streamer_mode_mac.mm b/Telegram/SourceFiles/ayu/features/streamer_mode/platform/streamer_mode_mac.mm new file mode 100644 index 0000000000..a853dcafcf --- /dev/null +++ b/Telegram/SourceFiles/ayu/features/streamer_mode/platform/streamer_mode_mac.mm @@ -0,0 +1,45 @@ +// This is the source code of AyuGram for Desktop. +// +// We do not and cannot prevent the use of our code, +// but be respectful and credit the original author. +// +// Copyright @Radolyn, 2026 + +#include "ayu/features/streamer_mode/platform/streamer_mode_mac.h" + +#include "core/application.h" +#include "window/window_controller.h" + +#include + +namespace AyuFeatures::StreamerMode::Impl { + +namespace { + +NSWindow *NativeWindow(QWidget *widget) { + return [reinterpret_cast(widget->window()->winId()) window]; +} + +} // namespace + +void enableHook() { + Core::App().enumerateWindows([&](not_null w) { + NativeWindow(w->widget()).sharingType = NSWindowSharingNone; + }); +} + +void disableHook() { + Core::App().enumerateWindows([&](not_null w) { + NativeWindow(w->widget()).sharingType = NSWindowSharingReadOnly; + }); +} + +void hideWidgetWindow(QWidget *widget) { + NativeWindow(widget).sharingType = NSWindowSharingNone; +} + +void showWidgetWindow(QWidget *widget) { + NativeWindow(widget).sharingType = NSWindowSharingReadOnly; +} + +} diff --git a/Telegram/SourceFiles/ayu/ui/settings/settings_appearance.cpp b/Telegram/SourceFiles/ayu/ui/settings/settings_appearance.cpp index 139838a582..4ce914ca13 100644 --- a/Telegram/SourceFiles/ayu/ui/settings/settings_appearance.cpp +++ b/Telegram/SourceFiles/ayu/ui/settings/settings_appearance.cpp @@ -430,7 +430,7 @@ void BuildTrayElements(SectionBuilder &builder, AyuSectionBuilder &ayu) { .keywords = { u"ghost"_q, u"tray"_q }, }); -#ifdef WIN32 +#if defined Q_OS_WIN || defined Q_OS_MAC ayu.addSettingToggle({ .id = u"ayu/streamerToggleInTray"_q, .title = tr::ayu_EnableStreamerModeTray(), @@ -533,7 +533,7 @@ void BuildDrawerElements(SectionBuilder &builder, AyuSectionBuilder &ayu) { .icon = { &st::ayuGhostIcon }, }); -#ifdef WIN32 +#if defined Q_OS_WIN || defined Q_OS_MAC ayu.addSettingToggle({ .id = u"ayu/streamerToggleInDrawer"_q, .title = tr::ayu_StreamerModeToggle(),