moved dpi handling out of helper file

This commit is contained in:
fourtf 2018-01-14 21:59:45 +01:00
parent e19a83679f
commit e0372a2453
2 changed files with 21 additions and 27 deletions

View file

@ -9,19 +9,6 @@
namespace chatterino {
namespace util {
static bool tryHandleDpiChangedMessage(void *message, int &dpi)
{
MSG *msg = reinterpret_cast<MSG *>(message);
// WM_DPICHANGED
if (msg->message == 0x02E0) {
dpi = HIWORD(msg->wParam);
return true;
}
return false;
}
static boost::optional<UINT> getWindowDpi(quintptr ptr)
{
typedef UINT(WINAPI * GetDpiForWindow)(HWND);

View file

@ -7,6 +7,8 @@
#include <QDebug>
#include <QIcon>
#include <windows.h>
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<MSG *>(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<int>(this->width() * scale),
static_cast<int>(this->height() * scale));
return true;
}
return QWidget::nativeEvent(eventType, message, result);
}
} // namespace widgets
#endif
} // namespace widgets