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::TouchBegin:
|
||||
case QEvent::Wheel: {
|
||||
psUserActionDone();
|
||||
updateNonIdle();
|
||||
} break;
|
||||
|
||||
case QEvent::ShortcutOverride: {
|
||||
@ -252,7 +252,7 @@ bool Application::eventFilter(QObject *object, QEvent *e) {
|
||||
|
||||
case QEvent::ApplicationActivate: {
|
||||
if (object == QCoreApplication::instance()) {
|
||||
psUserActionDone();
|
||||
updateNonIdle();
|
||||
}
|
||||
} break;
|
||||
|
||||
|
@ -484,7 +484,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *e) {
|
||||
|
||||
case QEvent::MouseMove: {
|
||||
if (_main && _main->isIdle()) {
|
||||
psUserActionDone();
|
||||
Core::App().updateNonIdle();
|
||||
_main->checkIdleFinish();
|
||||
}
|
||||
} break;
|
||||
|
@ -193,16 +193,6 @@ void psDeleteDir(const QString &dir) {
|
||||
_removeDirectory(dir);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
auto _lastUserAction = 0LL;
|
||||
|
||||
} // namespace
|
||||
|
||||
void psUserActionDone() {
|
||||
_lastUserAction = crl::now();
|
||||
}
|
||||
|
||||
bool psIdleSupported() {
|
||||
return false;
|
||||
}
|
||||
@ -446,7 +436,7 @@ bool OpenSystemSettings(SystemSettingsType type) {
|
||||
}
|
||||
|
||||
crl::time LastUserInputTime() {
|
||||
return _lastUserAction;
|
||||
return 0LL;
|
||||
}
|
||||
|
||||
namespace ThirdParty {
|
||||
|
@ -51,7 +51,6 @@ void psWriteDump();
|
||||
|
||||
void psDeleteDir(const QString &dir);
|
||||
|
||||
void psUserActionDone();
|
||||
bool psIdleSupported();
|
||||
|
||||
QStringList psInitLogs();
|
||||
|
@ -52,7 +52,6 @@ void psWriteDump();
|
||||
|
||||
void psDeleteDir(const QString &dir);
|
||||
|
||||
void psUserActionDone();
|
||||
bool psIdleSupported();
|
||||
|
||||
QStringList psInitLogs();
|
||||
|
@ -90,16 +90,6 @@ void psDeleteDir(const QString &dir) {
|
||||
objc_deleteDir(dir);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
auto _lastUserAction = 0LL;
|
||||
|
||||
} // namespace
|
||||
|
||||
void psUserActionDone() {
|
||||
_lastUserAction = crl::now();
|
||||
}
|
||||
|
||||
bool psIdleSupported() {
|
||||
return objc_idleSupported();
|
||||
}
|
||||
@ -267,7 +257,7 @@ bool OpenSystemSettings(SystemSettingsType type) {
|
||||
|
||||
crl::time LastUserInputTime() {
|
||||
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
|
||||
|
@ -128,17 +128,6 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
crl::time _lastUserAction = 0;
|
||||
|
||||
} // namespace
|
||||
|
||||
void psUserActionDone() {
|
||||
_lastUserAction = crl::now();
|
||||
EventFilter::getInstance()->setSessionLoggedOff(false);
|
||||
}
|
||||
|
||||
bool psIdleSupported() {
|
||||
LASTINPUTINFO lii;
|
||||
lii.cbSize = sizeof(LASTINPUTINFO);
|
||||
@ -347,7 +336,7 @@ QString CurrentExecutablePath(int argc, char *argv[]) {
|
||||
crl::time LastUserInputTime() {
|
||||
LASTINPUTINFO lii;
|
||||
lii.cbSize = sizeof(LASTINPUTINFO);
|
||||
return GetLastInputInfo(&lii) ? (crl::now() + lii.dwTime - GetTickCount()) : _lastUserAction;
|
||||
return GetLastInputInfo(&lii) ? (crl::now() + lii.dwTime - GetTickCount()) : 0LL;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -59,7 +59,6 @@ void psWriteDump();
|
||||
|
||||
void psDeleteDir(const QString &dir);
|
||||
|
||||
void psUserActionDone();
|
||||
bool psIdleSupported();
|
||||
|
||||
QStringList psInitLogs();
|
||||
|
@ -288,7 +288,7 @@ void MainWindow::init() {
|
||||
void MainWindow::handleStateChanged(Qt::WindowState state) {
|
||||
stateChangedHook(state);
|
||||
updateIsActive((state == Qt::WindowMinimized) ? Global::OfflineBlurTimeout() : Global::OnlineFocusTimeout());
|
||||
psUserActionDone();
|
||||
Core::App().updateNonIdle();
|
||||
if (state == Qt::WindowMinimized && Global::WorkMode().value() == dbiwmTrayOnly) {
|
||||
minimizeToTray();
|
||||
}
|
||||
|
@ -505,9 +505,7 @@ Notification::Notification(
|
||||
int shift,
|
||||
Direction shiftDirection)
|
||||
: Widget(manager, startPosition, shift, shiftDirection)
|
||||
#ifdef Q_OS_WIN
|
||||
, _started(GetTickCount())
|
||||
#endif // Q_OS_WIN
|
||||
, _started(crl::now())
|
||||
, _history(history)
|
||||
, _peer(peer)
|
||||
, _author(author)
|
||||
@ -588,14 +586,7 @@ void Notification::prepareActionsCache() {
|
||||
bool Notification::checkLastInput(bool hasReplyingNotifications) {
|
||||
if (!_waitingForInput) return true;
|
||||
|
||||
auto wasUserInput = true; // TODO
|
||||
#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) {
|
||||
if (Core::App().lastNonIdleTime() > _started) {
|
||||
_waitingForInput = false;
|
||||
if (!hasReplyingNotifications) {
|
||||
_hideTimer.start(st::notifyWaitLongHide);
|
||||
|
@ -216,9 +216,7 @@ private:
|
||||
Animation a_actionsOpacity;
|
||||
QPixmap _buttonsCache;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
crl::time _started;
|
||||
#endif // Q_OS_WIN
|
||||
|
||||
History *_history;
|
||||
PeerData *_peer;
|
||||
|
Loading…
Reference in New Issue
Block a user