fixed dpi not initializing when the window shows
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef USEWINSDK
|
||||
#include "windows.h"
|
||||
#include <windows.h>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <QLibrary>
|
||||
|
||||
namespace chatterino {
|
||||
namespace util {
|
||||
@@ -17,7 +20,23 @@ static bool tryHandleDpiChangedMessage(void *message, int &dpi)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static boost::optional<UINT> getWindowDpi(quintptr ptr)
|
||||
{
|
||||
typedef UINT(WINAPI * GetDpiForWindow)(HWND);
|
||||
QLibrary user32("user32.dll", NULL);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
} // namespace util
|
||||
} // namespace chatterino
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user