Skip to content

Commit

Permalink
Fix incorrect window activation on message jump.
Browse files Browse the repository at this point in the history
Fixes #28275.
  • Loading branch information
john-preston committed Aug 16, 2024
1 parent f3dca6e commit 62a20ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions Telegram/SourceFiles/mainwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,9 @@ void MainWidget::showHistory(
const SectionShow &params,
MsgId showAtMsgId) {
if (peerId && _controller->window().locked()) {
if (params.activation != anim::activation::background) {
_controller->window().activate();
}
return;
} else if (auto peer = session().data().peerLoaded(peerId)) {
if (peer->migrateTo()) {
Expand All @@ -1317,6 +1320,9 @@ void MainWidget::showHistory(
&& _mainSection
&& _mainSection->showMessage(peerId, params, showAtMsgId)) {
session().data().hideShownSpoilers();
if (params.activation != anim::activation::background) {
_controller->window().activate();
}
return;
} else if (showHistoryInDifferentWindow(peerId, params, showAtMsgId)) {
return;
Expand Down Expand Up @@ -1502,16 +1508,26 @@ void MainWidget::showMessage(
if (!v::is_null(params.origin)) {
if (_mainSection) {
if (_mainSection->showMessage(peerId, params, itemId)) {
if (params.activation != anim::activation::background) {
_controller->window().activate();
}
return;
}
} 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);
return;
}
}
if (const auto topic = item->topic()) {
_controller->showTopic(topic, item->id, params);
if (params.activation != anim::activation::background) {
_controller->window().activate();
}
} else {
// showPeerHistory may be redirected to different window,
// so we don't call activate() on current controller's window.
_controller->showPeerHistory(
item->history(),
params,
Expand Down
6 changes: 3 additions & 3 deletions Telegram/SourceFiles/window/window_session_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2487,12 +2487,12 @@ void SessionController::showMessage(
std::make_shared<HistoryView::ScheduledMemento>(
item->history()),
params);
if (params.activation != anim::activation::background) {
controller->window().activate();
}
} else {
controller->content()->showMessage(item, params);
}
if (params.activation != anim::activation::background) {
controller->window().activate();
}
});
}

Expand Down

0 comments on commit 62a20ba

Please sign in to comment.