diff options
author | Nick Johnson <sylvyrfysh@gmail.com> | 2021-03-11 13:37:26 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-22 12:46:16 +0100 |
commit | 7351c77a423108eaac1b1f6ab0abb11f6c601ee7 (patch) | |
tree | ddffa8e0bc9b46d033d256aebaff3a4255a637a8 /Userland | |
parent | dddaa529b29ec91bbeb3e9c092dada3733fdab10 (diff) | |
download | serenity-7351c77a423108eaac1b1f6ab0abb11f6c601ee7.zip |
LibGUI+Notification: Use lifetime connection
In order to allow notifications to be updated, we will create a persistent connection for the lifetime of the notification.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGUI/Notification.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Notification.h | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGUI/Notification.cpp b/Userland/Libraries/LibGUI/Notification.cpp index 51667d6a97..34e06345c9 100644 --- a/Userland/Libraries/LibGUI/Notification.cpp +++ b/Userland/Libraries/LibGUI/Notification.cpp @@ -49,6 +49,7 @@ private: }; Notification::Notification() + : m_connection(NotificationServerConnection::construct()) { } @@ -58,9 +59,8 @@ Notification::~Notification() void Notification::show() { - auto connection = NotificationServerConnection::construct(); auto icon = m_icon ? m_icon->to_shareable_bitmap() : Gfx::ShareableBitmap(); - connection->send_sync<Messages::NotificationServer::ShowNotification>(m_text, m_title, icon); + m_connection->send_sync<Messages::NotificationServer::ShowNotification>(m_text, m_title, icon); } } diff --git a/Userland/Libraries/LibGUI/Notification.h b/Userland/Libraries/LibGUI/Notification.h index 1b86bc8199..b26c5aa0fa 100644 --- a/Userland/Libraries/LibGUI/Notification.h +++ b/Userland/Libraries/LibGUI/Notification.h @@ -30,6 +30,7 @@ #include <LibGfx/Bitmap.h> namespace GUI { + class NotificationServerConnection; class Notification : public Core::Object { C_OBJECT(Notification); @@ -54,6 +55,8 @@ private: String m_title; String m_text; RefPtr<Gfx::Bitmap> m_icon; + + NonnullRefPtr<NotificationServerConnection> m_connection; }; } |