From 7efb497837422447a0913915967dc341f334ba3a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 16 Feb 2020 19:51:44 +0100 Subject: [PATCH] NotificationServer: Add new notification windows below the lowest one Don't stack notifications on top of each other, instead put them below one another on the y axis. This will obviously break if the screen fills with notifications, but that's a FIXME for now. :^) --- Servers/NotificationServer/NotificationWindow.cpp | 12 ++++++++++++ Servers/NotificationServer/NotificationWindow.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/Servers/NotificationServer/NotificationWindow.cpp b/Servers/NotificationServer/NotificationWindow.cpp index 1fca0803de..2bfb35d5de 100644 --- a/Servers/NotificationServer/NotificationWindow.cpp +++ b/Servers/NotificationServer/NotificationWindow.cpp @@ -43,12 +43,24 @@ NotificationWindow::NotificationWindow(const String& text, const String& title) set_window_type(GUI::WindowType::Tooltip); + Gfx::Rect lowest_notification_rect_on_screen; + for (auto& window : s_windows) { + if (window->m_original_rect.y() > lowest_notification_rect_on_screen.y()) + lowest_notification_rect_on_screen = window->m_original_rect; + } + Gfx::Rect rect; rect.set_width(200); rect.set_height(40); rect.set_location(GUI::Desktop::the().rect().top_right().translated(-rect.width() - 8, 26)); + + if (!lowest_notification_rect_on_screen.is_null()) + rect.set_location(lowest_notification_rect_on_screen.bottom_left().translated(0, 8)); + set_rect(rect); + m_original_rect = rect; + auto widget = GUI::Widget::construct(); widget->set_fill_with_background_color(true); diff --git a/Servers/NotificationServer/NotificationWindow.h b/Servers/NotificationServer/NotificationWindow.h index 73f19e59b9..dd13a65f86 100644 --- a/Servers/NotificationServer/NotificationWindow.h +++ b/Servers/NotificationServer/NotificationWindow.h @@ -38,6 +38,8 @@ public: private: NotificationWindow(const String& text, const String& title); + + Gfx::Rect m_original_rect; }; }