ladybird/Userland/Services/Taskbar/WindowList.cpp

38 lines
835 B
C++
Raw Normal View History

/*
* 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;
return s_the;
}
2022-04-01 14:58:27 -03:00
Window* WindowList::window(WindowIdentifier const& identifier)
{
auto it = m_windows.find(identifier);
if (it != m_windows.end())
return it->value;
return nullptr;
}
2022-04-01 14:58:27 -03:00
Window& WindowList::ensure_window(WindowIdentifier const& 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;
}
2022-04-01 14:58:27 -03:00
void WindowList::remove_window(WindowIdentifier const& identifier)
{
m_windows.remove(identifier);
}