Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2020-04-01 17:37:00 +08:00
parent 5e3a3b7109
commit a6af30ce2a
1 changed files with 16 additions and 1 deletions

View File

@ -27,10 +27,15 @@
#endif #endif
#ifndef WM_DWMCOMPOSITIONCHANGED #ifndef WM_DWMCOMPOSITIONCHANGED
// Only available since Windows 7 // Only available since Windows Vista
#define WM_DWMCOMPOSITIONCHANGED 0x031E #define WM_DWMCOMPOSITIONCHANGED 0x031E
#endif #endif
#ifndef WM_DPICHANGED
// Only available since Windows 8.1
#define WM_DPICHANGED 0x02E0
#endif
namespace { namespace {
QScopedPointer<WinNativeEventFilter> instance; QScopedPointer<WinNativeEventFilter> instance;
@ -405,6 +410,15 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
InvalidateRect(msg->hwnd, nullptr, TRUE); InvalidateRect(msg->hwnd, nullptr, TRUE);
break; break;
} }
case WM_DPICHANGED: {
const auto dpiX = LOWORD(msg->wParam);
const auto dpiY = HIWORD(msg->wParam);
// dpiX and dpiY are identical.
qDebug().noquote() << "Window DPI changed:" << (dpiX == dpiY ? dpiY : dpiX);
// FIXME: Temporary solution.
refreshWindow(msg->hwnd);
break;
}
default: default:
break; break;
} }
@ -472,6 +486,7 @@ void WinNativeEventFilter::handleBlurForWindow(LPWINDOW data) {
return; return;
} }
// We prefer using DWM blur on Windows 7 because it has better appearance. // We prefer using DWM blur on Windows 7 because it has better appearance.
// It's supported on Windows Vista as well actually, but Qt has drop it, so we won't do it for Vista.
if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8) { if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8) {
// Windows Aero // Windows Aero
DWM_BLURBEHIND dwmbb; DWM_BLURBEHIND dwmbb;