MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / closeWindow

Method closeWindow

Telegram/SourceFiles/core/application.cpp:1571–1624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1569}
1570
1571void Application::closeWindow(not_null<Window::Controller*> window) {
1572 const auto stackIt = ranges::find(_windowStack, window);
1573 const auto nextFromStack = _windowStack.empty()
1574 ? nullptr
1575 : (stackIt == end(_windowStack) || stackIt + 1 != end(_windowStack))
1576 ? _windowStack.back().get()
1577 : (_windowStack.size() > 1)
1578 ? (stackIt - 1)->get()
1579 : nullptr;
1580 const auto next = nextFromStack
1581 ? nextFromStack
1582 : (_windows.front().second.get() != window)
1583 ? _windows.front().second.get()
1584 : (_windows.back().second.get() != window)
1585 ? _windows.back().second.get()
1586 : nullptr;
1587 Assert(next != window);
1588
1589 if (_lastActivePrimaryWindow == window) {
1590 _lastActivePrimaryWindow = next;
1591 }
1592 if (_windowInSettings == window) {
1593 _windowInSettings = next;
1594 }
1595 if (stackIt != end(_windowStack)) {
1596 _windowStack.erase(stackIt);
1597 }
1598 if (_lastActiveWindow == window) {
1599 setLastActiveWindow(next);
1600 if (_lastActiveWindow) {
1601 _lastActiveWindow->activate();
1602 _lastActiveWindow->widget()->updateGlobalMenu();
1603 }
1604 }
1605 _closingAsyncWindows.remove(window);
1606 for (auto i = begin(_windows); i != end(_windows);) {
1607 if (i->second.get() == window) {
1608 Assert(_lastActiveWindow != window);
1609 Assert(_lastActivePrimaryWindow != window);
1610 Assert(_windowInSettings != window);
1611 i = _windows.erase(i);
1612 } else {
1613 ++i;
1614 }
1615 }
1616 const auto account = domain().started()
1617 ? &domain().active()
1618 : nullptr;
1619 if (account
1620 && !_windows.contains(Window::SeparateId(account))
1621 && _lastActiveWindow) {
1622 domain().activate(&_lastActiveWindow->account());
1623 }
1624}
1625
1626void Application::closeChatFromWindows(not_null<PeerData*> peer) {
1627 const auto closeOne = [&] {

Callers 4

showAccountMethod · 0.80
closeFolderMethod · 0.80
closeForumMethod · 0.80
CloseInWindowsFunction · 0.80

Calls 13

frontMethod · 0.80
updateGlobalMenuMethod · 0.80
SeparateIdClass · 0.50
emptyMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45
activateMethod · 0.45
widgetMethod · 0.45
removeMethod · 0.45
startedMethod · 0.45
activeMethod · 0.45

Tested by

no test coverage detected