From dcbb8cf0acf21fdd520d832ac551ed00b805bea2 Mon Sep 17 00:00:00 2001 From: Rummskartoffel Date: Sat, 4 Nov 2023 21:31:31 +0100 Subject: [PATCH] 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. --- .../Services/NotificationServer/NotificationWindow.cpp | 7 ++----- Userland/Services/NotificationServer/NotificationWindow.h | 2 -- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Userland/Services/NotificationServer/NotificationWindow.cpp b/Userland/Services/NotificationServer/NotificationWindow.cpp index 6373e33a34..65b454f384 100644 --- a/Userland/Services/NotificationServer/NotificationWindow.cpp +++ b/Userland/Services/NotificationServer/NotificationWindow.cpp @@ -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(); widget->set_fill_with_background_color(true); diff --git a/Userland/Services/NotificationServer/NotificationWindow.h b/Userland/Services/NotificationServer/NotificationWindow.h index 909f8087c9..1f90198bd5 100644 --- a/Userland/Services/NotificationServer/NotificationWindow.h +++ b/Userland/Services/NotificationServer/NotificationWindow.h @@ -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;