From 4a73bb7872dc0d52f10306e75f58a572b5e8f249 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 18 Nov 2020 13:32:28 +0300 Subject: [PATCH] Fix main window on Windows. Fixes #9089, fixes #9090. --- .../platform/win/window_title_win.cpp | 2 - .../platform/win/windows_event_filter.cpp | 58 ++++++++----------- 2 files changed, 23 insertions(+), 37 deletions(-) diff --git a/Telegram/SourceFiles/platform/win/window_title_win.cpp b/Telegram/SourceFiles/platform/win/window_title_win.cpp index a1c51f4917..80df1d90d5 100644 --- a/Telegram/SourceFiles/platform/win/window_title_win.cpp +++ b/Telegram/SourceFiles/platform/win/window_title_win.cpp @@ -42,8 +42,6 @@ TitleWidget::TitleWidget(QWidget *parent) }); _close->setPointerCursor(false); - window()->windowHandle()->setFlag(Qt::FramelessWindowHint, true); - setAttribute(Qt::WA_OpaquePaintEvent); resize(width(), _st.height); } diff --git a/Telegram/SourceFiles/platform/win/windows_event_filter.cpp b/Telegram/SourceFiles/platform/win/windows_event_filter.cpp index 0cd10f60dc..bdd55b9579 100644 --- a/Telegram/SourceFiles/platform/win/windows_event_filter.cpp +++ b/Telegram/SourceFiles/platform/win/windows_event_filter.cpp @@ -142,42 +142,30 @@ bool EventFilter::customWindowFrameEvent( if (result) *result = 0; } return true; - case WM_SHOWWINDOW: { - SetWindowLongPtr( - hWnd, - GWL_STYLE, - WS_POPUP - | WS_THICKFRAME - | WS_CAPTION - | WS_SYSMENU - | WS_MAXIMIZEBOX - | WS_MINIMIZEBOX); - } return false; - case WM_NCCALCSIZE: { - //WINDOWPLACEMENT wp; - //wp.length = sizeof(WINDOWPLACEMENT); - //if (GetWindowPlacement(hWnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) { - // LPNCCALCSIZE_PARAMS params = (LPNCCALCSIZE_PARAMS)lParam; - // LPRECT r = (wParam == TRUE) ? ¶ms->rgrc[0] : (LPRECT)lParam; - // HMONITOR hMonitor = MonitorFromPoint({ (r->left + r->right) / 2, (r->top + r->bottom) / 2 }, MONITOR_DEFAULTTONEAREST); - // if (hMonitor) { - // MONITORINFO mi; - // mi.cbSize = sizeof(mi); - // if (GetMonitorInfo(hMonitor, &mi)) { - // *r = mi.rcWork; - // UINT uEdge = (UINT)-1; - // if (IsTaskbarAutoHidden(&mi.rcMonitor, &uEdge)) { - // switch (uEdge) { - // case ABE_LEFT: r->left += 1; break; - // case ABE_RIGHT: r->right -= 1; break; - // case ABE_TOP: r->top += 1; break; - // case ABE_BOTTOM: r->bottom -= 1; break; - // } - // } - // } - // } - //} + WINDOWPLACEMENT wp; + wp.length = sizeof(WINDOWPLACEMENT); + if (GetWindowPlacement(hWnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) { + LPNCCALCSIZE_PARAMS params = (LPNCCALCSIZE_PARAMS)lParam; + LPRECT r = (wParam == TRUE) ? ¶ms->rgrc[0] : (LPRECT)lParam; + HMONITOR hMonitor = MonitorFromPoint({ (r->left + r->right) / 2, (r->top + r->bottom) / 2 }, MONITOR_DEFAULTTONEAREST); + if (hMonitor) { + MONITORINFO mi; + mi.cbSize = sizeof(mi); + if (GetMonitorInfo(hMonitor, &mi)) { + *r = mi.rcWork; + UINT uEdge = (UINT)-1; + if (IsTaskbarAutoHidden(&mi.rcMonitor, &uEdge)) { + switch (uEdge) { + case ABE_LEFT: r->left += 1; break; + case ABE_RIGHT: r->right -= 1; break; + case ABE_TOP: r->top += 1; break; + case ABE_BOTTOM: r->bottom -= 1; break; + } + } + } + } + } if (result) *result = 0; return true; }