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:
parent
a281fa3902
commit
dcbb8cf0ac
Notes:
sideshowbarker
2024-07-17 09:39:38 +09:00
Author: https://github.com/Rummskartoffel Commit: https://github.com/SerenityOS/serenity/commit/dcbb8cf0ac Pull-request: https://github.com/SerenityOS/serenity/pull/21754 Reviewed-by: https://github.com/awesomekling
2 changed files with 2 additions and 7 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue