Request screen recording permissions on macOS.

This commit is contained in:
John Preston 2021-06-08 17:11:18 +04:00
parent de3ea30d69
commit 054223efe0
7 changed files with 44 additions and 7 deletions

View file

@ -2094,6 +2094,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_group_call_mac_access" = "Telegram Desktop does not have access to system wide keyboard input required for Push to Talk."; "lng_group_call_mac_access" = "Telegram Desktop does not have access to system wide keyboard input required for Push to Talk.";
"lng_group_call_mac_input" = "Please allow **Input Monitoring** for Telegram in Privacy Settings."; "lng_group_call_mac_input" = "Please allow **Input Monitoring** for Telegram in Privacy Settings.";
"lng_group_call_mac_accessibility" = "Please allow **Accessibility** for Telegram in Privacy Settings.\n\nApp restart may be required."; "lng_group_call_mac_accessibility" = "Please allow **Accessibility** for Telegram in Privacy Settings.\n\nApp restart may be required.";
"lng_group_call_mac_screencast_access" = "Telegram Desktop does not have access to screen recording required for Screen Sharing.";
"lng_group_call_mac_recording" = "Please allow **Screen Recording** for Telegram in Privacy Settings.";
"lng_group_call_mac_settings" = "Open Settings"; "lng_group_call_mac_settings" = "Open Settings";
"lng_group_call_start_as_header" = "Start Voice Chat as..."; "lng_group_call_start_as_header" = "Start Voice Chat as...";

View file

@ -1052,12 +1052,46 @@ void Panel::refreshTopButton() {
} }
} }
void Panel::screenSharingPrivacyRequest() {
#ifdef Q_OS_MAC
if (!Platform::IsMac10_15OrGreater()) {
return;
}
const auto requestInputMonitoring = Platform::IsMac10_15OrGreater();
_layerBg->showBox(Box([=](not_null<Ui::GenericBox*> box) {
box->addRow(
object_ptr<Ui::FlatLabel>(
box.get(),
rpl::combine(
tr::lng_group_call_mac_screencast_access(),
tr::lng_group_call_mac_recording()
) | rpl::map([](QString a, QString b) {
auto result = Ui::Text::RichLangValue(a);
result.append("\n\n").append(Ui::Text::RichLangValue(b));
return result;
}),
st::groupCallBoxLabel),
style::margins(
st::boxRowPadding.left(),
st::boxPadding.top(),
st::boxRowPadding.right(),
st::boxPadding.bottom()));
box->addButton(tr::lng_group_call_mac_settings(), [=] {
Platform::OpenDesktopCapturePrivacySettings();
});
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
}));
#endif // Q_OS_MAC
}
void Panel::chooseShareScreenSource() { void Panel::chooseShareScreenSource() {
if (_call->emitShareScreenError()) { if (_call->emitShareScreenError()) {
return; return;
} }
const auto choose = [=] { const auto choose = [=] {
if (const auto source = Webrtc::UniqueDesktopCaptureSource()) { if (!Webrtc::DesktopCaptureAllowed()) {
screenSharingPrivacyRequest();
} else if (const auto source = Webrtc::UniqueDesktopCaptureSource()) {
if (_call->isSharingScreen()) { if (_call->isSharingScreen()) {
_call->toggleScreenSharing(std::nullopt); _call->toggleScreenSharing(std::nullopt);
} else { } else {

View file

@ -134,6 +134,7 @@ private:
void showMainMenu(); void showMainMenu();
void chooseJoinAs(); void chooseJoinAs();
void chooseShareScreenSource(); void chooseShareScreenSource();
void screenSharingPrivacyRequest();
void addMembers(); void addMembers();
void kickParticipant(not_null<PeerData*> participantPeer); void kickParticipant(not_null<PeerData*> participantPeer);
void kickParticipantSure(not_null<PeerData*> participantPeer); void kickParticipantSure(not_null<PeerData*> participantPeer);

View file

@ -298,9 +298,9 @@ void ChooseSourceProcess::activate() {
void ChooseSourceProcess::setupPanel() { void ChooseSourceProcess::setupPanel() {
#ifndef Q_OS_LINUX #ifndef Q_OS_LINUX
_window->setAttribute(Qt::WA_OpaquePaintEvent); //_window->setAttribute(Qt::WA_OpaquePaintEvent);
#endif // Q_OS_LINUX #endif // Q_OS_LINUX
_window->setAttribute(Qt::WA_NoSystemBackground); //_window->setAttribute(Qt::WA_NoSystemBackground);
_window->setWindowIcon(QIcon( _window->setWindowIcon(QIcon(
QPixmap::fromImage(Image::Empty()->original(), Qt::ColorOnly))); QPixmap::fromImage(Image::Empty()->original(), Qt::ColorOnly)));
@ -322,7 +322,7 @@ void ChooseSourceProcess::setupPanel() {
+ (st::desktopCaptureSourceSize.height() / 2) + (st::desktopCaptureSourceSize.height() / 2)
+ bottomHeight; + bottomHeight;
_window->setFixedSize({ width, height }); _window->setFixedSize({ width, height });
_window->setWindowFlag(Qt::WindowStaysOnTopHint); _window->setStaysOnTop(true);
_window->body()->paintRequest( _window->body()->paintRequest(
) | rpl::start_with_next([=](QRect clip) { ) | rpl::start_with_next([=](QRect clip) {

@ -1 +1 @@
Subproject commit 43e10864ac0b636457911c63ecd3e2429d38d339 Subproject commit 846282f36fc4270a1d6b926163d104b40800e781

@ -1 +1 @@
Subproject commit 7bc9e1261498af07475f4bac0d8bcd8721202177 Subproject commit 1c004580ebb1380d3cb19fadb017f416c85a0eef

@ -1 +1 @@
Subproject commit 539b9b51c730900ce724d2e329f3a877f2fcba30 Subproject commit 8926a5bbcbfa598f43be6c5a4b4762c2dd74b7e6