diff --git a/src/util/nativeeventhelper.hpp b/src/util/nativeeventhelper.hpp index da41d68d8..2995b1ff0 100644 --- a/src/util/nativeeventhelper.hpp +++ b/src/util/nativeeventhelper.hpp @@ -9,19 +9,6 @@ namespace chatterino { namespace util { -static bool tryHandleDpiChangedMessage(void *message, int &dpi) -{ - MSG *msg = reinterpret_cast(message); - - // WM_DPICHANGED - if (msg->message == 0x02E0) { - dpi = HIWORD(msg->wParam); - - return true; - } - return false; -} - static boost::optional getWindowDpi(quintptr ptr) { typedef UINT(WINAPI * GetDpiForWindow)(HWND); @@ -44,20 +31,20 @@ class DpiNativeEventFilter : public QAbstractNativeEventFilter public: bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override { -// MSG *msg = reinterpret_cast(message); + // MSG *msg = reinterpret_cast(message); -// if (msg->message == WM_NCCREATE) { -// QLibrary user32("user32.dll", 0); -// { -// typedef BOOL(WINAPI * EnableNonClientDpiScaling)(HWND); + // if (msg->message == WM_NCCREATE) { + // QLibrary user32("user32.dll", 0); + // { + // typedef BOOL(WINAPI * EnableNonClientDpiScaling)(HWND); -// EnableNonClientDpiScaling enableNonClientDpiScaling = -// (EnableNonClientDpiScaling)user32.resolve("EnableNonClientDpiScaling"); + // EnableNonClientDpiScaling enableNonClientDpiScaling = + // (EnableNonClientDpiScaling)user32.resolve("EnableNonClientDpiScaling"); - // if (enableNonClientDpiScaling) - // enableNonClientDpiScaling(msg->hwnd); -// } -// } + // if (enableNonClientDpiScaling) + // enableNonClientDpiScaling(msg->hwnd); + // } + // } return false; } }; diff --git a/src/widgets/basewindow.cpp b/src/widgets/basewindow.cpp index f3dcbf47a..54c5c517b 100644 --- a/src/widgets/basewindow.cpp +++ b/src/widgets/basewindow.cpp @@ -7,6 +7,8 @@ #include #include +#include + namespace chatterino { namespace widgets { @@ -60,10 +62,12 @@ void BaseWindow::leaveEvent(QEvent *) #ifdef USEWINSDK bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) { - int dpi; + MSG *msg = reinterpret_cast(message); - if (util::tryHandleDpiChangedMessage(message, dpi)) { + // WM_DPICHANGED + if (msg->message == 0x02E0) { qDebug() << "dpi changed"; + int dpi = HIWORD(msg->wParam); float oldDpiMultiplier = this->dpiMultiplier; this->dpiMultiplier = dpi / 96.f; @@ -73,10 +77,13 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, long *r this->resize(static_cast(this->width() * scale), static_cast(this->height() * scale)); + + return true; } return QWidget::nativeEvent(eventType, message, result); -} +} // namespace widgets + #endif } // namespace widgets