From f2a92f2b0201227c2cd18e423fd84305168d65e8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 31 Dec 2019 16:48:44 +0300 Subject: [PATCH] Check if app is active before showing a tooltip. Fixes #6885, fixes #6895. --- Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp | 2 +- Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp | 2 +- .../SourceFiles/history/admin_log/history_admin_log_inner.cpp | 2 +- .../history/admin_log/history_admin_log_section.cpp | 4 +++- Telegram/SourceFiles/history/history_inner_widget.cpp | 2 +- Telegram/SourceFiles/history/history_widget.cpp | 4 +++- .../SourceFiles/history/view/history_view_list_widget.cpp | 2 +- Telegram/SourceFiles/inline_bots/inline_results_widget.cpp | 2 +- Telegram/SourceFiles/ui/special_buttons.cpp | 2 +- Telegram/SourceFiles/ui/special_buttons.h | 4 +++- Telegram/lib_ui | 2 +- 11 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp b/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp index 2668efcc6..39d0b8d2f 100644 --- a/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp +++ b/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp @@ -271,7 +271,7 @@ QPoint BotKeyboard::tooltipPos() const { } bool BotKeyboard::tooltipWindowActive() const { - return Ui::InFocusChain(window()); + return Ui::AppInFocus() && Ui::InFocusChain(window()); } QString BotKeyboard::tooltipText() const { diff --git a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp index 3f597b931..e4b8c8ac6 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp @@ -770,7 +770,7 @@ QPoint EmojiListWidget::tooltipPos() const { } bool EmojiListWidget::tooltipWindowActive() const { - return Ui::InFocusChain(window()); + return Ui::AppInFocus() && Ui::InFocusChain(window()); } TabbedSelector::InnerFooter *EmojiListWidget::getFooter() const { diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index dd2328a46..ede2c7755 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -519,7 +519,7 @@ QPoint InnerWidget::tooltipPos() const { } bool InnerWidget::tooltipWindowActive() const { - return Ui::InFocusChain(window()); + return Ui::AppInFocus() && Ui::InFocusChain(window()); } HistoryView::Context InnerWidget::elementContext() { diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp index d73bbea33..809131b3d 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp @@ -352,7 +352,9 @@ void Widget::setInternalState(const QRect &geometry, not_null m void Widget::setupShortcuts() { Shortcuts::Requests( ) | rpl::filter([=] { - return isActiveWindow() && !Ui::isLayerShown() && inFocusChain(); + return Ui::AppInFocus() + && Ui::InFocusChain(this) + && !Ui::isLayerShown(); }) | rpl::start_with_next([=](not_null request) { using Command = Shortcuts::Command; request->check(Command::Search, 2) && request->handle([=] { diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 34679ee57..789bc7ca1 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -3207,7 +3207,7 @@ QPoint HistoryInner::tooltipPos() const { } bool HistoryInner::tooltipWindowActive() const { - return Ui::InFocusChain(window()); + return Ui::AppInFocus() && Ui::InFocusChain(window()); } void HistoryInner::onParentGeometryChanged() { diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index cfd0a7a25..f25f3b113 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1476,7 +1476,9 @@ void HistoryWidget::notify_userIsBotChanged(UserData *user) { void HistoryWidget::setupShortcuts() { Shortcuts::Requests( ) | rpl::filter([=] { - return isActiveWindow() && !Ui::isLayerShown() && inFocusChain(); + return Ui::AppInFocus() + && Ui::InFocusChain(this) + && !Ui::isLayerShown(); }) | rpl::start_with_next([=](not_null request) { using Command = Shortcuts::Command; if (_history) { diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 38745d248..c93461e17 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -1092,7 +1092,7 @@ QPoint ListWidget::tooltipPos() const { } bool ListWidget::tooltipWindowActive() const { - return Ui::InFocusChain(window()); + return Ui::AppInFocus() && Ui::InFocusChain(window()); } Context ListWidget::elementContext() { diff --git a/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp b/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp index 78c2dcb19..17e537944 100644 --- a/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp @@ -149,7 +149,7 @@ QPoint Inner::tooltipPos() const { } bool Inner::tooltipWindowActive() const { - return Ui::InFocusChain(window()); + return Ui::AppInFocus() && Ui::InFocusChain(window()); } Inner::~Inner() = default; diff --git a/Telegram/SourceFiles/ui/special_buttons.cpp b/Telegram/SourceFiles/ui/special_buttons.cpp index 7a7737433..1b6e84b17 100644 --- a/Telegram/SourceFiles/ui/special_buttons.cpp +++ b/Telegram/SourceFiles/ui/special_buttons.cpp @@ -1118,7 +1118,7 @@ QPoint SilentToggle::tooltipPos() const { } bool SilentToggle::tooltipWindowActive() const { - return InFocusChain(window()); + return Ui::AppInFocus() && InFocusChain(window()); } } // namespace Ui diff --git a/Telegram/SourceFiles/ui/special_buttons.h b/Telegram/SourceFiles/ui/special_buttons.h index 47ac205fc..f69476787 100644 --- a/Telegram/SourceFiles/ui/special_buttons.h +++ b/Telegram/SourceFiles/ui/special_buttons.h @@ -266,7 +266,9 @@ private: // //}; -class SilentToggle : public Ui::IconButton, public Ui::AbstractTooltipShower { +class SilentToggle + : public Ui::IconButton + , public Ui::AbstractTooltipShower { public: SilentToggle(QWidget *parent, not_null channel); diff --git a/Telegram/lib_ui b/Telegram/lib_ui index f0e95ee93..765e52545 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit f0e95ee933d1caf74b790fc85d34212dd3dd2229 +Subproject commit 765e525458843ffb893586441b885ac5ba143e51