From b5dcd845135e35b65bb257c4715e430de70fdfd9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 19 Feb 2020 20:54:19 +0400 Subject: [PATCH] Fix stop-auto-read when the system is idle. --- Telegram/SourceFiles/data/data_histories.cpp | 1 + Telegram/SourceFiles/history/history_inner_widget.cpp | 7 +++++-- Telegram/SourceFiles/mainwindow.cpp | 6 ++++-- Telegram/SourceFiles/mainwindow.h | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/data/data_histories.cpp b/Telegram/SourceFiles/data/data_histories.cpp index 5e06e4367..c3e945da5 100644 --- a/Telegram/SourceFiles/data/data_histories.cpp +++ b/Telegram/SourceFiles/data/data_histories.cpp @@ -126,6 +126,7 @@ void Histories::readInboxTill(not_null item) { void Histories::readInboxTill(not_null history, MsgId tillId) { readInboxTill(history, tillId, false); } + void Histories::readInboxTill( not_null history, MsgId tillId, diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 815bb3175..3b195f368 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -674,7 +674,10 @@ void HistoryInner::paintEvent(QPaintEvent *e) { const auto middle = y + h / 2; const auto bottom = y + h; if (_visibleAreaBottom >= bottom) { - readTill = view->data(); + const auto item = view->data(); + if (!item->out() && item->unread()) { + readTill = item; + } } if (_visibleAreaBottom >= middle && _visibleAreaTop <= middle) { @@ -704,7 +707,7 @@ void HistoryInner::paintEvent(QPaintEvent *e) { } p.restore(); - if (readTill) { + if (readTill && _widget->doWeReadServerHistory()) { session().data().histories().readInboxTill(readTill); } } diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 652ae6763..6df70cd0d 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -508,7 +508,7 @@ bool MainWindow::doWeMarkAsRead() { return false; } updateIsActive(0); - return isActive(); + return isActive() && _main->doWeMarkAsRead(); } void MainWindow::checkHistoryActivation() { @@ -549,10 +549,12 @@ bool MainWindow::eventFilter(QObject *object, QEvent *e) { } break; case QEvent::MouseMove: { - if (_main && _main->isIdle()) { + const auto position = static_cast(e)->globalPos(); + if (_main && _main->isIdle() && _lastMousePosition != position) { Core::App().updateNonIdle(); _main->checkIdleFinish(); } + _lastMousePosition = position; } break; case QEvent::MouseButtonRelease: { diff --git a/Telegram/SourceFiles/mainwindow.h b/Telegram/SourceFiles/mainwindow.h index 076ff1b23..d9b6fae0c 100644 --- a/Telegram/SourceFiles/mainwindow.h +++ b/Telegram/SourceFiles/mainwindow.h @@ -167,6 +167,7 @@ private: QImage icon16, icon32, icon64, iconbig16, iconbig32, iconbig64; crl::time _lastTrayClickTime = 0; + QPoint _lastMousePosition; object_ptr _passcodeLock = { nullptr }; object_ptr _intro = { nullptr };