mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:27:45 +00:00
Taskbar: Update and clear taskbar button rectangles
We need to update all button rectangles when the layout changed. We also need to clear the taskbar button rectangle when we remove a modal window button, so that WindowServer uses the parent's taskbar button rectangle for the minimize animation.
This commit is contained in:
parent
2552e3be00
commit
4897eb8c3e
4 changed files with 33 additions and 4 deletions
|
@ -47,13 +47,27 @@ void TaskbarButton::context_menu_event(GUI::ContextMenuEvent&)
|
||||||
GUI::WindowServerConnection::the().post_message(Messages::WindowServer::WM_PopupWindowMenu(m_identifier.client_id(), m_identifier.window_id(), screen_relative_rect().location()));
|
GUI::WindowServerConnection::the().post_message(Messages::WindowServer::WM_PopupWindowMenu(m_identifier.client_id(), m_identifier.window_id(), screen_relative_rect().location()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskbarButton::resize_event(GUI::ResizeEvent& event)
|
void TaskbarButton::update_taskbar_rect()
|
||||||
{
|
{
|
||||||
GUI::WindowServerConnection::the().post_message(
|
GUI::WindowServerConnection::the().post_message(
|
||||||
Messages::WindowServer::WM_SetWindowTaskbarRect(
|
Messages::WindowServer::WM_SetWindowTaskbarRect(
|
||||||
m_identifier.client_id(),
|
m_identifier.client_id(),
|
||||||
m_identifier.window_id(),
|
m_identifier.window_id(),
|
||||||
screen_relative_rect()));
|
screen_relative_rect()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskbarButton::clear_taskbar_rect()
|
||||||
|
{
|
||||||
|
GUI::WindowServerConnection::the().post_message(
|
||||||
|
Messages::WindowServer::WM_SetWindowTaskbarRect(
|
||||||
|
m_identifier.client_id(),
|
||||||
|
m_identifier.window_id(),
|
||||||
|
{}));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskbarButton::resize_event(GUI::ResizeEvent& event)
|
||||||
|
{
|
||||||
|
update_taskbar_rect();
|
||||||
return GUI::Button::resize_event(event);
|
return GUI::Button::resize_event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,9 @@ class TaskbarButton final : public GUI::Button {
|
||||||
public:
|
public:
|
||||||
virtual ~TaskbarButton() override;
|
virtual ~TaskbarButton() override;
|
||||||
|
|
||||||
|
void update_taskbar_rect();
|
||||||
|
void clear_taskbar_rect();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit TaskbarButton(const WindowIdentifier&);
|
explicit TaskbarButton(const WindowIdentifier&);
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,14 @@ private:
|
||||||
painter.fill_rect(rect(), palette().button());
|
painter.fill_rect(rect(), palette().button());
|
||||||
painter.draw_line({ 0, 1 }, { width() - 1, 1 }, palette().threed_highlight());
|
painter.draw_line({ 0, 1 }, { width() - 1, 1 }, palette().threed_highlight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void did_layout() override
|
||||||
|
{
|
||||||
|
WindowList::the().for_each_window([&](auto& window) {
|
||||||
|
if (auto* button = window.button())
|
||||||
|
static_cast<TaskbarButton*>(button)->update_taskbar_rect();
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TaskbarWindow::TaskbarWindow()
|
TaskbarWindow::TaskbarWindow()
|
||||||
|
@ -184,11 +192,13 @@ void TaskbarWindow::add_window_button(::Window& window, const WindowIdentifier&
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskbarWindow::remove_window_button(::Window& window)
|
void TaskbarWindow::remove_window_button(::Window& window, bool was_removed)
|
||||||
{
|
{
|
||||||
auto* button = window.button();
|
auto* button = window.button();
|
||||||
if (!button)
|
if (!button)
|
||||||
return;
|
return;
|
||||||
|
if (!was_removed)
|
||||||
|
static_cast<TaskbarButton*>(button)->clear_taskbar_rect();
|
||||||
window.set_button(nullptr);
|
window.set_button(nullptr);
|
||||||
button->remove_from_parent();
|
button->remove_from_parent();
|
||||||
}
|
}
|
||||||
|
@ -235,6 +245,8 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
|
||||||
removed_event.client_id(),
|
removed_event.client_id(),
|
||||||
removed_event.window_id());
|
removed_event.window_id());
|
||||||
#endif
|
#endif
|
||||||
|
if (auto* window = WindowList::the().window(identifier))
|
||||||
|
remove_window_button(*window, true);
|
||||||
WindowList::the().remove_window(identifier);
|
WindowList::the().remove_window(identifier);
|
||||||
update();
|
update();
|
||||||
break;
|
break;
|
||||||
|
@ -285,7 +297,7 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
|
||||||
if (!window.is_modal())
|
if (!window.is_modal())
|
||||||
add_window_button(window, identifier);
|
add_window_button(window, identifier);
|
||||||
else
|
else
|
||||||
remove_window_button(window);
|
remove_window_button(window, false);
|
||||||
window.set_title(changed_event.title());
|
window.set_title(changed_event.title());
|
||||||
window.set_rect(changed_event.rect());
|
window.set_rect(changed_event.rect());
|
||||||
window.set_modal(changed_event.is_modal());
|
window.set_modal(changed_event.is_modal());
|
||||||
|
|
|
@ -43,7 +43,7 @@ private:
|
||||||
void on_screen_rect_change(const Gfx::IntRect&);
|
void on_screen_rect_change(const Gfx::IntRect&);
|
||||||
NonnullRefPtr<GUI::Button> create_button(const WindowIdentifier&);
|
NonnullRefPtr<GUI::Button> create_button(const WindowIdentifier&);
|
||||||
void add_window_button(::Window&, const WindowIdentifier&);
|
void add_window_button(::Window&, const WindowIdentifier&);
|
||||||
void remove_window_button(::Window&);
|
void remove_window_button(::Window&, bool);
|
||||||
void update_window_button(::Window&, bool);
|
void update_window_button(::Window&, bool);
|
||||||
::Window* find_window_owner(::Window&) const;
|
::Window* find_window_owner(::Window&) const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue