| 564 | } |
| 565 | |
| 566 | void ms::SurfaceStack::add_observer(std::shared_ptr<ms::Observer> const& observer) |
| 567 | { |
| 568 | observers.add(observer); |
| 569 | |
| 570 | // Notify observer of existing surfaces. |
| 571 | // |
| 572 | // The surfaces are sent with the most-recently focused first and the |
| 573 | // least-recently focused last. |
| 574 | RecursiveReadLock lk(guard); |
| 575 | for (auto const& surface : std::ranges::reverse_view(focus_order)) |
| 576 | { |
| 577 | if (auto const locked = surface.lock()) |
| 578 | observer->surface_exists(locked); |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | void ms::SurfaceStack::remove_observer(std::weak_ptr<ms::Observer> const& observer) |
| 583 | { |
no test coverage detected