Fix accidental search focusing.

This commit is contained in:
John Preston 2024-04-26 11:10:12 +04:00
parent c6d034174b
commit 10c427127e
4 changed files with 18 additions and 11 deletions

View file

@ -958,6 +958,9 @@ void TabbedSelector::beforeHiding() {
_beforeHidingCallback(_currentTabType);
}
}
if (Ui::InFocusChain(this)) {
window()->setFocus();
}
}
void TabbedSelector::afterShown() {

View file

@ -58,7 +58,16 @@ void PickUntilBox(not_null<Ui::GenericBox*> box, Fn<void(TimeId)> callback) {
EmojiStatusPanel::EmojiStatusPanel() = default;
EmojiStatusPanel::~EmojiStatusPanel() = default;
EmojiStatusPanel::~EmojiStatusPanel() {
if (hasFocus()) {
// Panel will try to return focus to the layer widget, the problem is
// we are destroying the layer widget probably right now and focusing
// it will lead to a crash, because it destroys its children (how we
// got here) after it clears focus out of itself. So if you return
// the focus inside a child destructor, it won't be cleared at all.
_panel->window()->setFocus();
}
}
void EmojiStatusPanel::setChooseFilter(Fn<bool(DocumentId)> filter) {
_chooseFilter = std::move(filter);

View file

@ -2644,6 +2644,10 @@ bool MainWidget::eventFilter(QObject *o, QEvent *e) {
if (e->type() == QEvent::FocusIn) {
if (widget && relevantForDialogsFocus(widget)) {
_dialogs->updateHasFocus(widget);
} else if (widget == window()) {
crl::on_main(this, [=] {
_controller->widget()->setInnerFocus();
});
}
} else if (e->type() == QEvent::MouseButtonPress) {
if (widget && (widget->window() == window())) {

View file

@ -165,16 +165,7 @@ Cover::Cover(
}, _name->lifetime());
}
Cover::~Cover() {
if (_emojiStatusPanel.hasFocus()) {
// Panel will try to return focus to the layer widget, the problem is
// we are destroying the layer widget probably right now and focusing
// it will lead to a crash, because it destroys its children (how we
// got here) after it clears focus out of itself. So if you return
// the focus inside a child destructor, it won't be cleared at all.
window()->setFocus();
}
}
Cover::~Cover() = default;
void Cover::setupChildGeometry() {
using namespace rpl::mappers;