1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:48:11 +00:00
serenity/Userland/Services/WindowServer/WindowStack.cpp
Andreas Kling 2b0e0b602c WindowServer: Keep track of which WindowStack a Window is part of
Each Window now knows which WindowStack it's part of. We call this the
Window::outer_stack(), in preparation for supporting inner stacks. :^)
2021-06-18 17:40:05 +02:00

49 lines
911 B
C++

/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "WindowStack.h"
namespace WindowServer {
WindowStack::WindowStack()
{
}
WindowStack::~WindowStack()
{
}
void WindowStack::add(Window& window)
{
VERIFY(window.outer_stack() == nullptr);
m_windows.append(window);
window.set_outer_stack({}, this);
}
void WindowStack::remove(Window& window)
{
VERIFY(window.outer_stack() == this);
m_windows.remove(window);
window.set_outer_stack({}, nullptr);
}
void WindowStack::move_to_front(Window& window)
{
if (m_windows.last() != &window)
window.invalidate();
m_windows.remove(window);
m_windows.append(window);
}
void WindowStack::set_highlight_window(Window* window)
{
if (!window)
m_highlight_window = nullptr;
else
m_highlight_window = window->make_weak_ptr<Window>();
}
}