moved native event handler to it's proper file
This commit is contained in:
+3
-27
@@ -10,36 +10,11 @@
|
|||||||
#include "util/networkmanager.hpp"
|
#include "util/networkmanager.hpp"
|
||||||
|
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
#include "windows.h"
|
#include "util/nativeeventhelper.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
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)
|
inline bool initSettings(bool portable)
|
||||||
{
|
{
|
||||||
QString settingsPath;
|
QString settingsPath;
|
||||||
@@ -73,8 +48,9 @@ int main(int argc, char *argv[])
|
|||||||
QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, true);
|
QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, true);
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
|
// Install native event handler for hidpi on windows
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
a.installNativeEventFilter(new DpiNativeEventFilter);
|
a.installNativeEventFilter(new chatterino::util::DpiNativeEventFilter);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
|
#include <QAbstractNativeEventFilter>
|
||||||
#include <QLibrary>
|
#include <QLibrary>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
@@ -36,6 +37,32 @@ static boost::optional<UINT> getWindowDpi(quintptr ptr)
|
|||||||
|
|
||||||
return boost::none;
|
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 util
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user