From b6a31979f2c117852104f25e095f7c5d267787de Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 7 Mar 2025 17:50:09 +0400 Subject: [PATCH] Add the same enter/leave check to ListWidget. --- .../SourceFiles/history/view/history_view_list_widget.cpp | 8 ++++++++ .../SourceFiles/history/view/history_view_list_widget.h | 1 + 2 files changed, 9 insertions(+) diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 10cea51b4..7a2d62cd9 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -2954,6 +2954,7 @@ void ListWidget::mousePressEvent(QMouseEvent *e) { e->accept(); return; // ignore mouse press, that was hiding context menu } + _mouseActive = true; mouseActionStart(e->globalPos(), e->button()); } @@ -3161,6 +3162,7 @@ void ListWidget::mouseMoveEvent(QMouseEvent *e) { mouseReleaseEvent(e); } if (reallyMoved) { + _mouseActive = true; lastGlobalPosition = e->globalPos(); if (!buttonsPressed || (_scrollDateLink @@ -3191,6 +3193,7 @@ rpl::producer ListWidget::touchMaybeSelectingValue() const { } void ListWidget::enterEventHook(QEnterEvent *e) { + _mouseActive = true; mouseActionUpdate(QCursor::pos()); return TWidget::enterEventHook(e); } @@ -3211,6 +3214,7 @@ void ListWidget::leaveEventHook(QEvent *e) { _cursor = style::cur_default; setCursor(_cursor); } + _mouseActive = false; return TWidget::leaveEventHook(e); } @@ -3643,6 +3647,10 @@ int ListWidget::SelectionViewOffset( void ListWidget::mouseActionUpdate() { + if (!_mouseActive && !window()->isActiveWindow()) { + return; + } + auto mousePosition = mapFromGlobal(_mousePosition); auto point = QPoint( std::clamp(mousePosition.x(), 0, width()), diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.h b/Telegram/SourceFiles/history/view/history_view_list_widget.h index a21cea06e..71db29cd5 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.h +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.h @@ -816,6 +816,7 @@ private: uint16 _mouseTextSymbol = 0; bool _pressWasInactive = false; bool _overSenderUserpic = false; + bool _mouseActive = false; bool _selectEnabled = false; HistoryItem *_selectedTextItem = nullptr;