feat: implement streamer mode on macOS

This commit is contained in:
AlexeyZavar
2026-03-02 18:28:21 +03:00
parent dfc6718bea
commit 55fb7aeb68
4 changed files with 48 additions and 35 deletions
+1 -1
View File
@@ -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
@@ -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)
{
}
}
@@ -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 <Cocoa/Cocoa.h>
namespace AyuFeatures::StreamerMode::Impl {
namespace {
NSWindow *NativeWindow(QWidget *widget) {
return [reinterpret_cast<NSView*>(widget->window()->winId()) window];
}
} // namespace
void enableHook() {
Core::App().enumerateWindows([&](not_null<Window::Controller*> w) {
NativeWindow(w->widget()).sharingType = NSWindowSharingNone;
});
}
void disableHook() {
Core::App().enumerateWindows([&](not_null<Window::Controller*> w) {
NativeWindow(w->widget()).sharingType = NSWindowSharingReadOnly;
});
}
void hideWidgetWindow(QWidget *widget) {
NativeWindow(widget).sharingType = NSWindowSharingNone;
}
void showWidgetWindow(QWidget *widget) {
NativeWindow(widget).sharingType = NSWindowSharingReadOnly;
}
}
@@ -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(),