| 392 | } |
| 393 | |
| 394 | TaskbarAppearance TaskbarAttributeWorker::GetConfig(taskbar_iterator taskbar) const |
| 395 | { |
| 396 | const auto& config = m_ConfigManager.GetConfig(); |
| 397 | |
| 398 | if (config.BatterySaverAppearance.Enabled && m_PowerSaver) |
| 399 | { |
| 400 | return WithPreview(txmp::TaskbarState::BatterySaver, config.BatterySaverAppearance); |
| 401 | } |
| 402 | |
| 403 | if (config.TaskViewOpenedAppearance.Enabled && m_TaskViewActive) |
| 404 | { |
| 405 | return WithPreview(txmp::TaskbarState::TaskViewOpened, config.TaskViewOpenedAppearance); |
| 406 | } |
| 407 | |
| 408 | // Task View is ignored by peek, so shall we |
| 409 | if (m_PeekActive) |
| 410 | { |
| 411 | return WithPreview(txmp::TaskbarState::Desktop, config.DesktopAppearance); |
| 412 | } |
| 413 | |
| 414 | // on windows 11, search is considered open when start is, so we need to check for start first. |
| 415 | bool startOpened; |
| 416 | if (m_IsWindows11 && (m_CurrentSearchMonitor != nullptr || m_CurrentFindInStartMonitor != nullptr)) |
| 417 | { |
| 418 | // checking the search monitor is more reliable on windows 11 (if available) |
| 419 | // so check the start monitor to see if it's open and then use the search monitor |
| 420 | // to check *where* it's open. |
| 421 | startOpened = m_CurrentStartMonitor != nullptr && (m_CurrentSearchMonitor == taskbar->first || m_CurrentFindInStartMonitor == taskbar->first); |
| 422 | } |
| 423 | else |
| 424 | { |
| 425 | startOpened = m_CurrentStartMonitor == taskbar->first; |
| 426 | } |
| 427 | |
| 428 | if (config.StartOpenedAppearance.Enabled && startOpened) |
| 429 | { |
| 430 | return WithPreview(txmp::TaskbarState::StartOpened, config.StartOpenedAppearance); |
| 431 | } |
| 432 | |
| 433 | if (config.SearchOpenedAppearance.Enabled && !startOpened && (m_CurrentSearchMonitor == taskbar->first || m_CurrentFindInStartMonitor == taskbar->first)) |
| 434 | { |
| 435 | return WithPreview(txmp::TaskbarState::SearchOpened, config.SearchOpenedAppearance); |
| 436 | } |
| 437 | |
| 438 | auto &maximisedWindows = taskbar->second.MaximisedWindows; |
| 439 | if (config.MaximisedWindowAppearance.Enabled && !maximisedWindows.empty()) |
| 440 | { |
| 441 | if (config.MaximisedWindowAppearance.HasRules()) |
| 442 | { |
| 443 | for (const Window wnd : Window::DesktopWindow().get_ordered_childrens()) |
| 444 | { |
| 445 | // find the highest maximized window in the z-order. |
| 446 | if (maximisedWindows.contains(wnd)) |
| 447 | { |
| 448 | if (const auto rule = config.MaximisedWindowAppearance.FindRule(wnd)) |
| 449 | { |
| 450 | // if it has a rule, use that rule |
| 451 | return *rule; |
no test coverage detected