NotificationServer: Make notifications not overlap when they appear

Before this patch, if two or more notifications were created after one
another, they would overlap. This was caused by the previously lowest
notification's m_original_rect being used to calculate the position for
each new notification instead of the notification's actual rect, which
can be different.
This patch makes notifications use each others' rect() method instead,
which makes them appear in the correct position. With that,
m_original_rect has no use anymore, so this patch removes it.
This commit is contained in:
Rummskartoffel 2023-11-04 21:31:31 +01:00 committed by Andreas Kling
parent a281fa3902
commit dcbb8cf0ac
2 changed files with 2 additions and 7 deletions

View file

@ -32,7 +32,6 @@ static void update_notification_window_locations(Gfx::IntRect const& screen_rect
new_window_location = screen_rect.top_right().translated(-window->rect().width() - 24 - 1, 7);
if (window->rect().location() != new_window_location) {
window->move_to(new_window_location);
window->set_original_rect(window->rect());
}
last_window_rect = window->rect();
}
@ -50,8 +49,8 @@ NotificationWindow::NotificationWindow(i32 client_id, String const& text, String
for (auto& window_entry : s_windows) {
auto& window = window_entry.value;
if (!lowest_notification_rect_on_screen.has_value()
|| (window->m_original_rect.y() > lowest_notification_rect_on_screen.value().y()))
lowest_notification_rect_on_screen = window->m_original_rect;
|| (window->rect().y() > lowest_notification_rect_on_screen.value().y()))
lowest_notification_rect_on_screen = window->rect();
}
s_windows.set(m_id, this);
@ -66,8 +65,6 @@ NotificationWindow::NotificationWindow(i32 client_id, String const& text, String
set_rect(rect);
m_original_rect = rect;
auto widget = set_main_widget<GUI::Widget>();
widget->set_fill_with_background_color(true);

View file

@ -16,7 +16,6 @@ class NotificationWindow final : public GUI::Window {
public:
virtual ~NotificationWindow() override = default;
void set_original_rect(Gfx::IntRect original_rect) { m_original_rect = original_rect; }
void set_text(String const&);
void set_title(String const&);
@ -36,7 +35,6 @@ private:
void resize_to_fit_text();
void set_height(int);
Gfx::IntRect m_original_rect;
i32 m_id;
GUI::Label* m_text_label;