From edd4789bf794df3be23c36375e9b6cb67e507cbb Mon Sep 17 00:00:00 2001 From: kornes <28986062+kornes@users.noreply.github.com> Date: Sat, 3 Dec 2022 10:20:31 +0000 Subject: [PATCH] perf: ignore `WM_SHOWWINDOW` hide event (#4198) Co-authored-by: Rasmus Karlsson --- CHANGELOG.md | 2 ++ src/widgets/BaseWindow.cpp | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4fae1414..374027115 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unversioned +- Dev: Ignore `WM_SHOWWINDOW` hide events, causing fewer attempted rescales. (#4198) + ## 2.4.0 - Major: Added support for emotes, badges, and live emote updates from [7TV](https://7tv.app). [Wiki Page](https://wiki.chatterino.com/Third_party_services/#7tv) (#4002, #4062, #4090) diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index 61e9c2c58..a434849db 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -563,9 +563,9 @@ void BaseWindow::resizeEvent(QResizeEvent *) }); }); } -#endif this->calcButtonsSizes(); +#endif } void BaseWindow::moveEvent(QMoveEvent *event) @@ -726,6 +726,11 @@ void BaseWindow::calcButtonsSizes() return; } + if (this->frameless_) + { + return; + } + if ((this->width() / this->scale()) < 300) { if (this->ui_.minButton) @@ -784,6 +789,12 @@ bool BaseWindow::handleDPICHANGED(MSG *msg) bool BaseWindow::handleSHOWWINDOW(MSG *msg) { #ifdef USEWINSDK + // ignore window hide event + if (!msg->wParam) + { + return true; + } + if (auto dpi = getWindowDpi(msg->hwnd)) { float currentScale = (float)dpi.get() / 96.F; @@ -794,16 +805,17 @@ bool BaseWindow::handleSHOWWINDOW(MSG *msg) } } - if (!this->shown_ && this->isVisible()) + if (!this->shown_) { + this->shown_ = true; + if (this->hasCustomWindowFrame()) { - this->shown_ = true; - // disable OS window border const MARGINS margins = {-1}; DwmExtendFrameIntoClientArea(HWND(this->winId()), &margins); } + if (!this->initalBounds_.isNull()) { ::SetWindowPos(msg->hwnd, nullptr, this->initalBounds_.x(), @@ -812,9 +824,9 @@ bool BaseWindow::handleSHOWWINDOW(MSG *msg) SWP_NOZORDER | SWP_NOACTIVATE); this->currentBounds_ = this->initalBounds_; } - } - this->calcButtonsSizes(); + this->calcButtonsSizes(); + } return true; #else