* @brief Handles the active state change of a window. */
| 303 | * @brief Handles the active state change of a window. |
| 304 | */ |
| 305 | void NativeWindow::onActiveChanged() |
| 306 | { |
| 307 | #if defined(Q_OS_WIN) |
| 308 | if (!isWindows11()) |
| 309 | return; |
| 310 | |
| 311 | auto* window = qobject_cast<QWindow*>(sender()); |
| 312 | if (!window || !m_windows.contains(window)) |
| 313 | return; |
| 314 | |
| 315 | const auto& colors = Misc::ThemeManager::instance().colors(); |
| 316 | QString colorName; |
| 317 | |
| 318 | if (m_colors.contains(window) && !m_colors[window].isEmpty()) |
| 319 | colorName = m_colors[window]; |
| 320 | |
| 321 | else if (window->isActive()) |
| 322 | colorName = colors.value("toolbar_top").toString(); |
| 323 | else |
| 324 | colorName = colors.value("toolbar_bottom").toString(); |
| 325 | |
| 326 | const QColor color(colorName); |
| 327 | const COLORREF colorref = color.red() | (color.green() << 8) | (color.blue() << 16); |
| 328 | |
| 329 | const DWORD attribute = 35; |
| 330 | DwmSetWindowAttribute((HWND)window->winId(), attribute, &colorref, sizeof(colorref)); |
| 331 | #else |
| 332 | Q_UNUSED(this); |
| 333 | #endif |
| 334 | } |