mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
Fix bad window rendering with maximize-on-launch.
I have no idea why MainWindow is ruined completely in case you call MainWindow::show, MainWindow::setWindowState(maximized) and then in the same context (without crl::on_main) create full screen viewer.
This commit is contained in:
parent
1a2b2c15c5
commit
a88423a33f
@ -235,13 +235,16 @@ void Application::run() {
|
|||||||
_window->setupIntro();
|
_window->setupIntro();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEBUG_LOG(("Application Info: showing."));
|
|
||||||
_window->firstShow();
|
_window->widget()->show();
|
||||||
|
|
||||||
const auto currentGeometry = _window->widget()->geometry();
|
const auto currentGeometry = _window->widget()->geometry();
|
||||||
_mediaView = std::make_unique<Media::View::OverlayWidget>();
|
_mediaView = std::make_unique<Media::View::OverlayWidget>();
|
||||||
_window->widget()->setGeometry(currentGeometry);
|
_window->widget()->setGeometry(currentGeometry);
|
||||||
|
|
||||||
|
DEBUG_LOG(("Application Info: showing."));
|
||||||
|
_window->finishFirstShow();
|
||||||
|
|
||||||
if (!locked() && cStartToSettings()) {
|
if (!locked() && cStartToSettings()) {
|
||||||
_window->showSettings();
|
_window->showSettings();
|
||||||
}
|
}
|
||||||
@ -274,6 +277,8 @@ void Application::showPhoto(not_null<const PhotoOpenClickHandler*> link) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Application::showPhoto(not_null<PhotoData*> photo, HistoryItem *item) {
|
void Application::showPhoto(not_null<PhotoData*> photo, HistoryItem *item) {
|
||||||
|
Expects(_mediaView != nullptr);
|
||||||
|
|
||||||
_mediaView->showPhoto(photo, item);
|
_mediaView->showPhoto(photo, item);
|
||||||
_mediaView->activateWindow();
|
_mediaView->activateWindow();
|
||||||
_mediaView->setFocus();
|
_mediaView->setFocus();
|
||||||
@ -282,12 +287,16 @@ void Application::showPhoto(not_null<PhotoData*> photo, HistoryItem *item) {
|
|||||||
void Application::showPhoto(
|
void Application::showPhoto(
|
||||||
not_null<PhotoData*> photo,
|
not_null<PhotoData*> photo,
|
||||||
not_null<PeerData*> peer) {
|
not_null<PeerData*> peer) {
|
||||||
|
Expects(_mediaView != nullptr);
|
||||||
|
|
||||||
_mediaView->showPhoto(photo, peer);
|
_mediaView->showPhoto(photo, peer);
|
||||||
_mediaView->activateWindow();
|
_mediaView->activateWindow();
|
||||||
_mediaView->setFocus();
|
_mediaView->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::showDocument(not_null<DocumentData*> document, HistoryItem *item) {
|
void Application::showDocument(not_null<DocumentData*> document, HistoryItem *item) {
|
||||||
|
Expects(_mediaView != nullptr);
|
||||||
|
|
||||||
if (cUseExternalVideoPlayer()
|
if (cUseExternalVideoPlayer()
|
||||||
&& document->isVideoFile()
|
&& document->isVideoFile()
|
||||||
&& document->loaded()) {
|
&& document->loaded()) {
|
||||||
@ -302,6 +311,8 @@ void Application::showDocument(not_null<DocumentData*> document, HistoryItem *it
|
|||||||
void Application::showTheme(
|
void Application::showTheme(
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
const Data::CloudTheme &cloud) {
|
const Data::CloudTheme &cloud) {
|
||||||
|
Expects(_mediaView != nullptr);
|
||||||
|
|
||||||
_mediaView->showTheme(document, cloud);
|
_mediaView->showTheme(document, cloud);
|
||||||
_mediaView->activateWindow();
|
_mediaView->activateWindow();
|
||||||
_mediaView->setFocus();
|
_mediaView->setFocus();
|
||||||
|
@ -130,7 +130,7 @@ void MainWindow::initHook() {
|
|||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::firstShow() {
|
void MainWindow::createTrayIconMenu() {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
trayIconMenu = new Ui::PopupMenu(nullptr);
|
trayIconMenu = new Ui::PopupMenu(nullptr);
|
||||||
trayIconMenu->deleteOnHide(false);
|
trayIconMenu->deleteOnHide(false);
|
||||||
@ -148,9 +148,48 @@ void MainWindow::firstShow() {
|
|||||||
trayIconMenu->addAction(tr::lng_minimize_to_tray(tr::now), this, SLOT(minimizeToTray()));
|
trayIconMenu->addAction(tr::lng_minimize_to_tray(tr::now), this, SLOT(minimizeToTray()));
|
||||||
trayIconMenu->addAction(notificationActionText, this, SLOT(toggleDisplayNotifyFromTray()));
|
trayIconMenu->addAction(notificationActionText, this, SLOT(toggleDisplayNotifyFromTray()));
|
||||||
trayIconMenu->addAction(tr::lng_quit_from_tray(tr::now), this, SLOT(quitFromTray()));
|
trayIconMenu->addAction(tr::lng_quit_from_tray(tr::now), this, SLOT(quitFromTray()));
|
||||||
|
|
||||||
|
initTrayMenuHook();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::applyInitialWorkMode() {
|
||||||
Global::RefWorkMode().setForced(Global::WorkMode().value(), true);
|
Global::RefWorkMode().setForced(Global::WorkMode().value(), true);
|
||||||
|
|
||||||
psFirstShow();
|
if (cWindowPos().maximized) {
|
||||||
|
DEBUG_LOG(("Window Pos: First show, setting maximized."));
|
||||||
|
setWindowState(Qt::WindowMaximized);
|
||||||
|
}
|
||||||
|
if (cStartInTray()
|
||||||
|
|| (cLaunchMode() == LaunchModeAutoStart
|
||||||
|
&& cStartMinimized()
|
||||||
|
&& !Core::App().passcodeLocked())) {
|
||||||
|
const auto minimizeAndHide = [=] {
|
||||||
|
DEBUG_LOG(("Window Pos: First show, setting minimized after."));
|
||||||
|
setWindowState(windowState() | Qt::WindowMinimized);
|
||||||
|
if (Global::WorkMode().value() == dbiwmTrayOnly
|
||||||
|
|| Global::WorkMode().value() == dbiwmWindowAndTray) {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Platform::IsLinux()) {
|
||||||
|
// If I call hide() synchronously here after show() then on Ubuntu 14.04
|
||||||
|
// it will show a window frame with transparent window body, without content.
|
||||||
|
// And to be able to "Show from tray" one more hide() will be required.
|
||||||
|
crl::on_main(this, minimizeAndHide);
|
||||||
|
} else {
|
||||||
|
minimizeAndHide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setPositionInited();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::finishFirstShow() {
|
||||||
|
createTrayIconMenu();
|
||||||
|
initShadows();
|
||||||
|
applyInitialWorkMode();
|
||||||
|
createGlobalMenu();
|
||||||
|
firstShadowsUpdate();
|
||||||
updateTrayMenu();
|
updateTrayMenu();
|
||||||
|
|
||||||
windowDeactivateEvents(
|
windowDeactivateEvents(
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
explicit MainWindow(not_null<Window::Controller*> controller);
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
void firstShow();
|
void finishFirstShow();
|
||||||
|
|
||||||
void setupPasscodeLock();
|
void setupPasscodeLock();
|
||||||
void clearPasscodeLock();
|
void clearPasscodeLock();
|
||||||
@ -152,9 +152,11 @@ signals:
|
|||||||
private:
|
private:
|
||||||
[[nodiscard]] bool skipTrayClick() const;
|
[[nodiscard]] bool skipTrayClick() const;
|
||||||
|
|
||||||
|
void createTrayIconMenu();
|
||||||
void handleTrayIconActication(
|
void handleTrayIconActication(
|
||||||
QSystemTrayIcon::ActivationReason reason) override;
|
QSystemTrayIcon::ActivationReason reason) override;
|
||||||
|
|
||||||
|
void applyInitialWorkMode();
|
||||||
void ensureLayerCreated();
|
void ensureLayerCreated();
|
||||||
void destroyLayer();
|
void destroyLayer();
|
||||||
|
|
||||||
|
@ -455,7 +455,7 @@ void MainWindow::LibsLoaded() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::psFirstShow() {
|
void MainWindow::initTrayMenuHook() {
|
||||||
const auto trayAvailable = IsSNIAvailable()
|
const auto trayAvailable = IsSNIAvailable()
|
||||||
|| QSystemTrayIcon::isSystemTrayAvailable();
|
|| QSystemTrayIcon::isSystemTrayAvailable();
|
||||||
|
|
||||||
@ -490,30 +490,6 @@ void MainWindow::psFirstShow() {
|
|||||||
LOG(("Not using Unity Launcher count."));
|
LOG(("Not using Unity Launcher count."));
|
||||||
}
|
}
|
||||||
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION
|
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION
|
||||||
|
|
||||||
show();
|
|
||||||
if (cWindowPos().maximized) {
|
|
||||||
DEBUG_LOG(("Window Pos: First show, setting maximized."));
|
|
||||||
setWindowState(Qt::WindowMaximized);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((cLaunchMode() == LaunchModeAutoStart && cStartMinimized())
|
|
||||||
|| cStartInTray()) {
|
|
||||||
// If I call hide() synchronously here after show() then on Ubuntu 14.04
|
|
||||||
// it will show a window frame with transparent window body, without content.
|
|
||||||
// And to be able to "Show from tray" one more hide() will be required.
|
|
||||||
crl::on_main(this, [=] {
|
|
||||||
setWindowState(Qt::WindowMinimized);
|
|
||||||
if (Global::WorkMode().value() == dbiwmTrayOnly
|
|
||||||
|| Global::WorkMode().value() == dbiwmWindowAndTray) {
|
|
||||||
hide();
|
|
||||||
} else {
|
|
||||||
show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setPositionInited();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
|
@ -24,8 +24,6 @@ class MainWindow : public Window::MainWindow {
|
|||||||
public:
|
public:
|
||||||
explicit MainWindow(not_null<Window::Controller*> controller);
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
||||||
|
|
||||||
void psFirstShow();
|
|
||||||
|
|
||||||
virtual QImage iconWithCounter(
|
virtual QImage iconWithCounter(
|
||||||
int size,
|
int size,
|
||||||
int count,
|
int count,
|
||||||
@ -43,6 +41,7 @@ public slots:
|
|||||||
protected:
|
protected:
|
||||||
void unreadCounterChangedHook() override;
|
void unreadCounterChangedHook() override;
|
||||||
|
|
||||||
|
void initTrayMenuHook() override;
|
||||||
bool hasTrayIcon() const override;
|
bool hasTrayIcon() const override;
|
||||||
|
|
||||||
void workmodeUpdated(DBIWorkMode mode) override;
|
void workmodeUpdated(DBIWorkMode mode) override;
|
||||||
|
@ -23,8 +23,6 @@ class MainWindow : public Window::MainWindow {
|
|||||||
public:
|
public:
|
||||||
explicit MainWindow(not_null<Window::Controller*> controller);
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
||||||
|
|
||||||
void psFirstShow();
|
|
||||||
|
|
||||||
bool psFilterNativeEvent(void *event);
|
bool psFilterNativeEvent(void *event);
|
||||||
|
|
||||||
virtual QImage iconWithCounter(int size, int count, style::color bg, style::color fg, bool smallIcon) = 0;
|
virtual QImage iconWithCounter(int size, int count, style::color bg, style::color fg, bool smallIcon) = 0;
|
||||||
@ -87,14 +85,15 @@ protected:
|
|||||||
|
|
||||||
QTimer psUpdatedPositionTimer;
|
QTimer psUpdatedPositionTimer;
|
||||||
|
|
||||||
|
void initShadows() override;
|
||||||
void closeWithoutDestroy() override;
|
void closeWithoutDestroy() override;
|
||||||
|
void createGlobalMenu() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Private;
|
friend class Private;
|
||||||
|
|
||||||
void initTouchBar();
|
void initTouchBar();
|
||||||
void hideAndDeactivate();
|
void hideAndDeactivate();
|
||||||
void createGlobalMenu();
|
|
||||||
void updateTitleCounter();
|
void updateTitleCounter();
|
||||||
void updateIconCounters();
|
void updateIconCounters();
|
||||||
|
|
||||||
|
@ -663,31 +663,8 @@ void MainWindow::updateIconCounters() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::psFirstShow() {
|
void MainWindow::initShadows() {
|
||||||
bool showShadows = true;
|
|
||||||
|
|
||||||
show();
|
|
||||||
_private->enableShadow(winId());
|
_private->enableShadow(winId());
|
||||||
if (cWindowPos().maximized) {
|
|
||||||
DEBUG_LOG(("Window Pos: First show, setting maximized."));
|
|
||||||
setWindowState(Qt::WindowMaximized);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((cLaunchMode() == LaunchModeAutoStart && cStartMinimized()) || cStartInTray()) {
|
|
||||||
setWindowState(Qt::WindowMinimized);
|
|
||||||
if (Global::WorkMode().value() == dbiwmTrayOnly || Global::WorkMode().value() == dbiwmWindowAndTray) {
|
|
||||||
hide();
|
|
||||||
} else {
|
|
||||||
show();
|
|
||||||
}
|
|
||||||
showShadows = false;
|
|
||||||
} else {
|
|
||||||
show();
|
|
||||||
}
|
|
||||||
|
|
||||||
setPositionInited();
|
|
||||||
|
|
||||||
createGlobalMenu();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::createGlobalMenu() {
|
void MainWindow::createGlobalMenu() {
|
||||||
|
@ -808,37 +808,15 @@ void MainWindow::initHook() {
|
|||||||
psInitSysMenu();
|
psInitSysMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QMargins);
|
void MainWindow::initShadows() {
|
||||||
void MainWindow::psFirstShow() {
|
|
||||||
_psShadowWindows.init(this, st::windowShadowFg->c);
|
_psShadowWindows.init(this, st::windowShadowFg->c);
|
||||||
_shadowsWorking = true;
|
_shadowsWorking = true;
|
||||||
|
|
||||||
psUpdateMargins();
|
psUpdateMargins();
|
||||||
|
|
||||||
shadowsUpdate(ShadowsChange::Hidden);
|
shadowsUpdate(ShadowsChange::Hidden);
|
||||||
bool showShadows = true;
|
}
|
||||||
|
|
||||||
show();
|
void MainWindow::firstShadowsUpdate() {
|
||||||
if (cWindowPos().maximized) {
|
if (!(windowState() & Qt::WindowMinimized) && !isHidden()) {
|
||||||
DEBUG_LOG(("Window Pos: First show, setting maximized."));
|
|
||||||
setWindowState(Qt::WindowMaximized);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cStartInTray()
|
|
||||||
|| (cLaunchMode() == LaunchModeAutoStart
|
|
||||||
&& cStartMinimized()
|
|
||||||
&& !Core::App().passcodeLocked())) {
|
|
||||||
DEBUG_LOG(("Window Pos: First show, setting minimized after."));
|
|
||||||
setWindowState(windowState() | Qt::WindowMinimized);
|
|
||||||
if (Global::WorkMode().value() == dbiwmTrayOnly
|
|
||||||
|| Global::WorkMode().value() == dbiwmWindowAndTray) {
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
showShadows = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
setPositionInited();
|
|
||||||
if (showShadows) {
|
|
||||||
shadowsUpdate(ShadowsChange::Moved | ShadowsChange::Resized | ShadowsChange::Shown);
|
shadowsUpdate(ShadowsChange::Moved | ShadowsChange::Resized | ShadowsChange::Shown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -896,6 +874,7 @@ void MainWindow::updateSystemMenu(Qt::WindowState state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(QMargins);
|
||||||
void MainWindow::psUpdateMargins() {
|
void MainWindow::psUpdateMargins() {
|
||||||
if (!ps_hWnd || _inUpdateMargins) return;
|
if (!ps_hWnd || _inUpdateMargins) return;
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ public:
|
|||||||
HWND psHwnd() const;
|
HWND psHwnd() const;
|
||||||
HMENU psMenu() const;
|
HMENU psMenu() const;
|
||||||
|
|
||||||
void psFirstShow();
|
|
||||||
void psInitSysMenu();
|
void psInitSysMenu();
|
||||||
void updateSystemMenu(Qt::WindowState state);
|
void updateSystemMenu(Qt::WindowState state);
|
||||||
void psUpdateMargins();
|
void psUpdateMargins();
|
||||||
@ -77,6 +76,8 @@ protected:
|
|||||||
int32 screenNameChecksum(const QString &name) const override;
|
int32 screenNameChecksum(const QString &name) const override;
|
||||||
void unreadCounterChangedHook() override;
|
void unreadCounterChangedHook() override;
|
||||||
|
|
||||||
|
void initShadows() override;
|
||||||
|
void firstShadowsUpdate() override;
|
||||||
void stateChangedHook(Qt::WindowState state) override;
|
void stateChangedHook(Qt::WindowState state) override;
|
||||||
|
|
||||||
bool hasTrayIcon() const override {
|
bool hasTrayIcon() const override {
|
||||||
|
@ -137,6 +137,8 @@ protected:
|
|||||||
virtual void updateGlobalMenuHook() {
|
virtual void updateGlobalMenuHook() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void initTrayMenuHook() {
|
||||||
|
}
|
||||||
virtual bool hasTrayIcon() const {
|
virtual bool hasTrayIcon() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -148,6 +150,13 @@ protected:
|
|||||||
|
|
||||||
virtual void updateControlsGeometry();
|
virtual void updateControlsGeometry();
|
||||||
|
|
||||||
|
virtual void createGlobalMenu() {
|
||||||
|
}
|
||||||
|
virtual void initShadows() {
|
||||||
|
}
|
||||||
|
virtual void firstShadowsUpdate() {
|
||||||
|
}
|
||||||
|
|
||||||
// This one is overriden in Windows for historical reasons.
|
// This one is overriden in Windows for historical reasons.
|
||||||
virtual int32 screenNameChecksum(const QString &name) const;
|
virtual int32 screenNameChecksum(const QString &name) const;
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@ Controller::~Controller() {
|
|||||||
_widget.clearWidgets();
|
_widget.clearWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::firstShow() {
|
void Controller::finishFirstShow() {
|
||||||
_widget.firstShow();
|
_widget.finishFirstShow();
|
||||||
checkThemeEditor();
|
checkThemeEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
return _sessionController.get();
|
return _sessionController.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void firstShow();
|
void finishFirstShow();
|
||||||
|
|
||||||
void setupPasscodeLock();
|
void setupPasscodeLock();
|
||||||
void clearPasscodeLock();
|
void clearPasscodeLock();
|
||||||
|
Loading…
Reference in New Issue
Block a user