ladybird/Userland/Services/Taskbar/WindowList.cpp
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00

52 lines
1.2 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "WindowList.h"
WindowList& WindowList::the()
{
static WindowList* s_the;
if (!s_the)
s_the = new WindowList;
return *s_the;
}
Window* WindowList::find_parent(const Window& window)
{
if (!window.parent_identifier().is_valid())
return nullptr;
for (auto& it : m_windows) {
auto& w = *it.value;
if (w.identifier() == window.parent_identifier())
return &w;
}
return nullptr;
}
Window* WindowList::window(const WindowIdentifier& identifier)
{
auto it = m_windows.find(identifier);
if (it != m_windows.end())
return it->value;
return nullptr;
}
Window& WindowList::ensure_window(const WindowIdentifier& identifier)
{
auto it = m_windows.find(identifier);
if (it != m_windows.end())
return *it->value;
auto window = make<Window>(identifier);
auto& window_ref = *window;
m_windows.set(identifier, move(window));
return window_ref;
}
void WindowList::remove_window(const WindowIdentifier& identifier)
{
m_windows.remove(identifier);
}