mirror of
https://github.com/telegramdesktop/tdesktop
synced 2024-12-24 23:42:58 +00:00
Refactored checking of last input while notifications are displayed.
- Removed condition for Windows platform only. - Added smooth hiding of notifications in case video is watched or voice message is recorded. - psUserActionDone() was completely replaced with Core::App().updateNonIdle().
This commit is contained in:
parent
78d00bcf22
commit
3372dfcd3e
@ -233,7 +233,7 @@ bool Application::eventFilter(QObject *object, QEvent *e) {
|
|||||||
case QEvent::MouseButtonPress:
|
case QEvent::MouseButtonPress:
|
||||||
case QEvent::TouchBegin:
|
case QEvent::TouchBegin:
|
||||||
case QEvent::Wheel: {
|
case QEvent::Wheel: {
|
||||||
psUserActionDone();
|
updateNonIdle();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case QEvent::ShortcutOverride: {
|
case QEvent::ShortcutOverride: {
|
||||||
@ -252,7 +252,7 @@ bool Application::eventFilter(QObject *object, QEvent *e) {
|
|||||||
|
|
||||||
case QEvent::ApplicationActivate: {
|
case QEvent::ApplicationActivate: {
|
||||||
if (object == QCoreApplication::instance()) {
|
if (object == QCoreApplication::instance()) {
|
||||||
psUserActionDone();
|
updateNonIdle();
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *e) {
|
|||||||
|
|
||||||
case QEvent::MouseMove: {
|
case QEvent::MouseMove: {
|
||||||
if (_main && _main->isIdle()) {
|
if (_main && _main->isIdle()) {
|
||||||
psUserActionDone();
|
Core::App().updateNonIdle();
|
||||||
_main->checkIdleFinish();
|
_main->checkIdleFinish();
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -193,16 +193,6 @@ void psDeleteDir(const QString &dir) {
|
|||||||
_removeDirectory(dir);
|
_removeDirectory(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
auto _lastUserAction = 0LL;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void psUserActionDone() {
|
|
||||||
_lastUserAction = crl::now();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool psIdleSupported() {
|
bool psIdleSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -446,7 +436,7 @@ bool OpenSystemSettings(SystemSettingsType type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
crl::time LastUserInputTime() {
|
crl::time LastUserInputTime() {
|
||||||
return _lastUserAction;
|
return 0LL;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ThirdParty {
|
namespace ThirdParty {
|
||||||
|
@ -51,7 +51,6 @@ void psWriteDump();
|
|||||||
|
|
||||||
void psDeleteDir(const QString &dir);
|
void psDeleteDir(const QString &dir);
|
||||||
|
|
||||||
void psUserActionDone();
|
|
||||||
bool psIdleSupported();
|
bool psIdleSupported();
|
||||||
|
|
||||||
QStringList psInitLogs();
|
QStringList psInitLogs();
|
||||||
|
@ -52,7 +52,6 @@ void psWriteDump();
|
|||||||
|
|
||||||
void psDeleteDir(const QString &dir);
|
void psDeleteDir(const QString &dir);
|
||||||
|
|
||||||
void psUserActionDone();
|
|
||||||
bool psIdleSupported();
|
bool psIdleSupported();
|
||||||
|
|
||||||
QStringList psInitLogs();
|
QStringList psInitLogs();
|
||||||
|
@ -90,16 +90,6 @@ void psDeleteDir(const QString &dir) {
|
|||||||
objc_deleteDir(dir);
|
objc_deleteDir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
auto _lastUserAction = 0LL;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void psUserActionDone() {
|
|
||||||
_lastUserAction = crl::now();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool psIdleSupported() {
|
bool psIdleSupported() {
|
||||||
return objc_idleSupported();
|
return objc_idleSupported();
|
||||||
}
|
}
|
||||||
@ -267,7 +257,7 @@ bool OpenSystemSettings(SystemSettingsType type) {
|
|||||||
|
|
||||||
crl::time LastUserInputTime() {
|
crl::time LastUserInputTime() {
|
||||||
auto idleTime = 0LL;
|
auto idleTime = 0LL;
|
||||||
return objc_idleTime(idleTime) ? (crl::now() - crl::time(idleTime)) : _lastUserAction;
|
return objc_idleTime(idleTime) ? (crl::now() - crl::time(idleTime)) : 0LL;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
@ -128,17 +128,6 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
crl::time _lastUserAction = 0;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void psUserActionDone() {
|
|
||||||
_lastUserAction = crl::now();
|
|
||||||
EventFilter::getInstance()->setSessionLoggedOff(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool psIdleSupported() {
|
bool psIdleSupported() {
|
||||||
LASTINPUTINFO lii;
|
LASTINPUTINFO lii;
|
||||||
lii.cbSize = sizeof(LASTINPUTINFO);
|
lii.cbSize = sizeof(LASTINPUTINFO);
|
||||||
@ -347,7 +336,7 @@ QString CurrentExecutablePath(int argc, char *argv[]) {
|
|||||||
crl::time LastUserInputTime() {
|
crl::time LastUserInputTime() {
|
||||||
LASTINPUTINFO lii;
|
LASTINPUTINFO lii;
|
||||||
lii.cbSize = sizeof(LASTINPUTINFO);
|
lii.cbSize = sizeof(LASTINPUTINFO);
|
||||||
return GetLastInputInfo(&lii) ? (crl::now() + lii.dwTime - GetTickCount()) : _lastUserAction;
|
return GetLastInputInfo(&lii) ? (crl::now() + lii.dwTime - GetTickCount()) : 0LL;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -59,7 +59,6 @@ void psWriteDump();
|
|||||||
|
|
||||||
void psDeleteDir(const QString &dir);
|
void psDeleteDir(const QString &dir);
|
||||||
|
|
||||||
void psUserActionDone();
|
|
||||||
bool psIdleSupported();
|
bool psIdleSupported();
|
||||||
|
|
||||||
QStringList psInitLogs();
|
QStringList psInitLogs();
|
||||||
|
@ -288,7 +288,7 @@ void MainWindow::init() {
|
|||||||
void MainWindow::handleStateChanged(Qt::WindowState state) {
|
void MainWindow::handleStateChanged(Qt::WindowState state) {
|
||||||
stateChangedHook(state);
|
stateChangedHook(state);
|
||||||
updateIsActive((state == Qt::WindowMinimized) ? Global::OfflineBlurTimeout() : Global::OnlineFocusTimeout());
|
updateIsActive((state == Qt::WindowMinimized) ? Global::OfflineBlurTimeout() : Global::OnlineFocusTimeout());
|
||||||
psUserActionDone();
|
Core::App().updateNonIdle();
|
||||||
if (state == Qt::WindowMinimized && Global::WorkMode().value() == dbiwmTrayOnly) {
|
if (state == Qt::WindowMinimized && Global::WorkMode().value() == dbiwmTrayOnly) {
|
||||||
minimizeToTray();
|
minimizeToTray();
|
||||||
}
|
}
|
||||||
|
@ -505,9 +505,7 @@ Notification::Notification(
|
|||||||
int shift,
|
int shift,
|
||||||
Direction shiftDirection)
|
Direction shiftDirection)
|
||||||
: Widget(manager, startPosition, shift, shiftDirection)
|
: Widget(manager, startPosition, shift, shiftDirection)
|
||||||
#ifdef Q_OS_WIN
|
, _started(crl::now())
|
||||||
, _started(GetTickCount())
|
|
||||||
#endif // Q_OS_WIN
|
|
||||||
, _history(history)
|
, _history(history)
|
||||||
, _peer(peer)
|
, _peer(peer)
|
||||||
, _author(author)
|
, _author(author)
|
||||||
@ -588,14 +586,7 @@ void Notification::prepareActionsCache() {
|
|||||||
bool Notification::checkLastInput(bool hasReplyingNotifications) {
|
bool Notification::checkLastInput(bool hasReplyingNotifications) {
|
||||||
if (!_waitingForInput) return true;
|
if (!_waitingForInput) return true;
|
||||||
|
|
||||||
auto wasUserInput = true; // TODO
|
if (Core::App().lastNonIdleTime() > _started) {
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
LASTINPUTINFO lii;
|
|
||||||
lii.cbSize = sizeof(LASTINPUTINFO);
|
|
||||||
BOOL res = GetLastInputInfo(&lii);
|
|
||||||
wasUserInput = (!res || lii.dwTime >= _started);
|
|
||||||
#endif // Q_OS_WIN
|
|
||||||
if (wasUserInput) {
|
|
||||||
_waitingForInput = false;
|
_waitingForInput = false;
|
||||||
if (!hasReplyingNotifications) {
|
if (!hasReplyingNotifications) {
|
||||||
_hideTimer.start(st::notifyWaitLongHide);
|
_hideTimer.start(st::notifyWaitLongHide);
|
||||||
|
@ -216,9 +216,7 @@ private:
|
|||||||
Animation a_actionsOpacity;
|
Animation a_actionsOpacity;
|
||||||
QPixmap _buttonsCache;
|
QPixmap _buttonsCache;
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
crl::time _started;
|
crl::time _started;
|
||||||
#endif // Q_OS_WIN
|
|
||||||
|
|
||||||
History *_history;
|
History *_history;
|
||||||
PeerData *_peer;
|
PeerData *_peer;
|
||||||
|
Loading…
Reference in New Issue
Block a user