| 1275 | } |
| 1276 | |
| 1277 | void MainWidget::setInnerFocus() { |
| 1278 | const auto setTo = [&](auto &&widget) { |
| 1279 | if (widget->isHidden()) { |
| 1280 | // If we try setting focus inside a hidden widget, we may |
| 1281 | // end up focusing search field in dialogs on window activation. |
| 1282 | setFocus(); |
| 1283 | } else { |
| 1284 | widget->setInnerFocus(); |
| 1285 | } |
| 1286 | }; |
| 1287 | if (_dialogs && _dialogs->searchHasFocus()) { |
| 1288 | setTo(_dialogs); |
| 1289 | } else if (_hider || !_history->peer()) { |
| 1290 | if (!_hider && _mainSection) { |
| 1291 | setTo(_mainSection); |
| 1292 | } else if (!_hider && _thirdSection) { |
| 1293 | setTo(_thirdSection); |
| 1294 | } else if (_dialogs) { |
| 1295 | setTo(_dialogs); |
| 1296 | } else { |
| 1297 | // Maybe we're just closing a child window, content is destroyed. |
| 1298 | _history->setFocus(); |
| 1299 | } |
| 1300 | } else if (_mainSection) { |
| 1301 | setTo(_mainSection); |
| 1302 | } else { |
| 1303 | setTo(_history); |
| 1304 | } |
| 1305 | } |
| 1306 | |
| 1307 | void MainWidget::showChooseReportMessages( |
| 1308 | not_null<PeerData*> peer, |
no test coverage detected