Fix stop-auto-read when the system is idle.

This commit is contained in:
John Preston 2020-02-19 20:54:19 +04:00
parent 5b7f7ed70e
commit b5dcd84513
4 changed files with 11 additions and 4 deletions

View File

@ -126,6 +126,7 @@ void Histories::readInboxTill(not_null<HistoryItem*> item) {
void Histories::readInboxTill(not_null<History*> history, MsgId tillId) { void Histories::readInboxTill(not_null<History*> history, MsgId tillId) {
readInboxTill(history, tillId, false); readInboxTill(history, tillId, false);
} }
void Histories::readInboxTill( void Histories::readInboxTill(
not_null<History*> history, not_null<History*> history,
MsgId tillId, MsgId tillId,

View File

@ -674,7 +674,10 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
const auto middle = y + h / 2; const auto middle = y + h / 2;
const auto bottom = y + h; const auto bottom = y + h;
if (_visibleAreaBottom >= bottom) { if (_visibleAreaBottom >= bottom) {
readTill = view->data(); const auto item = view->data();
if (!item->out() && item->unread()) {
readTill = item;
}
} }
if (_visibleAreaBottom >= middle if (_visibleAreaBottom >= middle
&& _visibleAreaTop <= middle) { && _visibleAreaTop <= middle) {
@ -704,7 +707,7 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
} }
p.restore(); p.restore();
if (readTill) { if (readTill && _widget->doWeReadServerHistory()) {
session().data().histories().readInboxTill(readTill); session().data().histories().readInboxTill(readTill);
} }
} }

View File

@ -508,7 +508,7 @@ bool MainWindow::doWeMarkAsRead() {
return false; return false;
} }
updateIsActive(0); updateIsActive(0);
return isActive(); return isActive() && _main->doWeMarkAsRead();
} }
void MainWindow::checkHistoryActivation() { void MainWindow::checkHistoryActivation() {
@ -549,10 +549,12 @@ bool MainWindow::eventFilter(QObject *object, QEvent *e) {
} break; } break;
case QEvent::MouseMove: { case QEvent::MouseMove: {
if (_main && _main->isIdle()) { const auto position = static_cast<QMouseEvent*>(e)->globalPos();
if (_main && _main->isIdle() && _lastMousePosition != position) {
Core::App().updateNonIdle(); Core::App().updateNonIdle();
_main->checkIdleFinish(); _main->checkIdleFinish();
} }
_lastMousePosition = position;
} break; } break;
case QEvent::MouseButtonRelease: { case QEvent::MouseButtonRelease: {

View File

@ -167,6 +167,7 @@ private:
QImage icon16, icon32, icon64, iconbig16, iconbig32, iconbig64; QImage icon16, icon32, icon64, iconbig16, iconbig32, iconbig64;
crl::time _lastTrayClickTime = 0; crl::time _lastTrayClickTime = 0;
QPoint _lastMousePosition;
object_ptr<Window::PasscodeLockWidget> _passcodeLock = { nullptr }; object_ptr<Window::PasscodeLockWidget> _passcodeLock = { nullptr };
object_ptr<Intro::Widget> _intro = { nullptr }; object_ptr<Intro::Widget> _intro = { nullptr };