diff options
author | Andreas Kling <kling@serenityos.org> | 2021-06-17 17:28:14 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-18 17:40:05 +0200 |
commit | d257f58306558e6c8804334f8bf68cea315df9d5 (patch) | |
tree | cef11ebf16701aca5457fe6f1420f0c3cf42d68f /Userland/Services/WindowServer/WindowStack.cpp | |
parent | 906d3e9f44dee00d2cbc27577dc7f836b464ab72 (diff) | |
download | serenity-d257f58306558e6c8804334f8bf68cea315df9d5.zip |
WindowServer: Add WindowStack concept
This patch moves the window stack out of WindowManager and into its own
WindowStack class.
A WindowStack is an ordered list of windows with an optional highlight
window. The highlight window mechanism is used during Super+Tab window
switching to temporarily bring a window to the front.
This is mostly mechanical, just moving the code to its own class.
Diffstat (limited to 'Userland/Services/WindowServer/WindowStack.cpp')
-rw-r--r-- | Userland/Services/WindowServer/WindowStack.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Userland/Services/WindowServer/WindowStack.cpp b/Userland/Services/WindowServer/WindowStack.cpp new file mode 100644 index 0000000000..324e11fa4c --- /dev/null +++ b/Userland/Services/WindowServer/WindowStack.cpp @@ -0,0 +1,45 @@ +/* + * 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) +{ + m_windows.append(window); +} + +void WindowStack::remove(Window& window) +{ + m_windows.remove(window); +} + +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>(); +} + +} |