moved native event handler to it's proper file

This commit is contained in:
fourtf 2017-12-19 01:32:06 +01:00
parent f9487b1dae
commit ded61256de
2 changed files with 30 additions and 27 deletions

View file

@ -10,36 +10,11 @@
#include "util/networkmanager.hpp"
#ifdef USEWINSDK
#include "windows.h"
#include "util/nativeeventhelper.hpp"
#endif
namespace {
#ifdef USEWINSDK
class DpiNativeEventFilter : public QAbstractNativeEventFilter
{
public:
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override
{
MSG *msg = reinterpret_cast<MSG *>(message);
if (msg->message == WM_NCCREATE) {
QLibrary user32("user32.dll", NULL);
{
typedef BOOL(WINAPI * EnableNonClientDpiScaling)(HWND);
EnableNonClientDpiScaling enableNonClientDpiScaling =
(EnableNonClientDpiScaling)user32.resolve("EnableNonClientDpiScaling");
// if (enableNonClientDpiScaling)
// enableNonClientDpiScaling(msg->hwnd);
}
}
return false;
}
};
#endif
inline bool initSettings(bool portable)
{
QString settingsPath;
@ -73,8 +48,9 @@ int main(int argc, char *argv[])
QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, true);
QApplication a(argc, argv);
// Install native event handler for hidpi on windows
#ifdef USEWINSDK
a.installNativeEventFilter(new DpiNativeEventFilter);
a.installNativeEventFilter(new chatterino::util::DpiNativeEventFilter);
#endif
// Options

View file

@ -4,6 +4,7 @@
#include <windows.h>
#include <boost/optional.hpp>
#include <QAbstractNativeEventFilter>
#include <QLibrary>
namespace chatterino {
@ -36,6 +37,32 @@ static boost::optional<UINT> getWindowDpi(quintptr ptr)
return boost::none;
}
#ifdef USEWINSDK
class DpiNativeEventFilter : public QAbstractNativeEventFilter
{
public:
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override
{
MSG *msg = reinterpret_cast<MSG *>(message);
if (msg->message == WM_NCCREATE) {
QLibrary user32("user32.dll", NULL);
{
typedef BOOL(WINAPI * EnableNonClientDpiScaling)(HWND);
EnableNonClientDpiScaling enableNonClientDpiScaling =
(EnableNonClientDpiScaling)user32.resolve("EnableNonClientDpiScaling");
// if (enableNonClientDpiScaling)
// enableNonClientDpiScaling(msg->hwnd);
}
}
return false;
}
};
#endif
} // namespace util
} // namespace chatterino