From 6c68bacaef8a7cb4246d2b05d188cf6bb61348b1 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 30 Mar 2025 23:14:57 +0300 Subject: [PATCH] Added ability to open chat in window from Ctrl+click on notifications. --- .../window/notifications_manager.cpp | 18 +++++++++++++++--- .../SourceFiles/window/notifications_manager.h | 3 ++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index eee26caece..ea10b6a63d 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/notifications_manager.h" #include "base/options.h" +#include "base/qt/qt_key_modifiers.h" #include "platform/platform_notifications_manager.h" #include "window/notifications_manager_default.h" #include "media/audio/media_audio_track.h" @@ -1146,7 +1147,8 @@ void Manager::notificationActivated( window->widget()->setInnerFocus(); system()->clearAll(); } else { - openNotificationMessage(history, id.msgId); + const auto openSeparated = base::IsCtrlPressed(); + openNotificationMessage(history, id.msgId, openSeparated); } onAfterNotificationActivated(id, window); } @@ -1155,7 +1157,8 @@ void Manager::notificationActivated( void Manager::openNotificationMessage( not_null history, - MsgId messageId) { + MsgId messageId, + bool openSeparated) { const auto item = history->owner().message(history->peer, messageId); const auto openExactlyMessage = !history->peer->isBroadcast() && item @@ -1163,10 +1166,19 @@ void Manager::openNotificationMessage( && (item->out() || (item->mentionsMe() && !history->peer->isUser())); const auto topic = item ? item->topic() : nullptr; const auto separate = Core::App().separateWindowFor(history->peer); + const auto itemId = openExactlyMessage ? messageId : ShowAtUnreadMsgId; const auto window = separate ? separate->sessionController() + : openSeparated + ? [&] { + const auto window = Core::App().ensureSeparateWindowFor( + topic + ? Window::SeparateId(Window::SeparateType::Forum, history) + : Window::SeparateId(history->peer), + itemId); + return window ? window->sessionController() : nullptr; + }() : history->session().tryResolveWindow(); - const auto itemId = openExactlyMessage ? messageId : ShowAtUnreadMsgId; if (window) { if (topic) { window->showSection( diff --git a/Telegram/SourceFiles/window/notifications_manager.h b/Telegram/SourceFiles/window/notifications_manager.h index 833a79d002..d2561ea5d4 100644 --- a/Telegram/SourceFiles/window/notifications_manager.h +++ b/Telegram/SourceFiles/window/notifications_manager.h @@ -355,7 +355,8 @@ protected: private: void openNotificationMessage( not_null history, - MsgId messageId); + MsgId messageId, + bool openSeparated); const not_null _system;