mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:58:11 +00:00
WindowServer: Allow windows to be pinnable (always on top)
This patch adds the concept of a window being "Pinnable" (always drawn on top of other windows). This can be toggled through a new checkable action in the top left corner's window menu.
This commit is contained in:
parent
d5722eab36
commit
f6f14777ac
7 changed files with 87 additions and 0 deletions
|
@ -24,6 +24,8 @@ void WindowStack::add(Window& window)
|
|||
VERIFY(!window.is_on_any_window_stack({}));
|
||||
m_windows.append(window);
|
||||
window.set_window_stack({}, this);
|
||||
|
||||
move_pinned_windows_to_front();
|
||||
}
|
||||
|
||||
void WindowStack::add_to_back(Window& window)
|
||||
|
@ -50,13 +52,45 @@ void WindowStack::move_to_front(Window& window)
|
|||
{
|
||||
if (m_windows.last() != &window)
|
||||
window.invalidate();
|
||||
|
||||
m_windows.remove(window);
|
||||
m_windows.append(window);
|
||||
|
||||
move_pinned_windows_to_front();
|
||||
|
||||
if (window.is_pinned()) {
|
||||
m_windows.remove(window);
|
||||
m_windows.append(window);
|
||||
window.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void WindowStack::move_pinned_windows_to_front()
|
||||
{
|
||||
Window::List pinned_list;
|
||||
for (auto iterator = m_windows.begin(); iterator != m_windows.end(); ++iterator) {
|
||||
auto& window = *iterator;
|
||||
if (window.is_pinned()) {
|
||||
m_windows.remove(window);
|
||||
pinned_list.append(window);
|
||||
iterator = m_windows.begin();
|
||||
}
|
||||
}
|
||||
|
||||
while (!pinned_list.is_empty()) {
|
||||
auto& window = *pinned_list.begin();
|
||||
pinned_list.remove(window);
|
||||
m_windows.append(window);
|
||||
window.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void WindowStack::move_all_windows(WindowStack& new_window_stack, Vector<Window*, 32>& windows_moved, MoveAllWindowsTo move_to)
|
||||
{
|
||||
VERIFY(this != &new_window_stack);
|
||||
|
||||
move_pinned_windows_to_front();
|
||||
|
||||
if (move_to == MoveAllWindowsTo::Front) {
|
||||
while (auto* window = m_windows.take_first()) {
|
||||
window->set_window_stack({}, nullptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue