From c229915e9d4b2818155f3650869726fdcbe7e21d Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: ćšć, 21 12æ 2023 14:12:26 +0800 Subject: [PATCH] Prepare to add mica --- src/core/contexts/win32windowcontext.cpp | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-) diff --git a/src/core/contexts/win32windowcontext.cpp b/src/core/contexts/win32windowcontext.cpp index 418a211..1b969cf 100644 --- a/src/core/contexts/win32windowcontext.cpp +++ b/src/core/contexts/win32windowcontext.cpp @@ -914,13 +914,38 @@ const auto &oldVar = *static_cast<const QVariant *>(args[2]); if (key == QStringLiteral("no-frame-shadow")) { + if (!windowId) + return; if (newVar.toBool()) { // TODO: set off } else { // TODO: set on } - } + } else if (key == QStringLiteral("mica-material")) { + if (!windowId || !isWin11OrGreater()) + return; + const auto hwnd = reinterpret_cast<HWND>(windowId); + if (newVar.toBool()) { + /* + // We need to extend the window frame into the whole client area to be able + // to see the blurred window background. + static constexpr const MARGINS margins = {-1, -1, -1, -1}; + ::DwmExtendFrameIntoClientArea(hwnd, &margins); + + // Use official DWM API to enable Mica/Mica Alt, available since Windows 11 + // (10.0.22000). + const DWM_SYSTEMBACKDROP_TYPE blurType = + DWMSBT_MAINWINDOW; // This one is Mica, if you want to enable Mica Alt, + // use DWMSBT_TABBEDWINDOW instead. + DynamicApis::instance().pDwmSetWindowAttribute( + hwnd, DWMWA_SYSTEMBACKDROP_TYPE, &blurType, sizeof(blurType)); + + */ + } else { + // TODO: set off + } + } return; } -- Gitblit v1.9.1