Remove some App::wnd() calls.
This commit is contained in:
parent
204dd0a869
commit
54f06740d5
|
@ -17,11 +17,16 @@ namespace HistoryView {
|
||||||
class ElementDelegate;
|
class ElementDelegate;
|
||||||
} // namespace HistoryView
|
} // namespace HistoryView
|
||||||
|
|
||||||
|
namespace Window {
|
||||||
|
class SessionController;
|
||||||
|
} // namespace Window
|
||||||
|
|
||||||
[[nodiscard]] bool UrlRequiresConfirmation(const QUrl &url);
|
[[nodiscard]] bool UrlRequiresConfirmation(const QUrl &url);
|
||||||
|
|
||||||
struct ClickHandlerContext {
|
struct ClickHandlerContext {
|
||||||
FullMsgId itemId;
|
FullMsgId itemId;
|
||||||
Fn<HistoryView::ElementDelegate*()> elementDelegate;
|
Fn<HistoryView::ElementDelegate*()> elementDelegate;
|
||||||
|
base::weak_ptr<Window::SessionController> sessionWindow;
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(ClickHandlerContext);
|
Q_DECLARE_METATYPE(ClickHandlerContext);
|
||||||
|
|
||||||
|
|
|
@ -1351,6 +1351,7 @@ void HistoryInner::mouseActionFinish(
|
||||||
? HistoryInner::ElementDelegate().get()
|
? HistoryInner::ElementDelegate().get()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
},
|
},
|
||||||
|
.sessionWindow = base::make_weak(_controller.get()),
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2220,6 +2220,7 @@ void ListWidget::mouseActionFinish(
|
||||||
? (ElementDelegate*)weak
|
? (ElementDelegate*)weak
|
||||||
: nullptr;
|
: nullptr;
|
||||||
},
|
},
|
||||||
|
.sessionWindow = base::make_weak(_controller.get()),
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -19,10 +19,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/emoji_config.h"
|
#include "ui/emoji_config.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
|
#include "core/click_handler_types.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
#include "main/main_app_config.h"
|
#include "main/main_app_config.h"
|
||||||
#include "mainwindow.h" // App::wnd()->sessionController.
|
|
||||||
#include "window/window_session_controller.h" // isGifPausedAtLeastFor.
|
#include "window/window_session_controller.h" // isGifPausedAtLeastFor.
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
|
@ -270,8 +270,11 @@ void Sticker::refreshLink() {
|
||||||
that->_parent);
|
that->_parent);
|
||||||
});
|
});
|
||||||
} else if (sticker && sticker->set.type() != mtpc_inputStickerSetEmpty) {
|
} else if (sticker && sticker->set.type() != mtpc_inputStickerSetEmpty) {
|
||||||
_link = std::make_shared<LambdaClickHandler>([document = _data] {
|
_link = std::make_shared<LambdaClickHandler>([document = _data](ClickContext context) {
|
||||||
StickerSetBox::Show(App::wnd()->sessionController(), document);
|
const auto my = context.other.value<ClickHandlerContext>();
|
||||||
|
if (const auto window = my.sessionWindow.get()) {
|
||||||
|
StickerSetBox::Show(window, document);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else if (sticker
|
} else if (sticker
|
||||||
&& (_data->dimensions.width() > kStickerSideSize
|
&& (_data->dimensions.width() > kStickerSideSize
|
||||||
|
|
|
@ -1591,8 +1591,8 @@ void MainWidget::ui_showPeerHistory(
|
||||||
animationParams);
|
animationParams);
|
||||||
} else {
|
} else {
|
||||||
_history->show();
|
_history->show();
|
||||||
crl::on_main(App::wnd(), [] {
|
crl::on_main(this, [=] {
|
||||||
App::wnd()->setInnerFocus();
|
_controller->widget()->setInnerFocus();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1948,11 +1948,10 @@ void MainWidget::showBackFromStack(
|
||||||
|
|
||||||
if (selectingPeer()) {
|
if (selectingPeer()) {
|
||||||
return;
|
return;
|
||||||
}
|
} else if (_stack.empty()) {
|
||||||
if (_stack.empty()) {
|
|
||||||
_controller->clearSectionStack(params);
|
_controller->clearSectionStack(params);
|
||||||
crl::on_main(App::wnd(), [] {
|
crl::on_main(this, [=] {
|
||||||
App::wnd()->setInnerFocus();
|
_controller->widget()->setInnerFocus();
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2236,7 +2235,7 @@ void MainWidget::showAll() {
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
floatPlayerCheckVisibility();
|
floatPlayerCheckVisibility();
|
||||||
|
|
||||||
App::wnd()->checkHistoryActivation();
|
_controller->widget()->checkHistoryActivation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::resizeEvent(QResizeEvent *e) {
|
void MainWidget::resizeEvent(QResizeEvent *e) {
|
||||||
|
@ -2720,7 +2719,7 @@ void MainWidget::activate() {
|
||||||
} else if (!_mainSection) {
|
} else if (!_mainSection) {
|
||||||
if (_hider) {
|
if (_hider) {
|
||||||
_dialogs->setInnerFocus();
|
_dialogs->setInnerFocus();
|
||||||
} else if (App::wnd() && !Ui::isLayerShown()) {
|
} else if (!Ui::isLayerShown()) {
|
||||||
if (!cSendPaths().isEmpty()) {
|
if (!cSendPaths().isEmpty()) {
|
||||||
const auto interpret = qstr("interpret://");
|
const auto interpret = qstr("interpret://");
|
||||||
const auto path = cSendPaths()[0];
|
const auto path = cSendPaths()[0];
|
||||||
|
@ -2742,7 +2741,7 @@ void MainWidget::activate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
App::wnd()->fixOrder();
|
_controller->widget()->fixOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::isActive() const {
|
bool MainWidget::isActive() const {
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
|
|
||||||
void showSettings();
|
void showSettings();
|
||||||
|
|
||||||
void setInnerFocus();
|
void setInnerFocus() override;
|
||||||
|
|
||||||
MainWidget *sessionContent() const;
|
MainWidget *sessionContent() const;
|
||||||
|
|
||||||
|
|
|
@ -928,8 +928,8 @@ void MainWindow::createGlobalMenu() {
|
||||||
|
|
||||||
auto quit = file->addAction(
|
auto quit = file->addAction(
|
||||||
tr::lng_mac_menu_quit_telegram(tr::now, lt_telegram, qsl("Telegram")),
|
tr::lng_mac_menu_quit_telegram(tr::now, lt_telegram, qsl("Telegram")),
|
||||||
App::wnd(),
|
this,
|
||||||
[=] { App::wnd()->quitFromTray(); },
|
[=] { quitFromTray(); },
|
||||||
QKeySequence::Quit);
|
QKeySequence::Quit);
|
||||||
|
|
||||||
quit->setMenuRole(QAction::QuitRole);
|
quit->setMenuRole(QAction::QuitRole);
|
||||||
|
@ -1037,7 +1037,7 @@ void MainWindow::createGlobalMenu() {
|
||||||
tr::lng_mac_menu_contacts(tr::now),
|
tr::lng_mac_menu_contacts(tr::now),
|
||||||
crl::guard(this, [=] {
|
crl::guard(this, [=] {
|
||||||
if (isHidden()) {
|
if (isHidden()) {
|
||||||
App::wnd()->showFromTray();
|
showFromTray();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sessionController()) {
|
if (!sessionController()) {
|
||||||
|
@ -1154,7 +1154,9 @@ void MainWindow::psLinuxClearFormat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateGlobalMenuHook() {
|
void MainWindow::updateGlobalMenuHook() {
|
||||||
if (!App::wnd() || !positionInited()) return;
|
if (!positionInited()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const auto focused = QApplication::focusWidget();
|
const auto focused = QApplication::focusWidget();
|
||||||
auto canUndo = false;
|
auto canUndo = false;
|
||||||
|
@ -1189,7 +1191,7 @@ void MainWindow::updateGlobalMenuHook() {
|
||||||
canCopy = list->canCopySelected();
|
canCopy = list->canCopySelected();
|
||||||
canDelete = list->canDeleteSelected();
|
canDelete = list->canDeleteSelected();
|
||||||
}
|
}
|
||||||
App::wnd()->updateIsActive();
|
updateIsActive();
|
||||||
const auto logged = (sessionController() != nullptr);
|
const auto logged = (sessionController() != nullptr);
|
||||||
const auto inactive = !logged || controller().locked();
|
const auto inactive = !logged || controller().locked();
|
||||||
const auto support = logged && account().session().supportMode();
|
const auto support = logged && account().session().supportMode();
|
||||||
|
|
|
@ -545,7 +545,7 @@ std::optional<bool> IsDarkMode() {
|
||||||
if (integration->checkVersion(3, 0, 0)) {
|
if (integration->checkVersion(3, 0, 0)) {
|
||||||
const auto preferDarkTheme = integration->getBoolSetting(
|
const auto preferDarkTheme = integration->getBoolSetting(
|
||||||
qsl("gtk-application-prefer-dark-theme"));
|
qsl("gtk-application-prefer-dark-theme"));
|
||||||
|
|
||||||
if (!preferDarkTheme.has_value()) {
|
if (!preferDarkTheme.has_value()) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
} else if (*preferDarkTheme) {
|
} else if (*preferDarkTheme) {
|
||||||
|
@ -588,17 +588,6 @@ bool SkipTaskbarSupported() {
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
||||||
QRect psDesktopRect() {
|
|
||||||
static QRect _monitorRect;
|
|
||||||
static auto _monitorLastGot = 0LL;
|
|
||||||
auto tnow = crl::now();
|
|
||||||
if (tnow > _monitorLastGot + 1000LL || tnow < _monitorLastGot) {
|
|
||||||
_monitorLastGot = tnow;
|
|
||||||
_monitorRect = QApplication::desktop()->availableGeometry(App::wnd());
|
|
||||||
}
|
|
||||||
return _monitorRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
void psWriteDump() {
|
void psWriteDump() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,6 @@ QString psAppDataPath();
|
||||||
void psAutoStart(bool start, bool silent = false);
|
void psAutoStart(bool start, bool silent = false);
|
||||||
void psSendToMenu(bool send, bool silent = false);
|
void psSendToMenu(bool send, bool silent = false);
|
||||||
|
|
||||||
QRect psDesktopRect();
|
|
||||||
|
|
||||||
int psCleanup();
|
int psCleanup();
|
||||||
int psFixPrevious();
|
int psFixPrevious();
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,6 @@ QString psAppDataPath();
|
||||||
void psAutoStart(bool start, bool silent = false);
|
void psAutoStart(bool start, bool silent = false);
|
||||||
void psSendToMenu(bool send, bool silent = false);
|
void psSendToMenu(bool send, bool silent = false);
|
||||||
|
|
||||||
QRect psDesktopRect();
|
|
||||||
|
|
||||||
int psCleanup();
|
int psCleanup();
|
||||||
int psFixPrevious();
|
int psFixPrevious();
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "history/history_location_manager.h"
|
#include "history/history_location_manager.h"
|
||||||
#include "base/platform/mac/base_utilities_mac.h"
|
#include "base/platform/mac/base_utilities_mac.h"
|
||||||
|
@ -36,17 +37,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <mach-o/dyld.h>
|
#include <mach-o/dyld.h>
|
||||||
#include <AVFoundation/AVFoundation.h>
|
#include <AVFoundation/AVFoundation.h>
|
||||||
|
|
||||||
QRect psDesktopRect() {
|
|
||||||
static QRect _monitorRect;
|
|
||||||
static crl::time _monitorLastGot = 0;
|
|
||||||
auto tnow = crl::now();
|
|
||||||
if (tnow > _monitorLastGot + 1000 || tnow < _monitorLastGot) {
|
|
||||||
_monitorLastGot = tnow;
|
|
||||||
_monitorRect = QApplication::desktop()->availableGeometry(App::wnd());
|
|
||||||
}
|
|
||||||
return _monitorRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
void psWriteDump() {
|
void psWriteDump() {
|
||||||
#ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS
|
#ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS
|
||||||
double v = objc_appkitVersion();
|
double v = objc_appkitVersion();
|
||||||
|
@ -56,7 +46,8 @@ void psWriteDump() {
|
||||||
|
|
||||||
void psActivateProcess(uint64 pid) {
|
void psActivateProcess(uint64 pid) {
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
objc_activateProgram(App::wnd() ? App::wnd()->winId() : 0);
|
const auto window = Core::App().activeWindow();
|
||||||
|
objc_activateProgram(window ? window->widget()->winId() : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "media/audio/media_audio.h"
|
#include "media/audio/media_audio.h"
|
||||||
#include "media/player/media_player_instance.h"
|
#include "media/player/media_player_instance.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
#include "base/platform/mac/base_utilities_mac.h"
|
#include "base/platform/mac/base_utilities_mac.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
@ -114,7 +115,11 @@ ApplicationDelegate *_sharedDelegate = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag {
|
- (BOOL) applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag {
|
||||||
if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray();
|
if (const auto window = Core::App().activeWindow()) {
|
||||||
|
if (window->widget()->isHidden()) {
|
||||||
|
window->widget()->showFromTray();
|
||||||
|
}
|
||||||
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,9 +148,9 @@ ApplicationDelegate *_sharedDelegate = nil;
|
||||||
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
||||||
if (Core::IsAppLaunched() && !_ignoreActivation) {
|
if (Core::IsAppLaunched() && !_ignoreActivation) {
|
||||||
Core::App().handleAppActivated();
|
Core::App().handleAppActivated();
|
||||||
if (auto window = App::wnd()) {
|
if (auto window = Core::App().activeWindow()) {
|
||||||
if (window->isHidden()) {
|
if (window->widget()->isHidden()) {
|
||||||
window->showFromTray();
|
window->widget()->showFromTray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ void TitleWidget::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
object_ptr<Window::TitleWidget> CreateTitleWidget(QWidget *parent) {
|
object_ptr<Window::TitleWidget> CreateTitleWidget(QWidget *parent) {
|
||||||
if (auto window = qobject_cast<Platform::MainWindow*>(parent)) {
|
if (auto window = Core::App().activeWindow()) {
|
||||||
if (auto height = window->getCustomTitleHeight()) {
|
if (auto height = window->getCustomTitleHeight()) {
|
||||||
return object_ptr<TitleWidget>(window, height);
|
return object_ptr<TitleWidget>(window, height);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ object_ptr<Window::TitleWidget> CreateTitleWidget(QWidget *parent) {
|
||||||
// account, with 100% scale and without "px" dimensions, because thats
|
// account, with 100% scale and without "px" dimensions, because thats
|
||||||
// how it will look in real launched macOS app.
|
// how it will look in real launched macOS app.
|
||||||
int PreviewTitleHeight() {
|
int PreviewTitleHeight() {
|
||||||
if (auto window = qobject_cast<Platform::MainWindow*>(App::wnd())) {
|
if (auto window = Core::App().activeWindow()) {
|
||||||
if (auto height = window->getCustomTitleHeight()) {
|
if (auto height = window->getCustomTitleHeight()) {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/crash_reports.h"
|
#include "core/crash_reports.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
#include <QtWidgets/QFileDialog>
|
#include <QtWidgets/QFileDialog>
|
||||||
|
@ -139,12 +140,12 @@ bool UnsafeShowOpenWithDropdown(const QString &filepath, QPoint menuPosition) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto window = App::wnd();
|
auto window = Core::App().activeWindow();
|
||||||
if (!window) {
|
if (!window) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto parentHWND = window->psHwnd();
|
auto parentHWND = window->widget()->psHwnd();
|
||||||
auto wstringPath = QDir::toNativeSeparators(filepath).toStdWString();
|
auto wstringPath = QDir::toNativeSeparators(filepath).toStdWString();
|
||||||
|
|
||||||
auto result = false;
|
auto result = false;
|
||||||
|
|
|
@ -247,7 +247,7 @@ void MainWindow::psSetupTrayIcon() {
|
||||||
trayIcon,
|
trayIcon,
|
||||||
&QSystemTrayIcon::messageClicked,
|
&QSystemTrayIcon::messageClicked,
|
||||||
this,
|
this,
|
||||||
[=] { App::wnd()->showFromTray(); });
|
[=] { showFromTray(); });
|
||||||
attachToTrayIcon(trayIcon);
|
attachToTrayIcon(trayIcon);
|
||||||
}
|
}
|
||||||
updateIconCounters();
|
updateIconCounters();
|
||||||
|
@ -328,6 +328,21 @@ bool MainWindow::initSizeFromSystem() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRect MainWindow::computeDesktopRect() const {
|
||||||
|
const auto flags = MONITOR_DEFAULTTONEAREST;
|
||||||
|
if (const auto monitor = MonitorFromWindow(psHwnd(), flags)) {
|
||||||
|
MONITORINFOEX info;
|
||||||
|
info.cbSize = sizeof(info);
|
||||||
|
GetMonitorInfo(monitor, &info);
|
||||||
|
return QRect(
|
||||||
|
info.rcWork.left,
|
||||||
|
info.rcWork.top,
|
||||||
|
info.rcWork.right - info.rcWork.left,
|
||||||
|
info.rcWork.bottom - info.rcWork.top);
|
||||||
|
}
|
||||||
|
return Window::MainWindow::computeDesktopRect();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::updateWindowIcon() {
|
void MainWindow::updateWindowIcon() {
|
||||||
updateIconCounters();
|
updateIconCounters();
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,8 @@ protected:
|
||||||
|
|
||||||
bool initSizeFromSystem() override;
|
bool initSizeFromSystem() override;
|
||||||
|
|
||||||
|
QRect computeDesktopRect() const override;
|
||||||
|
|
||||||
QTimer psUpdatedPositionTimer;
|
QTimer psUpdatedPositionTimer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "platform/win/notifications_manager_win.h"
|
#include "platform/win/notifications_manager_win.h"
|
||||||
|
|
||||||
#include "window/notifications_utilities.h"
|
#include "window/notifications_utilities.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
#include "base/platform/win/base_windows_wrl.h"
|
#include "base/platform/win/base_windows_wrl.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "platform/win/windows_app_user_model_id.h"
|
#include "platform/win/windows_app_user_model_id.h"
|
||||||
|
@ -311,7 +312,9 @@ public:
|
||||||
void clearFromHistory(not_null<History*> history);
|
void clearFromHistory(not_null<History*> history);
|
||||||
void clearFromSession(not_null<Main::Session*> session);
|
void clearFromSession(not_null<Main::Session*> session);
|
||||||
void beforeNotificationActivated(NotificationId id);
|
void beforeNotificationActivated(NotificationId id);
|
||||||
void afterNotificationActivated(NotificationId id);
|
void afterNotificationActivated(
|
||||||
|
NotificationId id,
|
||||||
|
not_null<Window::SessionController*> window);
|
||||||
void clearNotification(NotificationId id);
|
void clearNotification(NotificationId id);
|
||||||
|
|
||||||
~Private();
|
~Private();
|
||||||
|
@ -423,10 +426,10 @@ void Manager::Private::beforeNotificationActivated(NotificationId id) {
|
||||||
clearNotification(id);
|
clearNotification(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::Private::afterNotificationActivated(NotificationId id) {
|
void Manager::Private::afterNotificationActivated(
|
||||||
if (auto window = App::wnd()) {
|
NotificationId id,
|
||||||
SetForegroundWindow(window->psHwnd());
|
not_null<Window::SessionController*> window) {
|
||||||
}
|
SetForegroundWindow(window->widget()->psHwnd());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::Private::clearNotification(NotificationId id) {
|
void Manager::Private::clearNotification(NotificationId id) {
|
||||||
|
@ -617,8 +620,10 @@ void Manager::onBeforeNotificationActivated(NotificationId id) {
|
||||||
_private->beforeNotificationActivated(id);
|
_private->beforeNotificationActivated(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::onAfterNotificationActivated(NotificationId id) {
|
void Manager::onAfterNotificationActivated(
|
||||||
_private->afterNotificationActivated(id);
|
NotificationId id,
|
||||||
|
not_null<Window::SessionController*> window) {
|
||||||
|
_private->afterNotificationActivated(id, window);
|
||||||
}
|
}
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,9 @@ protected:
|
||||||
void doClearFromHistory(not_null<History*> history) override;
|
void doClearFromHistory(not_null<History*> history) override;
|
||||||
void doClearFromSession(not_null<Main::Session*> session) override;
|
void doClearFromSession(not_null<Main::Session*> session) override;
|
||||||
void onBeforeNotificationActivated(NotificationId id) override;
|
void onBeforeNotificationActivated(NotificationId id) override;
|
||||||
void onAfterNotificationActivated(NotificationId id) override;
|
void onAfterNotificationActivated(
|
||||||
|
NotificationId id,
|
||||||
|
not_null<Window::SessionController*> window) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
|
|
|
@ -145,25 +145,6 @@ void psDoCleanup() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect psDesktopRect() {
|
|
||||||
static QRect _monitorRect;
|
|
||||||
static crl::time _monitorLastGot = 0;
|
|
||||||
auto tnow = crl::now();
|
|
||||||
if (tnow > _monitorLastGot + 1000LL || tnow < _monitorLastGot) {
|
|
||||||
_monitorLastGot = tnow;
|
|
||||||
HMONITOR hMonitor = MonitorFromWindow(App::wnd()->psHwnd(), MONITOR_DEFAULTTONEAREST);
|
|
||||||
if (hMonitor) {
|
|
||||||
MONITORINFOEX info;
|
|
||||||
info.cbSize = sizeof(info);
|
|
||||||
GetMonitorInfo(hMonitor, &info);
|
|
||||||
_monitorRect = QRect(info.rcWork.left, info.rcWork.top, info.rcWork.right - info.rcWork.left, info.rcWork.bottom - info.rcWork.top);
|
|
||||||
} else {
|
|
||||||
_monitorRect = QApplication::desktop()->availableGeometry(App::wnd());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return _monitorRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
int psCleanup() {
|
int psCleanup() {
|
||||||
__try
|
__try
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,8 +55,6 @@ QString psAppDataPathOld();
|
||||||
void psAutoStart(bool start, bool silent = false);
|
void psAutoStart(bool start, bool silent = false);
|
||||||
void psSendToMenu(bool send, bool silent = false);
|
void psSendToMenu(bool send, bool silent = false);
|
||||||
|
|
||||||
QRect psDesktopRect();
|
|
||||||
|
|
||||||
int psCleanup();
|
int psCleanup();
|
||||||
int psFixPrevious();
|
int psFixPrevious();
|
||||||
|
|
||||||
|
|
|
@ -370,7 +370,7 @@ void NotificationsCount::setOverCorner(ScreenCorner corner) {
|
||||||
samples[i]->showFast();
|
samples[i]->showFast();
|
||||||
}
|
}
|
||||||
if (samplesNeeded > samplesLeave) {
|
if (samplesNeeded > samplesLeave) {
|
||||||
auto r = psDesktopRect();
|
auto r = _controller->widget()->desktopRect();
|
||||||
auto isLeft = Core::Settings::IsLeftCorner(_overCorner);
|
auto isLeft = Core::Settings::IsLeftCorner(_overCorner);
|
||||||
auto isTop = Core::Settings::IsTopCorner(_overCorner);
|
auto isTop = Core::Settings::IsTopCorner(_overCorner);
|
||||||
auto sampleLeft = (isLeft == rtl()) ? (r.x() + r.width() - st::notifyWidth - st::notifyDeltaX) : (r.x() + st::notifyDeltaX);
|
auto sampleLeft = (isLeft == rtl()) ? (r.x() + r.width() - st::notifyWidth - st::notifyDeltaX) : (r.x() + st::notifyDeltaX);
|
||||||
|
|
|
@ -218,6 +218,15 @@ void MainWindow::updateWindowIcon() {
|
||||||
setWindowIcon(_icon);
|
setWindowIcon(_icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRect MainWindow::desktopRect() const {
|
||||||
|
const auto now = crl::now();
|
||||||
|
if (now >= _monitorLastGot && now <= _monitorLastGot + crl::time(1000)) {
|
||||||
|
_monitorLastGot = now;
|
||||||
|
_monitorRect = computeDesktopRect();
|
||||||
|
}
|
||||||
|
return _monitorRect;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::init() {
|
void MainWindow::init() {
|
||||||
Expects(!windowHandle());
|
Expects(!windowHandle());
|
||||||
|
|
||||||
|
@ -612,6 +621,10 @@ void MainWindow::updateUnreadCounter() {
|
||||||
unreadCounterChangedHook();
|
unreadCounterChangedHook();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRect MainWindow::computeDesktopRect() const {
|
||||||
|
return QApplication::desktop()->availableGeometry(this);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::savePosition(Qt::WindowState state) {
|
void MainWindow::savePosition(Qt::WindowState state) {
|
||||||
if (state == Qt::WindowActive) {
|
if (state == Qt::WindowActive) {
|
||||||
state = windowHandle()->windowState();
|
state = windowHandle()->windowState();
|
||||||
|
@ -698,8 +711,9 @@ bool MainWindow::minimizeToTray() {
|
||||||
|
|
||||||
void MainWindow::reActivateWindow() {
|
void MainWindow::reActivateWindow() {
|
||||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||||
|
const auto weak = Ui::MakeWeak(this);
|
||||||
const auto reActivate = [=] {
|
const auto reActivate = [=] {
|
||||||
if (const auto w = App::wnd()) {
|
if (const auto w = weak.data()) {
|
||||||
if (auto f = QApplication::focusWidget()) {
|
if (auto f = QApplication::focusWidget()) {
|
||||||
f->clearFocus();
|
f->clearFocus();
|
||||||
}
|
}
|
||||||
|
@ -723,8 +737,8 @@ void MainWindow::showRightColumn(object_ptr<TWidget> widget) {
|
||||||
_rightColumn->setParent(this);
|
_rightColumn->setParent(this);
|
||||||
_rightColumn->show();
|
_rightColumn->show();
|
||||||
_rightColumn->setFocus();
|
_rightColumn->setFocus();
|
||||||
} else if (App::wnd()) {
|
} else {
|
||||||
App::wnd()->setInnerFocus();
|
setInnerFocus();
|
||||||
}
|
}
|
||||||
const auto nowRightWidth = _rightColumn ? _rightColumn->width() : 0;
|
const auto nowRightWidth = _rightColumn ? _rightColumn->width() : 0;
|
||||||
const auto wasMaximized = isMaximized();
|
const auto wasMaximized = isMaximized();
|
||||||
|
@ -777,7 +791,7 @@ int MainWindow::tryToExtendWidthBy(int addToWidth) {
|
||||||
|
|
||||||
void MainWindow::launchDrag(std::unique_ptr<QMimeData> data) {
|
void MainWindow::launchDrag(std::unique_ptr<QMimeData> data) {
|
||||||
auto weak = QPointer<MainWindow>(this);
|
auto weak = QPointer<MainWindow>(this);
|
||||||
auto drag = std::make_unique<QDrag>(App::wnd());
|
auto drag = std::make_unique<QDrag>(this);
|
||||||
drag->setMimeData(data.release());
|
drag->setMimeData(data.release());
|
||||||
drag->exec(Qt::CopyAction);
|
drag->exec(Qt::CopyAction);
|
||||||
|
|
||||||
|
|
|
@ -37,10 +37,9 @@ QIcon CreateIcon(Main::Session *session = nullptr);
|
||||||
void ConvertIconToBlack(QImage &image);
|
void ConvertIconToBlack(QImage &image);
|
||||||
|
|
||||||
class MainWindow : public Ui::RpWidget, protected base::Subscriber {
|
class MainWindow : public Ui::RpWidget, protected base::Subscriber {
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(not_null<Controller*> controller);
|
explicit MainWindow(not_null<Controller*> controller);
|
||||||
|
virtual ~MainWindow();
|
||||||
|
|
||||||
[[nodiscard]] Window::Controller &controller() const {
|
[[nodiscard]] Window::Controller &controller() const {
|
||||||
return *_controller;
|
return *_controller;
|
||||||
|
@ -57,15 +56,17 @@ public:
|
||||||
showFromTray();
|
showFromTray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] QRect desktopRect() const;
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
HitTestResult hitTest(const QPoint &p) const;
|
[[nodiscard]] HitTestResult hitTest(const QPoint &p) const;
|
||||||
|
|
||||||
void updateIsActive();
|
void updateIsActive();
|
||||||
|
|
||||||
bool isActive() const {
|
[[nodiscard]] bool isActive() const {
|
||||||
return _isActive;
|
return _isActive;
|
||||||
}
|
}
|
||||||
virtual bool isActiveForTrayMenu() {
|
[[nodiscard]] virtual bool isActiveForTrayMenu() {
|
||||||
updateIsActive();
|
updateIsActive();
|
||||||
return isActive();
|
return isActive();
|
||||||
}
|
}
|
||||||
|
@ -94,8 +95,9 @@ public:
|
||||||
}
|
}
|
||||||
virtual void fixOrder() {
|
virtual void fixOrder() {
|
||||||
}
|
}
|
||||||
|
virtual void setInnerFocus() {
|
||||||
virtual ~MainWindow();
|
setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
Ui::RpWidget *bodyWidget() {
|
Ui::RpWidget *bodyWidget() {
|
||||||
return _body.data();
|
return _body.data();
|
||||||
|
@ -121,7 +123,6 @@ public:
|
||||||
|
|
||||||
bool hasShadow() const;
|
bool hasShadow() const;
|
||||||
|
|
||||||
public slots:
|
|
||||||
bool minimizeToTray();
|
bool minimizeToTray();
|
||||||
void updateGlobalMenu() {
|
void updateGlobalMenu() {
|
||||||
updateGlobalMenuHook();
|
updateGlobalMenuHook();
|
||||||
|
@ -199,6 +200,8 @@ protected:
|
||||||
QSystemTrayIcon::ActivationReason reason) = 0;
|
QSystemTrayIcon::ActivationReason reason) = 0;
|
||||||
void updateUnreadCounter();
|
void updateUnreadCounter();
|
||||||
|
|
||||||
|
virtual QRect computeDesktopRect() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void refreshTitleWidget();
|
void refreshTitleWidget();
|
||||||
void updateMinimumSize();
|
void updateMinimumSize();
|
||||||
|
@ -231,6 +234,9 @@ private:
|
||||||
|
|
||||||
bool _maximizedBeforeHide = false;
|
bool _maximizedBeforeHide = false;
|
||||||
|
|
||||||
|
mutable QRect _monitorRect;
|
||||||
|
mutable crl::time _monitorLastGot = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
|
@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -391,10 +392,10 @@ void System::showNext() {
|
||||||
const auto &settings = Core::App().settings();
|
const auto &settings = Core::App().settings();
|
||||||
if (alert) {
|
if (alert) {
|
||||||
if (settings.flashBounceNotify() && !Platform::Notifications::SkipFlashBounce()) {
|
if (settings.flashBounceNotify() && !Platform::Notifications::SkipFlashBounce()) {
|
||||||
if (const auto widget = App::wnd()) {
|
if (const auto window = Core::App().activeWindow()) {
|
||||||
if (const auto window = widget->windowHandle()) {
|
if (const auto handle = window->widget()->windowHandle()) {
|
||||||
window->alert(kSystemAlertDuration);
|
handle->alert(kSystemAlertDuration);
|
||||||
// (window, SLOT(_q_clearAlert())); in the future.
|
// (handle, SLOT(_q_clearAlert())); in the future.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -635,9 +636,9 @@ void Manager::notificationActivated(NotificationId id) {
|
||||||
} else {
|
} else {
|
||||||
openNotificationMessage(history, id.msgId);
|
openNotificationMessage(history, id.msgId);
|
||||||
}
|
}
|
||||||
|
onAfterNotificationActivated(id, window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onAfterNotificationActivated(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::openNotificationMessage(
|
void Manager::openNotificationMessage(
|
||||||
|
|
|
@ -32,6 +32,9 @@ class Track;
|
||||||
} // namespace Media
|
} // namespace Media
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
|
|
||||||
|
class SessionController;
|
||||||
|
|
||||||
namespace Notifications {
|
namespace Notifications {
|
||||||
|
|
||||||
enum class ManagerType {
|
enum class ManagerType {
|
||||||
|
@ -217,7 +220,9 @@ protected:
|
||||||
virtual void doClearFromSession(not_null<Main::Session*> session) = 0;
|
virtual void doClearFromSession(not_null<Main::Session*> session) = 0;
|
||||||
virtual void onBeforeNotificationActivated(NotificationId id) {
|
virtual void onBeforeNotificationActivated(NotificationId id) {
|
||||||
}
|
}
|
||||||
virtual void onAfterNotificationActivated(NotificationId id) {
|
virtual void onAfterNotificationActivated(
|
||||||
|
NotificationId id,
|
||||||
|
not_null<SessionController*> window) {
|
||||||
}
|
}
|
||||||
[[nodiscard]] virtual QString accountNameSeparator();
|
[[nodiscard]] virtual QString accountNameSeparator();
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "dialogs/dialogs_layout.h"
|
#include "dialogs/dialogs_layout.h"
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
#include "storage/file_download.h"
|
#include "storage/file_download.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
|
@ -34,7 +35,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
#include "styles/style_window.h"
|
#include "styles/style_window.h"
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
|
#include <QtGui/QScreen>
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
namespace Notifications {
|
namespace Notifications {
|
||||||
|
@ -47,7 +49,10 @@ int notificationMaxHeight() {
|
||||||
|
|
||||||
QPoint notificationStartPosition() {
|
QPoint notificationStartPosition() {
|
||||||
const auto corner = Core::App().settings().notificationsCorner();
|
const auto corner = Core::App().settings().notificationsCorner();
|
||||||
const auto r = psDesktopRect();
|
const auto window = Core::App().activeWindow();
|
||||||
|
const auto r = window
|
||||||
|
? window->widget()->desktopRect()
|
||||||
|
: QGuiApplication::primaryScreen()->availableGeometry();
|
||||||
const auto isLeft = Core::Settings::IsLeftCorner(corner);
|
const auto isLeft = Core::Settings::IsLeftCorner(corner);
|
||||||
const auto isTop = Core::Settings::IsTopCorner(corner);
|
const auto isTop = Core::Settings::IsTopCorner(corner);
|
||||||
const auto x = (isLeft == rtl()) ? (r.x() + r.width() - st::notifyWidth - st::notifyDeltaX) : (r.x() + st::notifyDeltaX);
|
const auto x = (isLeft == rtl()) ? (r.x() + r.width() - st::notifyWidth - st::notifyDeltaX) : (r.x() + st::notifyDeltaX);
|
||||||
|
|
|
@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/shortcuts.h"
|
#include "core/shortcuts.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
|
#include "core/click_handler_types.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
|
@ -78,7 +79,10 @@ void DateClickHandler::setDate(QDate date) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DateClickHandler::onClick(ClickContext context) const {
|
void DateClickHandler::onClick(ClickContext context) const {
|
||||||
App::wnd()->sessionController()->showJumpToDate(_chat, _date);
|
const auto my = context.other.value<ClickHandlerContext>();
|
||||||
|
if (const auto window = my.sessionWindow.get()) {
|
||||||
|
window->showJumpToDate(_chat, _date);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionNavigation::SessionNavigation(not_null<Main::Session*> session)
|
SessionNavigation::SessionNavigation(not_null<Main::Session*> session)
|
||||||
|
|
Loading…
Reference in New Issue