From a851bebc75ffb08d469aea55d5c7084ddf79645e Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Tue, 2 Jul 2024 22:06:56 +0300 Subject: [PATCH] fix: a bunch of useful fixes --- Telegram/SourceFiles/apiwrap.cpp | 19 ++++++++++++------- .../streamer_mode/streamer_mode_windows.cpp | 8 ++++++++ .../ayu/utils/telegram_helpers.cpp | 6 +++--- .../SourceFiles/ayu/utils/telegram_helpers.h | 2 +- .../SourceFiles/boxes/sticker_set_box.cpp | 18 ++++++++++++++++++ Telegram/SourceFiles/core/application.cpp | 8 ++++++++ Telegram/SourceFiles/core/application.h | 5 +++-- Telegram/SourceFiles/core/launcher.cpp | 2 +- .../info/profile/info_profile_actions.cpp | 7 +++++-- .../SourceFiles/window/window_peer_menu.cpp | 2 +- 10 files changed, 60 insertions(+), 17 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 8a2fc0de7a9d68..9e465962bfb9ae 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -1352,27 +1352,30 @@ void ApiWrap::migrateFail(not_null peer, const QString &error) { void ApiWrap::markContentsRead( const base::flat_set> &items) { + const auto settings = &AyuSettings::getInstance(); + auto markedIds = QVector(); auto channelMarkedIds = base::flat_map< not_null, QVector>(); markedIds.reserve(items.size()); for (const auto &item : items) { + const auto passthrough = (item->isUnreadMention() || item->hasUnreadReaction()) && !item->isUnreadMedia(); + if (!item->markContentsRead(true) || !item->isRegular()) { continue; } + + if (!settings->sendReadMessages && !passthrough) { + continue; + } + if (const auto channel = item->history()->peer->asChannel()) { channelMarkedIds[channel].push_back(MTP_int(item->id)); } else { markedIds.push_back(MTP_int(item->id)); } } - - const auto settings = &AyuSettings::getInstance(); - if (!settings->sendReadMessages) { - return; - } - if (!markedIds.isEmpty()) { request(MTPmessages_ReadMessageContents( MTP_vector(markedIds) @@ -1389,12 +1392,14 @@ void ApiWrap::markContentsRead( } void ApiWrap::markContentsRead(not_null item) { + const auto passthrough = (item->isUnreadMention() || item->hasUnreadReaction()) && !item->isUnreadMedia(); + if (!item->markContentsRead(true) || !item->isRegular()) { return; } const auto settings = &AyuSettings::getInstance(); - if (!settings->sendReadMessages) { + if (!settings->sendReadMessages && !passthrough) { return; } diff --git a/Telegram/SourceFiles/ayu/features/streamer_mode/streamer_mode_windows.cpp b/Telegram/SourceFiles/ayu/features/streamer_mode/streamer_mode_windows.cpp index f389797d398ecd..600394fa6bf325 100644 --- a/Telegram/SourceFiles/ayu/features/streamer_mode/streamer_mode_windows.cpp +++ b/Telegram/SourceFiles/ayu/features/streamer_mode/streamer_mode_windows.cpp @@ -24,6 +24,10 @@ void enable() { auto handle = Core::App().activeWindow()->widget()->psHwnd(); SetWindowDisplayAffinity(handle, WDA_EXCLUDEFROMCAPTURE); + Core::App().enumerateWindows([&](not_null w) { + SetWindowDisplayAffinity(w->widget()->psHwnd(), WDA_EXCLUDEFROMCAPTURE); + }); + isEnabledVal = true; } @@ -31,6 +35,10 @@ void disable() { auto handle = Core::App().activeWindow()->widget()->psHwnd(); SetWindowDisplayAffinity(handle, WDA_NONE); + Core::App().enumerateWindows([&](not_null w) { + SetWindowDisplayAffinity(w->widget()->psHwnd(), WDA_NONE); + }); + isEnabledVal = false; } diff --git a/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp b/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp index 62eb2787bf3fd3..5567ab8d2c2878 100644 --- a/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp +++ b/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp @@ -517,10 +517,10 @@ QString getMediaDC(not_null message) { return {}; } -QString getUserDC(not_null user) { - if (user->hasUserpic()) { +QString getPeerDC(not_null peer) { + if (peer->hasUserpic()) { const auto dc = v::match( - user->userpicLocation().file().data, + peer->userpicLocation().file().data, [&](const StorageFileLocation &data) { return data.dcId(); diff --git a/Telegram/SourceFiles/ayu/utils/telegram_helpers.h b/Telegram/SourceFiles/ayu/utils/telegram_helpers.h index f026f35421d423..e416b1f93e2d5a 100644 --- a/Telegram/SourceFiles/ayu/utils/telegram_helpers.h +++ b/Telegram/SourceFiles/ayu/utils/telegram_helpers.h @@ -43,7 +43,7 @@ QString getMediaName(not_null message); QString getMediaResolution(not_null message); QString getMediaDC(not_null message); -QString getUserDC(not_null user); +QString getPeerDC(not_null peer); int getScheduleTime(int64 sumSize); diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index f3c02c2d1ea635..0a98761ffae62d 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -63,6 +63,7 @@ For license and copyright information please follow this link: // AyuGram includes #include "ayu/utils/telegram_helpers.h" +#include "styles/style_ayu_styles.h" #include "window/window_session_controller.h" #include "data/data_user.h" @@ -1392,6 +1393,18 @@ void StickerSetBox::Inner::paintSticker( (_singleSize.width() - size.width()) / 2, (_singleSize.height() - size.height()) / 2); auto lottieFrame = QImage(); + + if (sticker->setType == Data::StickersType::Stickers) { + QPainterPath path; + path.addRoundedRect(QRectF(ppos, size), st::stickerRoundingSize, st::stickerRoundingSize); + + p.save(); + + p.setRenderHint(QPainter::Antialiasing, true); + p.setClipPath(path); + p.setRenderHint(QPainter::Antialiasing, false); + } + if (element.emoji) { element.emoji->paint(p, { .textColor = st::windowFg->c, @@ -1425,6 +1438,11 @@ void StickerSetBox::Inner::paintSticker( QRect(ppos, size), _pathGradient.get()); } + + if (sticker->setType == Data::StickersType::Stickers) { + p.restore(); + } + if (premium) { _premiumMark.paint( p, diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 372aa8d21728ef..db9a85b88d3ef6 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -109,6 +109,10 @@ For license and copyright information please follow this link: #include #include +// AyuGram includes +#include "ayu/features/streamer_mode/streamer_mode.h" + + namespace Core { namespace { @@ -505,6 +509,10 @@ void Application::processCreatedWindow( not_null window) { window->openInMediaViewRequests( ) | rpl::start_to_stream(_openInMediaViewRequests, window->lifetime()); + + if (AyuFeatures::StreamerMode::isEnabled()) { + AyuFeatures::StreamerMode::hideWidgetWindow(window->widget()); + } } void Application::startMediaView() { diff --git a/Telegram/SourceFiles/core/application.h b/Telegram/SourceFiles/core/application.h index 77fe09b7ff00d2..28975d47468ba1 100644 --- a/Telegram/SourceFiles/core/application.h +++ b/Telegram/SourceFiles/core/application.h @@ -334,6 +334,9 @@ class Application final : public QObject { void preventOrInvoke(Fn &&callback); + void enumerateWindows( + Fn)> callback) const; + // Global runtime variables. void setScreenIsLocked(bool locked); bool screenIsLocked() const; @@ -364,8 +367,6 @@ class Application final : public QObject { void updateWindowTitles(); void setLastActiveWindow(Window::Controller *window); void showAccount(not_null account); - void enumerateWindows( - Fn)> callback) const; void processCreatedWindow(not_null window); void refreshApplicationIcon(Main::Session *session); diff --git a/Telegram/SourceFiles/core/launcher.cpp b/Telegram/SourceFiles/core/launcher.cpp index 50af389020a11e..518b7d05baa4b9 100644 --- a/Telegram/SourceFiles/core/launcher.cpp +++ b/Telegram/SourceFiles/core/launcher.cpp @@ -516,7 +516,7 @@ void Launcher::processArguments() { { "-tosettings" , KeyFormat::NoValues }, { "-startintray" , KeyFormat::NoValues }, { "-quit" , KeyFormat::NoValues }, - { "-ghost" , KeyFormat::NoValues }, + { "-ghost" , KeyFormat::NoValues }, { "-sendpath" , KeyFormat::AllLeftValues }, { "-workdir" , KeyFormat::OneValue }, { "--" , KeyFormat::OneValue }, diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index ea1b66983bab1a..5996f889e63763 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -1156,7 +1156,7 @@ object_ptr DetailsFiller::setupInfo() { } if (settings->showPeerId != 0) { - const auto dataCenter = getUserDC(user); + const auto dataCenter = getPeerDC(_peer); const auto idLabel = dataCenter.isEmpty() ? QString("ID") : dataCenter; auto idDrawableText = IDValue( @@ -1277,6 +1277,9 @@ object_ptr DetailsFiller::setupInfo() { } if (settings->showPeerId != 0 && !_topic) { + const auto dataCenter = getPeerDC(_peer); + const auto idLabel = dataCenter.isEmpty() ? QString("ID") : dataCenter; + auto idDrawableText = IDValue( _peer ) | rpl::map([](TextWithEntities &&text) @@ -1284,7 +1287,7 @@ object_ptr DetailsFiller::setupInfo() { return Ui::Text::Code(text.text); }); auto idInfo = addInfoOneLine( - rpl::single(QString("ID")), + idLabel, std::move(idDrawableText), tr::ayu_ContextCopyID(tr::now) ); diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index f05e40fa1e6cda..e4b892a3e3d4d2 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -1138,7 +1138,7 @@ void Filler::addJumpToBeginning() { } else if (group && !chat) { jumpToDate(controller->session().data().history(group), showPeerHistory); } else if (chat && !topic) { - if (!chat->migrateFrom()) { + if (!chat->migrateFrom() && chat->availableMinId() == 1) { showPeerHistory(chat, 1); } else { jumpToDate(controller->session().data().history(chat), showPeerHistory);