Fix point state detection on media messages.

This commit is contained in:
John Preston 2024-11-15 18:28:35 +04:00
parent 0445f7d6e8
commit a4212cc865

View file

@ -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));
}
}