mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 13:47:05 +02:00
Fix focus search on topic open.
This commit is contained in:
parent
520de600a0
commit
7d52c13625
1 changed files with 15 additions and 6 deletions
|
@ -1185,23 +1185,32 @@ Image *MainWidget::newBackgroundThumb() {
|
|||
}
|
||||
|
||||
void MainWidget::setInnerFocus() {
|
||||
const auto setTo = [&](auto &&widget) {
|
||||
if (widget->isHidden()) {
|
||||
// If we try setting focus inside a hidden widget, we may
|
||||
// end up focusing search field in dialogs on window activation.
|
||||
setFocus();
|
||||
} else {
|
||||
widget->setInnerFocus();
|
||||
}
|
||||
};
|
||||
if (_dialogs && _dialogs->searchHasFocus()) {
|
||||
_dialogs->setInnerFocus();
|
||||
setTo(_dialogs);
|
||||
} else if (_hider || !_history->peer()) {
|
||||
if (!_hider && _mainSection) {
|
||||
_mainSection->setInnerFocus();
|
||||
setTo(_mainSection);
|
||||
} else if (!_hider && _thirdSection) {
|
||||
_thirdSection->setInnerFocus();
|
||||
setTo(_thirdSection);
|
||||
} else if (_dialogs) {
|
||||
_dialogs->setInnerFocus();
|
||||
setTo(_dialogs);
|
||||
} else {
|
||||
// Maybe we're just closing a child window, content is destroyed.
|
||||
_history->setFocus();
|
||||
}
|
||||
} else if (_mainSection) {
|
||||
_mainSection->setInnerFocus();
|
||||
setTo(_mainSection);
|
||||
} else {
|
||||
_history->setInnerFocus();
|
||||
setTo(_history);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue