From 322367c1b1f7606f37a517d13df6a4f905a59a69 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 2 Jan 2020 14:57:36 +0300 Subject: [PATCH] Correctly minimize window. Fixes #6932. --- .../platform/win/main_window_win.cpp | 2 +- .../platform/win/window_title_win.cpp | 13 +++++++----- .../platform/win/windows_event_filter.cpp | 21 ++++++++++++++----- .../SourceFiles/window/window_controller.cpp | 2 +- Telegram/lib_ui | 2 +- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Telegram/SourceFiles/platform/win/main_window_win.cpp b/Telegram/SourceFiles/platform/win/main_window_win.cpp index 1b6c8c370..d62a79590 100644 --- a/Telegram/SourceFiles/platform/win/main_window_win.cpp +++ b/Telegram/SourceFiles/platform/win/main_window_win.cpp @@ -825,7 +825,7 @@ void MainWindow::psFirstShow() { && cStartMinimized() && !Core::App().passcodeLocked())) { DEBUG_LOG(("Window Pos: First show, setting minimized after.")); - setWindowState(Qt::WindowMinimized); + setWindowState(windowState() | Qt::WindowMinimized); if (Global::WorkMode().value() == dbiwmTrayOnly || Global::WorkMode().value() == dbiwmWindowAndTray) { hide(); diff --git a/Telegram/SourceFiles/platform/win/window_title_win.cpp b/Telegram/SourceFiles/platform/win/window_title_win.cpp index 9e2687f4f..6e098f46a 100644 --- a/Telegram/SourceFiles/platform/win/window_title_win.cpp +++ b/Telegram/SourceFiles/platform/win/window_title_win.cpp @@ -23,17 +23,20 @@ TitleWidget::TitleWidget(QWidget *parent) , _close(this, _st.close) , _shadow(this, st::titleShadow) , _maximizedState(parent->window()->windowState() & Qt::WindowMaximized) { - _minimize->setClickedCallback([this]() { - window()->setWindowState(Qt::WindowMinimized); + _minimize->setClickedCallback([=] { + window()->setWindowState( + window()->windowState() | Qt::WindowMinimized); _minimize->clearState(); }); _minimize->setPointerCursor(false); - _maximizeRestore->setClickedCallback([this]() { - window()->setWindowState(_maximizedState ? Qt::WindowNoState : Qt::WindowMaximized); + _maximizeRestore->setClickedCallback([=] { + window()->setWindowState(_maximizedState + ? Qt::WindowNoState + : Qt::WindowMaximized); _maximizeRestore->clearState(); }); _maximizeRestore->setPointerCursor(false); - _close->setClickedCallback([this]() { + _close->setClickedCallback([=] { window()->close(); _close->clearState(); }); diff --git a/Telegram/SourceFiles/platform/win/windows_event_filter.cpp b/Telegram/SourceFiles/platform/win/windows_event_filter.cpp index b9302165c..b7766049b 100644 --- a/Telegram/SourceFiles/platform/win/windows_event_filter.cpp +++ b/Telegram/SourceFiles/platform/win/windows_event_filter.cpp @@ -238,13 +238,24 @@ bool EventFilter::mainWindowEvent( } return false; case WM_COMMAND: { - if (HIWORD(wParam)) return false; + if (HIWORD(wParam)) { + return false; + } int cmd = LOWORD(wParam); switch (cmd) { - case SC_CLOSE: _window->close(); return true; - case SC_MINIMIZE: _window->setWindowState(Qt::WindowMinimized); return true; - case SC_MAXIMIZE: _window->setWindowState(Qt::WindowMaximized); return true; - case SC_RESTORE: _window->setWindowState(Qt::WindowNoState); return true; + case SC_CLOSE: + _window->close(); + return true; + case SC_MINIMIZE: + _window->setWindowState( + _window->windowState() | Qt::WindowMinimized); + return true; + case SC_MAXIMIZE: + _window->setWindowState(Qt::WindowMaximized); + return true; + case SC_RESTORE: + _window->setWindowState(Qt::WindowNoState); + return true; } } return true; diff --git a/Telegram/SourceFiles/window/window_controller.cpp b/Telegram/SourceFiles/window/window_controller.cpp index d281aff33..a6e4c8da9 100644 --- a/Telegram/SourceFiles/window/window_controller.cpp +++ b/Telegram/SourceFiles/window/window_controller.cpp @@ -102,7 +102,7 @@ void Controller::minimize() { if (Global::WorkMode().value() == dbiwmTrayOnly) { _widget.minimizeToTray(); } else { - _widget.setWindowState(Qt::WindowMinimized); + _widget.setWindowState(_widget.windowState() | Qt::WindowMinimized); } } diff --git a/Telegram/lib_ui b/Telegram/lib_ui index d30d36160..0aadf4ca7 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit d30d361609d4b76d3a55b1329642caee30b82264 +Subproject commit 0aadf4ca7d483600122bacac1bf24bb6cfe7e448