Fix incorrect window activation on message jump.

Fixes #28275.
This commit is contained in:
John Preston 2024-08-16 10:57:30 +02:00
parent f3dca6efb7
commit 62a20ba975
2 changed files with 19 additions and 3 deletions

View file

@ -1295,6 +1295,9 @@ void MainWidget::showHistory(
const SectionShow &params, const SectionShow &params,
MsgId showAtMsgId) { MsgId showAtMsgId) {
if (peerId && _controller->window().locked()) { if (peerId && _controller->window().locked()) {
if (params.activation != anim::activation::background) {
_controller->window().activate();
}
return; return;
} else if (auto peer = session().data().peerLoaded(peerId)) { } else if (auto peer = session().data().peerLoaded(peerId)) {
if (peer->migrateTo()) { if (peer->migrateTo()) {
@ -1317,6 +1320,9 @@ void MainWidget::showHistory(
&& _mainSection && _mainSection
&& _mainSection->showMessage(peerId, params, showAtMsgId)) { && _mainSection->showMessage(peerId, params, showAtMsgId)) {
session().data().hideShownSpoilers(); session().data().hideShownSpoilers();
if (params.activation != anim::activation::background) {
_controller->window().activate();
}
return; return;
} else if (showHistoryInDifferentWindow(peerId, params, showAtMsgId)) { } else if (showHistoryInDifferentWindow(peerId, params, showAtMsgId)) {
return; return;
@ -1502,16 +1508,26 @@ void MainWidget::showMessage(
if (!v::is_null(params.origin)) { if (!v::is_null(params.origin)) {
if (_mainSection) { if (_mainSection) {
if (_mainSection->showMessage(peerId, params, itemId)) { if (_mainSection->showMessage(peerId, params, itemId)) {
if (params.activation != anim::activation::background) {
_controller->window().activate();
}
return; return;
} }
} else if (_history->peer() == item->history()->peer) { } else if (_history->peer() == item->history()->peer) {
// showHistory may be redirected to different window,
// so we don't call activate() on current controller's window.
showHistory(peerId, params, itemId); showHistory(peerId, params, itemId);
return; return;
} }
} }
if (const auto topic = item->topic()) { if (const auto topic = item->topic()) {
_controller->showTopic(topic, item->id, params); _controller->showTopic(topic, item->id, params);
if (params.activation != anim::activation::background) {
_controller->window().activate();
}
} else { } else {
// showPeerHistory may be redirected to different window,
// so we don't call activate() on current controller's window.
_controller->showPeerHistory( _controller->showPeerHistory(
item->history(), item->history(),
params, params,

View file

@ -2487,12 +2487,12 @@ void SessionController::showMessage(
std::make_shared<HistoryView::ScheduledMemento>( std::make_shared<HistoryView::ScheduledMemento>(
item->history()), item->history()),
params); params);
if (params.activation != anim::activation::background) {
controller->window().activate();
}
} else { } else {
controller->content()->showMessage(item, params); controller->content()->showMessage(item, params);
} }
if (params.activation != anim::activation::background) {
controller->window().activate();
}
}); });
} }