From 3ff033cdf3b5bc49101e983592a79f44902f36e7 Mon Sep 17 00:00:00 2001 From: Kirsan Date: Fri, 30 Mar 2018 18:36:31 +0300 Subject: [PATCH] Fix for https://github.com/telegramdesktop/tdesktop/issues/4544 (cherry picked from commit d99c757d44d7c31fbb0eb290f273ad4d2d464255) --- .../platform/win/main_window_win.cpp | 22 +++++++++++++------ .../platform/win/main_window_win.h | 3 +++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/platform/win/main_window_win.cpp b/Telegram/SourceFiles/platform/win/main_window_win.cpp index 93bc5c4ae..8495050ef 100644 --- a/Telegram/SourceFiles/platform/win/main_window_win.cpp +++ b/Telegram/SourceFiles/platform/win/main_window_win.cpp @@ -873,7 +873,9 @@ void MainWindow::updateSystemMenu(Qt::WindowState state) { } void MainWindow::psUpdateMargins() { - if (!ps_hWnd) return; + if (!ps_hWnd || _inUpdateMargins) return; + + _inUpdateMargins = true; RECT r, a; @@ -898,13 +900,18 @@ void MainWindow::psUpdateMargins() { _deltaLeft = w.left - m.left; _deltaTop = w.top - m.top; + _deltaRight = m.right - w.right; + _deltaBottom = m.bottom - w.bottom; - margins.setLeft(margins.left() - w.left + m.left); - margins.setRight(margins.right() - m.right + w.right); - margins.setBottom(margins.bottom() - m.bottom + w.bottom); - margins.setTop(margins.top() - w.top + m.top); - } else { - _deltaLeft = _deltaTop = 0; + margins.setLeft(margins.left() - _deltaLeft); + margins.setRight(margins.right() - _deltaRight); + margins.setBottom(margins.bottom() - _deltaBottom); + margins.setTop(margins.top() - _deltaTop); + } else if (_deltaLeft != 0 || _deltaTop != 0 || _deltaRight != 0 || _deltaBottom != 0) { + RECT w; + GetWindowRect(ps_hWnd, &w); + SetWindowPos(ps_hWnd, 0, 0, 0, w.right - w.left - _deltaLeft - _deltaRight, w.bottom - w.top - _deltaBottom - _deltaTop, SWP_NOMOVE | SWP_NOSENDCHANGING | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREPOSITION); + _deltaLeft = _deltaTop = _deltaRight = _deltaBottom = 0; } QPlatformNativeInterface *i = QGuiApplication::platformNativeInterface(); @@ -918,6 +925,7 @@ void MainWindow::psUpdateMargins() { } } } + _inUpdateMargins = false; } HWND MainWindow::psHwnd() const { diff --git a/Telegram/SourceFiles/platform/win/main_window_win.h b/Telegram/SourceFiles/platform/win/main_window_win.h index 96858cbb3..5bba35806 100644 --- a/Telegram/SourceFiles/platform/win/main_window_win.h +++ b/Telegram/SourceFiles/platform/win/main_window_win.h @@ -103,6 +103,7 @@ private: bool _shadowsWorking = false; bool _themeInited = false; + bool _inUpdateMargins = false; HWND ps_hWnd = nullptr; HWND ps_tbHider_hWnd = nullptr; @@ -113,6 +114,8 @@ private: int _deltaLeft = 0; int _deltaTop = 0; + int _deltaRight = 0; + int _deltaBottom = 0; };