From 867e3f3ab08ac8c7bd807f2fe8edfb1518ddcee5 Mon Sep 17 00:00:00 2001 From: nerix Date: Mon, 21 Oct 2024 00:57:37 +0200 Subject: [PATCH] fix: only invalidate buffers for chat windows (#5666) --- CHANGELOG.md | 2 +- src/widgets/BaseWindow.cpp | 11 +++++++---- src/widgets/BaseWindow.hpp | 1 + src/widgets/DraggablePopup.cpp | 6 +++--- src/widgets/OverlayWindow.cpp | 8 ++++++++ src/widgets/Window.cpp | 4 +++- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a08aac4..3555762c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - Major: Add option to show pronouns in user card. (#5442, #5583) - Major: Release plugins alpha. (#5288) -- Major: Improve high-DPI support on Windows. (#4868, #5391, #5664) +- Major: Improve high-DPI support on Windows. (#4868, #5391, #5664, #5666) - Major: Added transparent overlay window (default keybind: CTRL + ALT + N). (#4746, #5643, #5659) - Minor: Removed the Ctrl+Shift+L hotkey for toggling the "live only" tab visibility state. (#5530) - Minor: Add support for Shared Chat messages. Shared chat messages can be filtered with the `flags.shared` filter variable, or with search using `is:shared`. Some messages like subscriptions are filtered on purpose to avoid confusion for the broadcaster. If you have both channels participating in Shared Chat open, only one of the message triggering your highlight will trigger. (#5606, #5625) diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index a82a364f..31f72a3d 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -877,10 +877,13 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, break; case WM_DPICHANGED: { - // wait for Qt to process this message - postToThread([] { - getApp()->getWindows()->invalidateChannelViewBuffers(); - }); + if (this->flags_.has(ClearBuffersOnDpiChange)) + { + // wait for Qt to process this message + postToThread([] { + getApp()->getWindows()->invalidateChannelViewBuffers(); + }); + } } break; diff --git a/src/widgets/BaseWindow.hpp b/src/widgets/BaseWindow.hpp index 2f216864..1f0455dc 100644 --- a/src/widgets/BaseWindow.hpp +++ b/src/widgets/BaseWindow.hpp @@ -37,6 +37,7 @@ public: Dialog = 1 << 6, DisableLayoutSave = 1 << 7, BoundsCheckOnShow = 1 << 8, + ClearBuffersOnDpiChange = 1 << 9, }; enum ActionOnFocusLoss { Nothing, Delete, Close, Hide }; diff --git a/src/widgets/DraggablePopup.cpp b/src/widgets/DraggablePopup.cpp index 84a57c0f..6b7e9eaf 100644 --- a/src/widgets/DraggablePopup.cpp +++ b/src/widgets/DraggablePopup.cpp @@ -36,9 +36,9 @@ namespace { DraggablePopup::DraggablePopup(bool closeAutomatically, QWidget *parent) : BaseWindow( - closeAutomatically - ? popupFlagsCloseAutomatically | BaseWindow::DisableLayoutSave - : popupFlags | BaseWindow::DisableLayoutSave, + (closeAutomatically ? popupFlagsCloseAutomatically : popupFlags) | + BaseWindow::DisableLayoutSave | + BaseWindow::ClearBuffersOnDpiChange, parent) , lifetimeHack_(std::make_shared(false)) , dragTimer_(this) diff --git a/src/widgets/OverlayWindow.cpp b/src/widgets/OverlayWindow.cpp index b6cff796..ce7ee248 100644 --- a/src/widgets/OverlayWindow.cpp +++ b/src/widgets/OverlayWindow.cpp @@ -7,6 +7,7 @@ #include "singletons/Emotes.hpp" #include "singletons/Settings.hpp" #include "singletons/WindowManager.hpp" +#include "util/PostToThread.hpp" #include "widgets/BaseWidget.hpp" #include "widgets/helper/ChannelView.hpp" #include "widgets/helper/InvisibleSizeGrip.hpp" @@ -312,6 +313,13 @@ bool OverlayWindow::nativeEvent(const QByteArray &eventType, void *message, } break; # endif + case WM_DPICHANGED: { + // wait for Qt to process this message, same as in BaseWindow + postToThread([] { + getApp()->getWindows()->invalidateChannelViewBuffers(); + }); + } + break; default: return QWidget::nativeEvent(eventType, message, result); diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index 4dcb1450..92b85c72 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -52,7 +52,9 @@ namespace chatterino { Window::Window(WindowType type, QWidget *parent) - : BaseWindow(BaseWindow::EnableCustomFrame, parent) + : BaseWindow( + {BaseWindow::EnableCustomFrame, BaseWindow::ClearBuffersOnDpiChange}, + parent) , type_(type) , notebook_(new SplitNotebook(this)) {