From de4a477686886df8afb7ff9849cfaba2efcd786c Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 23 Dec 2018 16:08:48 +0400 Subject: [PATCH] Mark event loop nesting more carefully. Fixes #5506. I hope fixes #5508. --- Telegram/SourceFiles/application.cpp | 3 ++- .../SourceFiles/platform/linux/specific_linux.cpp | 10 +++++++--- Telegram/SourceFiles/platform/mac/specific_mac.mm | 4 ++++ Telegram/SourceFiles/platform/platform_specific.h | 2 ++ .../SourceFiles/platform/win/specific_win.cpp | 15 +++++++++++++++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index ca6b613af..eccdb2f6f 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -430,7 +430,8 @@ bool Application::nativeEventFilter( const QByteArray &eventType, void *message, long *result) { - if (_eventNestingLevel > _loopNestingLevel) { + if (_eventNestingLevel > _loopNestingLevel + && Platform::NativeEventNestsLoop(message)) { _previousLoopNestingLevels.push_back(_loopNestingLevel); _loopNestingLevel = _eventNestingLevel; } diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index c6c23e6f7..401cbefd5 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -477,15 +477,19 @@ void RegisterCustomScheme() { #endif // !TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME } -PermissionStatus GetPermissionStatus(PermissionType type){ +PermissionStatus GetPermissionStatus(PermissionType type) { return PermissionStatus::Granted; } -void RequestPermission(PermissionType type, Fn resultCallback){ +void RequestPermission(PermissionType type, Fn resultCallback) { resultCallback(PermissionStatus::Granted); } -void OpenSystemSettingsForPermission(PermissionType type){ +void OpenSystemSettingsForPermission(PermissionType type) { +} + +bool NativeEventNestsLoop(void *message) { + return true; } namespace ThirdParty { diff --git a/Telegram/SourceFiles/platform/mac/specific_mac.mm b/Telegram/SourceFiles/platform/mac/specific_mac.mm index c0726628b..b57064e4f 100644 --- a/Telegram/SourceFiles/platform/mac/specific_mac.mm +++ b/Telegram/SourceFiles/platform/mac/specific_mac.mm @@ -332,6 +332,10 @@ void OpenSystemSettingsForPermission(PermissionType type) { #endif // OS_MAC_OLD } +bool NativeEventNestsLoop(void *message) { + return true; +} + } // namespace Platform void psNewVersion() { diff --git a/Telegram/SourceFiles/platform/platform_specific.h b/Telegram/SourceFiles/platform/platform_specific.h index dfb625a50..a9c8acc2b 100644 --- a/Telegram/SourceFiles/platform/platform_specific.h +++ b/Telegram/SourceFiles/platform/platform_specific.h @@ -35,6 +35,8 @@ PermissionStatus GetPermissionStatus(PermissionType type); void RequestPermission(PermissionType type, Fn resultCallback); void OpenSystemSettingsForPermission(PermissionType type); +bool NativeEventNestsLoop(void *message); + QString SystemLanguage(); QString SystemCountry(); diff --git a/Telegram/SourceFiles/platform/win/specific_win.cpp b/Telegram/SourceFiles/platform/win/specific_win.cpp index 683097d6a..31cbd7c4a 100644 --- a/Telegram/SourceFiles/platform/win/specific_win.cpp +++ b/Telegram/SourceFiles/platform/win/specific_win.cpp @@ -657,6 +657,21 @@ void OpenSystemSettingsForPermission(PermissionType type) { } } +bool NativeEventNestsLoop(void *message) { + const auto code = static_cast(message)->message; + if (code > WM_NULL && code <= WM_GETMINMAXINFO) { + return true; + } else if (code >= WM_NCCREATE && code <= WM_NCXBUTTONDBLCLK) { + return true; + } else if (code == WM_WINDOWPOSCHANGING + || code == WM_WINDOWPOSCHANGED + || code == WM_STYLECHANGING + || code == WM_STYLECHANGED) { + return true; + } + return false; +} + } // namespace Platform void psNewVersion() {