From a4212cc865189bc71d2716cb512b997c30c2d96c Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 15 Nov 2024 18:28:35 +0400 Subject: [PATCH] Fix point state detection on media messages. --- .../history/view/history_view_message.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 0dae7fbf0..d67787ae6 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -2120,6 +2120,7 @@ PointState Message::pointState(QPoint point) const { // Entry page is always a bubble bottom. auto mediaOnBottom = (mediaDisplayed && media->isBubbleBottom()) || check || (entry/* && entry->isBubbleBottom()*/); + auto mediaOnTop = (mediaDisplayed && media->isBubbleTop()) || (entry && entry->isBubbleTop()); if (item->repliesAreComments() || item->externalReply()) { g.setHeight(g.height() - st::historyCommentsButtonHeight); @@ -2160,11 +2161,18 @@ PointState Message::pointState(QPoint point) const { trect.setHeight(trect.height() - entryHeight); } - auto mediaHeight = media->height(); - auto mediaLeft = trect.x() - st::msgPadding.left(); - auto mediaTop = (trect.y() + trect.height() - mediaHeight); - - if (point.y() >= mediaTop && point.y() < mediaTop + mediaHeight) { + const auto mediaHeight = mediaDisplayed ? media->height() : 0; + const auto mediaLeft = trect.x() - st::msgPadding.left(); + const auto mediaTop = (!mediaDisplayed || _invertMedia) + ? (trect.y() + (mediaOnTop ? 0 : st::mediaInBubbleSkip)) + : (trect.y() + trect.height() - mediaHeight); + if (mediaDisplayed && _invertMedia) { + trect.setY(mediaTop + + mediaHeight + + (mediaOnBottom ? 0 : st::mediaInBubbleSkip)); + } + if (point.y() >= mediaTop + && point.y() < mediaTop + mediaHeight) { return media->pointState(point - QPoint(mediaLeft, mediaTop)); } }