mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-30 05:42:37 +00:00 
			
		
		
		
	 7cfe712f4d
			
		
	
	
		7cfe712f4d
		
	
	
	
	
		
			
			With this patch, it's now possible to pass a Gfx::ShareableBitmap in an IPC message. As long as the message itself is synchronous, the bitmap will be adopted by the receiving end, and disowned by the sender nicely without any accounting effort like we've had to do in the past. Use this in NotificationServer to allow sending arbitrary bitmaps as icons instead of paths-to-icons.
		
			
				
	
	
		
			41 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| #include <LibGUI/Notification.h>
 | |
| #include <LibIPC/ServerConnection.h>
 | |
| #include <NotificationServer/NotificationClientEndpoint.h>
 | |
| #include <NotificationServer/NotificationServerEndpoint.h>
 | |
| 
 | |
| namespace GUI {
 | |
| 
 | |
| class NotificationServerConnection : public IPC::ServerConnection<NotificationClientEndpoint, NotificationServerEndpoint>
 | |
|     , public NotificationClientEndpoint {
 | |
|     C_OBJECT(NotificationServerConnection)
 | |
| public:
 | |
|     virtual void handshake() override
 | |
|     {
 | |
|         auto response = send_sync<Messages::NotificationServer::Greet>();
 | |
|         set_my_client_id(response->client_id());
 | |
|     }
 | |
| 
 | |
| private:
 | |
|     NotificationServerConnection()
 | |
|         : IPC::ServerConnection<NotificationClientEndpoint, NotificationServerEndpoint>(*this, "/tmp/portal/notify")
 | |
|     {
 | |
| 
 | |
|     }
 | |
|     virtual void handle(const Messages::NotificationClient::Dummy&) override {}
 | |
| };
 | |
| 
 | |
| Notification::Notification()
 | |
| {
 | |
| }
 | |
| 
 | |
| Notification::~Notification()
 | |
| {
 | |
| }
 | |
| 
 | |
| void Notification::show()
 | |
| {
 | |
|     auto connection = NotificationServerConnection::construct();
 | |
|     connection->send_sync<Messages::NotificationServer::ShowNotification>(m_text, m_title, m_icon ? m_icon->to_shareable_bitmap(connection->server_pid()) : Gfx::ShareableBitmap());
 | |
| }
 | |
| 
 | |
| }
 |