1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 09:37:34 +00:00

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.
This commit is contained in:
Nick Johnson 2021-03-11 13:37:26 -06:00 committed by Andreas Kling
parent dddaa529b2
commit 7351c77a42
2 changed files with 5 additions and 2 deletions

View file

@ -49,6 +49,7 @@ private:
}; };
Notification::Notification() Notification::Notification()
: m_connection(NotificationServerConnection::construct())
{ {
} }
@ -58,9 +59,8 @@ Notification::~Notification()
void Notification::show() void Notification::show()
{ {
auto connection = NotificationServerConnection::construct();
auto icon = m_icon ? m_icon->to_shareable_bitmap() : Gfx::ShareableBitmap(); 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);
} }
} }

View file

@ -30,6 +30,7 @@
#include <LibGfx/Bitmap.h> #include <LibGfx/Bitmap.h>
namespace GUI { namespace GUI {
class NotificationServerConnection;
class Notification : public Core::Object { class Notification : public Core::Object {
C_OBJECT(Notification); C_OBJECT(Notification);
@ -54,6 +55,8 @@ private:
String m_title; String m_title;
String m_text; String m_text;
RefPtr<Gfx::Bitmap> m_icon; RefPtr<Gfx::Bitmap> m_icon;
NonnullRefPtr<NotificationServerConnection> m_connection;
}; };
} }