2017-09-22 00:50:43 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef USEWINSDK
|
2017-09-23 18:37:51 +02:00
|
|
|
#include <windows.h>
|
|
|
|
#include <boost/optional.hpp>
|
|
|
|
|
2017-12-19 01:32:06 +01:00
|
|
|
#include <QAbstractNativeEventFilter>
|
2017-09-23 18:37:51 +02:00
|
|
|
#include <QLibrary>
|
2017-09-22 00:50:43 +02:00
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
namespace util {
|
2017-09-23 18:37:51 +02:00
|
|
|
static boost::optional<UINT> getWindowDpi(quintptr ptr)
|
|
|
|
{
|
|
|
|
typedef UINT(WINAPI * GetDpiForWindow)(HWND);
|
2017-12-23 23:24:35 +01:00
|
|
|
QLibrary user32("user32.dll", 0);
|
2017-09-23 18:37:51 +02:00
|
|
|
|
|
|
|
GetDpiForWindow getDpiForWindow = (GetDpiForWindow)user32.resolve("GetDpiForWindow");
|
|
|
|
|
|
|
|
if (getDpiForWindow) {
|
|
|
|
UINT value = getDpiForWindow((HWND)ptr);
|
|
|
|
|
|
|
|
return value == 0 ? boost::none : boost::optional<UINT>(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return boost::none;
|
2017-09-22 00:50:43 +02:00
|
|
|
}
|
2017-12-19 01:32:06 +01:00
|
|
|
|
|
|
|
#ifdef USEWINSDK
|
|
|
|
class DpiNativeEventFilter : public QAbstractNativeEventFilter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override
|
|
|
|
{
|
2018-01-14 21:59:45 +01:00
|
|
|
// MSG *msg = reinterpret_cast<MSG *>(message);
|
2017-12-19 01:32:06 +01:00
|
|
|
|
2018-01-14 21:59:45 +01:00
|
|
|
// if (msg->message == WM_NCCREATE) {
|
|
|
|
// QLibrary user32("user32.dll", 0);
|
|
|
|
// {
|
|
|
|
// typedef BOOL(WINAPI * EnableNonClientDpiScaling)(HWND);
|
2017-12-19 01:32:06 +01:00
|
|
|
|
2018-01-14 21:59:45 +01:00
|
|
|
// EnableNonClientDpiScaling enableNonClientDpiScaling =
|
|
|
|
// (EnableNonClientDpiScaling)user32.resolve("EnableNonClientDpiScaling");
|
2017-12-19 01:32:06 +01:00
|
|
|
|
2018-01-14 21:59:45 +01:00
|
|
|
// if (enableNonClientDpiScaling)
|
|
|
|
// enableNonClientDpiScaling(msg->hwnd);
|
|
|
|
// }
|
|
|
|
// }
|
2017-12-19 01:32:06 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2017-09-23 18:37:51 +02:00
|
|
|
} // namespace util
|
|
|
|
} // namespace chatterino
|
2017-09-22 00:50:43 +02:00
|
|
|
|
|
|
|
#endif
|