mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
moved native event handler to it's proper file
This commit is contained in:
parent
f9487b1dae
commit
ded61256de
30
src/main.cpp
30
src/main.cpp
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue