Create tray / mediaview queued on macOS.

This removes some strange redundant entries like "Item-0" from the Dock menu.
This commit is contained in:
John Preston 2023-02-06 13:16:37 +04:00
parent 671b3bc94e
commit 0bdd0689c0
2 changed files with 34 additions and 3 deletions
Telegram/SourceFiles/core

View file

@ -347,9 +347,7 @@ void Application::run() {
_lastActivePrimaryWindow->widget()->show();
const auto current = _lastActivePrimaryWindow->widget()->geometry();
_mediaView = std::make_unique<Media::View::OverlayWidget>();
_lastActivePrimaryWindow->widget()->Ui::RpWidget::setGeometry(current);
startMediaView();
DEBUG_LOG(("Application Info: showing."));
_lastActivePrimaryWindow->finishFirstShow();
@ -492,7 +490,38 @@ void Application::processCreatedWindow(
) | rpl::start_to_stream(_openInMediaViewRequests, window->lifetime());
}
void Application::startMediaView() {
#ifdef Q_OS_MAC
// On macOS we create some windows async, otherwise they're
// added to the Dock Menu as a visible window and are removed
// only after first show and then hide.
InvokeQueued(this, [=] {
_mediaView = std::make_unique<Media::View::OverlayWidget>();
});
#else // Q_OS_MAC
// On Windows we needed such hack for the main window, otherwise
// somewhere inside the media viewer creating code its geometry
// was broken / lost to some invalid values.
const auto current = _lastActivePrimaryWindow->widget()->geometry();
_mediaView = std::make_unique<Media::View::OverlayWidget>();
_lastActivePrimaryWindow->widget()->Ui::RpWidget::setGeometry(current);
#endif // Q_OS_MAC
}
void Application::startTray() {
#ifdef Q_OS_MAC
// On macOS we create some windows async, otherwise they're
// added to the Dock Menu as a visible window and are removed
// only after first show and then hide, tray icon being "Item-0".
InvokeQueued(this, [=] {
createTray();
});
#else // Q_OS_MAC
createTray();
#endif // Q_OS_MAC
}
void Application::createTray() {
using WindowRaw = not_null<Window::Controller*>;
_tray->create();
_tray->aboutToShowRequests(

View file

@ -333,8 +333,10 @@ private:
void startDomain();
void startEmojiImageLoader();
void startSystemDarkModeViewer();
void startMediaView();
void startTray();
void createTray();
void updateWindowTitles();
void setLastActiveWindow(Window::Controller *window);
void showAccount(not_null<Main::Account*> account);