Skip to content

Commit

Permalink
fix: only invalidate buffers for chat windows (#5666)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz authored Oct 20, 2024
1 parent e35fabf commit 867e3f3
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <kbd>CTRL</kbd> + <kbd>ALT</kbd> + <kbd>N</kbd>). (#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)
Expand Down
11 changes: 7 additions & 4 deletions src/widgets/BaseWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/widgets/BaseWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class BaseWindow : public BaseWidget
Dialog = 1 << 6,
DisableLayoutSave = 1 << 7,
BoundsCheckOnShow = 1 << 8,
ClearBuffersOnDpiChange = 1 << 9,
};

enum ActionOnFocusLoss { Nothing, Delete, Close, Hide };
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/DraggablePopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>(false))
, dragTimer_(this)
Expand Down
8 changes: 8 additions & 0 deletions src/widgets/OverlayWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/widgets/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down

0 comments on commit 867e3f3

Please sign in to comment.