2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-04-03 20:44:35 -03:00
|
|
|
#include "WindowList.h"
|
|
|
|
|
|
2019-04-23 18:14:14 -03:00
|
|
|
WindowList& WindowList::the()
|
|
|
|
|
{
|
2022-01-28 17:22:13 -03:00
|
|
|
static WindowList s_the;
|
|
|
|
|
return s_the;
|
2019-04-23 18:14:14 -03:00
|
|
|
}
|
|
|
|
|
|
2022-04-01 14:58:27 -03:00
|
|
|
Window* WindowList::window(WindowIdentifier const& identifier)
|
2019-04-17 19:39:11 -03:00
|
|
|
{
|
|
|
|
|
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)
|
2019-04-03 20:44:35 -03:00
|
|
|
{
|
|
|
|
|
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)
|
2019-04-03 20:44:35 -03:00
|
|
|
{
|
|
|
|
|
m_windows.remove(identifier);
|
|
|
|
|
}
|