forked from github_mirror/framelesshelper
parent
30dc4892f1
commit
22c0aa26df
|
@ -112,13 +112,19 @@
|
||||||
#define WM_DPICHANGED 0x02E0
|
#define WM_DPICHANGED 0x02E0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef WNEF_GENERATE_WINAPI
|
||||||
|
#define WNEF_GENERATE_WINAPI(funcName, resultType, ...) \
|
||||||
|
using _WNEF_WINAPI_##funcName = resultType (WINAPI *) (__VA_ARGS__); \
|
||||||
|
_WNEF_WINAPI_##funcName m_lp##funcName = nullptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef WNEF_RESOLVE_WINAPI
|
#ifndef WNEF_RESOLVE_WINAPI
|
||||||
#define WNEF_RESOLVE_WINAPI(libName, funcName) \
|
#define WNEF_RESOLVE_WINAPI(libName, funcName) \
|
||||||
if (!m_##funcName) { \
|
if (!m_lp##funcName) { \
|
||||||
QLibrary library(QString::fromUtf8(#libName)); \
|
QLibrary library(QString::fromUtf8(#libName)); \
|
||||||
m_##funcName = \
|
m_lp##funcName = \
|
||||||
reinterpret_cast<lp##funcName>(library.resolve(#funcName)); \
|
reinterpret_cast<_WNEF_WINAPI_##funcName>(library.resolve(#funcName)); \
|
||||||
if (!m_##funcName) { \
|
if (!m_lp##funcName) { \
|
||||||
qWarning().noquote() \
|
qWarning().noquote() \
|
||||||
<< "Failed to resolve" << #funcName << "from" << #libName \
|
<< "Failed to resolve" << #funcName << "from" << #libName \
|
||||||
<< "-->" << library.errorString(); \
|
<< "-->" << library.errorString(); \
|
||||||
|
@ -126,6 +132,15 @@
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef WNEF_USE_WINAPI
|
||||||
|
#define WNEF_USE_WINAPI(funcName, ...) \
|
||||||
|
if (m_lp##funcName) {\
|
||||||
|
m_lp##funcName(__VA_ARGS__);\
|
||||||
|
} else {\
|
||||||
|
qWarning().noquote() << "Uninitialized function:" << #funcName;\
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using WINDOWTHEMEATTRIBUTETYPE = enum _WINDOWTHEMEATTRIBUTETYPE {
|
using WINDOWTHEMEATTRIBUTETYPE = enum _WINDOWTHEMEATTRIBUTETYPE {
|
||||||
|
@ -199,52 +214,24 @@ using APPBARDATA = struct _APPBARDATA {
|
||||||
LPARAM lParam;
|
LPARAM lParam;
|
||||||
};
|
};
|
||||||
|
|
||||||
using lpGetSystemDpiForProcess = UINT(WINAPI *)(HANDLE);
|
WNEF_GENERATE_WINAPI(GetSystemDpiForProcess, UINT, HANDLE)
|
||||||
lpGetSystemDpiForProcess m_GetSystemDpiForProcess = nullptr;
|
WNEF_GENERATE_WINAPI(GetDpiForWindow, UINT, HWND)
|
||||||
|
WNEF_GENERATE_WINAPI(GetDpiForSystem, UINT)
|
||||||
using lpGetDpiForWindow = UINT(WINAPI *)(HWND);
|
WNEF_GENERATE_WINAPI(GetSystemMetricsForDpi, int, int, UINT)
|
||||||
lpGetDpiForWindow m_GetDpiForWindow = nullptr;
|
WNEF_GENERATE_WINAPI(GetDpiForMonitor, HRESULT, HMONITOR, MONITOR_DPI_TYPE, UINT *,
|
||||||
|
UINT *)
|
||||||
using lpGetDpiForSystem = UINT(WINAPI *)();
|
WNEF_GENERATE_WINAPI(SetWindowCompositionAttribute, BOOL, HWND, const WINDOWCOMPOSITIONATTRIBDATA *)
|
||||||
lpGetDpiForSystem m_GetDpiForSystem = nullptr;
|
WNEF_GENERATE_WINAPI(SetWindowThemeAttribute, HRESULT, HWND,
|
||||||
|
WINDOWTHEMEATTRIBUTETYPE,
|
||||||
using lpGetSystemMetricsForDpi = int(WINAPI *)(int, UINT);
|
PVOID, DWORD)
|
||||||
lpGetSystemMetricsForDpi m_GetSystemMetricsForDpi = nullptr;
|
WNEF_GENERATE_WINAPI(IsThemeActive, BOOL)
|
||||||
|
WNEF_GENERATE_WINAPI(DwmEnableBlurBehindWindow, HRESULT, HWND,
|
||||||
using lpGetDpiForMonitor = HRESULT(WINAPI *)(HMONITOR, MONITOR_DPI_TYPE, UINT *,
|
const DWM_BLURBEHIND *)
|
||||||
UINT *);
|
WNEF_GENERATE_WINAPI(DwmExtendFrameIntoClientArea, HRESULT, HWND, const MARGINS *)
|
||||||
lpGetDpiForMonitor m_GetDpiForMonitor = nullptr;
|
WNEF_GENERATE_WINAPI(DwmIsCompositionEnabled, HRESULT, BOOL *)
|
||||||
|
WNEF_GENERATE_WINAPI(DwmSetWindowAttribute, HRESULT, HWND, DWORD, LPCVOID, DWORD)
|
||||||
using lpSetWindowCompositionAttribute =
|
WNEF_GENERATE_WINAPI(SHAppBarMessage, UINT_PTR, DWORD, APPBARDATA *)
|
||||||
BOOL(WINAPI *)(HWND, const WINDOWCOMPOSITIONATTRIBDATA *);
|
WNEF_GENERATE_WINAPI(GetDeviceCaps, int, HDC, int)
|
||||||
lpSetWindowCompositionAttribute m_SetWindowCompositionAttribute = nullptr;
|
|
||||||
|
|
||||||
using lpSetWindowThemeAttribute = HRESULT(WINAPI *)(HWND,
|
|
||||||
WINDOWTHEMEATTRIBUTETYPE,
|
|
||||||
PVOID, DWORD);
|
|
||||||
lpSetWindowThemeAttribute m_SetWindowThemeAttribute = nullptr;
|
|
||||||
|
|
||||||
using lpIsThemeActive = BOOL(WINAPI *)();
|
|
||||||
lpIsThemeActive m_IsThemeActive = nullptr;
|
|
||||||
|
|
||||||
using lpDwmEnableBlurBehindWindow = HRESULT(WINAPI *)(HWND,
|
|
||||||
const DWM_BLURBEHIND *);
|
|
||||||
lpDwmEnableBlurBehindWindow m_DwmEnableBlurBehindWindow = nullptr;
|
|
||||||
|
|
||||||
using lpDwmExtendFrameIntoClientArea = HRESULT(WINAPI *)(HWND, const MARGINS *);
|
|
||||||
lpDwmExtendFrameIntoClientArea m_DwmExtendFrameIntoClientArea = nullptr;
|
|
||||||
|
|
||||||
using lpDwmIsCompositionEnabled = HRESULT(WINAPI *)(BOOL *);
|
|
||||||
lpDwmIsCompositionEnabled m_DwmIsCompositionEnabled = nullptr;
|
|
||||||
|
|
||||||
using lpDwmSetWindowAttribute = HRESULT(WINAPI *)(HWND, DWORD, LPCVOID, DWORD);
|
|
||||||
lpDwmSetWindowAttribute m_DwmSetWindowAttribute = nullptr;
|
|
||||||
|
|
||||||
using lpSHAppBarMessage = UINT_PTR(WINAPI *)(DWORD, APPBARDATA *);
|
|
||||||
lpSHAppBarMessage m_SHAppBarMessage = nullptr;
|
|
||||||
|
|
||||||
using lpGetDeviceCaps = int(WINAPI *)(HDC, int);
|
|
||||||
lpGetDeviceCaps m_GetDeviceCaps = nullptr;
|
|
||||||
|
|
||||||
const UINT m_defaultDotsPerInch = USER_DEFAULT_SCREEN_DPI;
|
const UINT m_defaultDotsPerInch = USER_DEFAULT_SCREEN_DPI;
|
||||||
|
|
||||||
|
@ -914,8 +901,8 @@ qreal WinNativeEventFilter::getDevicePixelRatioForWindow(HWND handle) {
|
||||||
int WinNativeEventFilter::getSystemMetricsForWindow(HWND handle, int index) {
|
int WinNativeEventFilter::getSystemMetricsForWindow(HWND handle, int index) {
|
||||||
if (m_GetSystemMetricsForDpi) {
|
if (m_GetSystemMetricsForDpi) {
|
||||||
return m_GetSystemMetricsForDpi(index,
|
return m_GetSystemMetricsForDpi(index,
|
||||||
static_cast<UINT>(getPreferedNumber(
|
static_cast<UINT>(std::round(getPreferedNumber(
|
||||||
getDotsPerInchForWindow(handle))));
|
getDotsPerInchForWindow(handle)))));
|
||||||
} else {
|
} else {
|
||||||
return std::round(GetSystemMetrics(index) * getDevicePixelRatioForWindow(handle));
|
return std::round(GetSystemMetrics(index) * getDevicePixelRatioForWindow(handle));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue