Index: components/exo/wayland/server.cc |
diff --git a/components/exo/wayland/server.cc b/components/exo/wayland/server.cc |
index 5ba8ee4496989fe48d99864c4126dafeef57a06e..888d19cce847c35112b06dd20b2abb544a8ea5fe 100644 |
--- a/components/exo/wayland/server.cc |
+++ b/components/exo/wayland/server.cc |
@@ -42,6 +42,8 @@ |
#include "components/exo/display.h" |
#include "components/exo/keyboard.h" |
#include "components/exo/keyboard_delegate.h" |
+#include "components/exo/notification_surface.h" |
+#include "components/exo/notification_surface_registry.h" |
#include "components/exo/pointer.h" |
#include "components/exo/pointer_delegate.h" |
#include "components/exo/shared_memory.h" |
@@ -1485,6 +1487,16 @@ const struct zwp_remote_surface_v1_interface remote_surface_implementation = { |
remote_surface_unfullscreen}; |
//////////////////////////////////////////////////////////////////////////////// |
+// notification_surface_interface: |
+ |
+void notification_surface_destroy(wl_client* client, wl_resource* resource) { |
+ wl_resource_destroy(resource); |
+} |
+ |
+const struct zwp_notification_surface_v1_interface |
+ notification_surface_implementation = {notification_surface_destroy}; |
+ |
+//////////////////////////////////////////////////////////////////////////////// |
// remote_shell_interface: |
// Implements remote shell interface and monitors workspace state needed |
@@ -1517,6 +1529,17 @@ class WaylandRemoteShell : public ash::ShellObserver, |
return display_->CreateRemoteShellSurface(surface, container); |
} |
+ bool IsValidNotificationId(const std::string& notification_id) const { |
reveman
2016/06/22 16:44:30
Would be nice if this could instead be validated w
xiyuan
2016/06/23 14:46:43
Done.
|
+ return display_->notification_surface_registry()->GetSurface( |
+ notification_id) == nullptr; |
+ } |
+ |
+ std::unique_ptr<NotificationSurface> CreateNotificationSurface( |
+ Surface* surface, |
+ const std::string& notification_id) { |
+ return display_->CreateNotificationSurface(surface, notification_id); |
+ } |
+ |
// Overridden from display::DisplayObserver: |
void OnDisplayAdded(const display::Display& new_display) override {} |
void OnDisplayRemoved(const display::Display& new_display) override {} |
@@ -1692,10 +1715,42 @@ void remote_shell_get_remote_surface(wl_client* client, |
std::move(shell_surface)); |
} |
+void remote_shell_get_notification_surface(wl_client* client, |
+ wl_resource* resource, |
+ uint32_t id, |
+ wl_resource* surface, |
+ const char* notification_id) { |
+ WaylandRemoteShell* remote_shell = |
+ GetUserDataAs<WaylandRemoteShell>(resource); |
+ if (!remote_shell->IsValidNotificationId(notification_id)) { |
+ wl_resource_post_error(resource, |
+ ZWP_REMOTE_SHELL_V1_ERROR_INVALID_NOTIFICATION_ID, |
+ "invalid notification id"); |
+ return; |
+ } |
+ |
+ std::unique_ptr<NotificationSurface> notification_surface = |
+ remote_shell->CreateNotificationSurface(GetUserDataAs<Surface>(surface), |
+ std::string(notification_id)); |
+ if (!notification_surface) { |
reveman
2016/06/22 16:44:31
Instead of using a null return value here. Can you
xiyuan
2016/06/23 14:46:43
Done.
|
+ wl_resource_post_error(resource, ZWP_REMOTE_SHELL_V1_ERROR_ROLE, |
+ "surface has already been assigned a role"); |
+ return; |
+ } |
+ |
+ wl_resource* notification_surface_resource = |
+ wl_resource_create(client, &zwp_notification_surface_v1_interface, |
+ wl_resource_get_version(resource), id); |
+ SetImplementation(notification_surface_resource, |
+ ¬ification_surface_implementation, |
+ std::move(notification_surface)); |
+} |
+ |
const struct zwp_remote_shell_v1_interface remote_shell_implementation = { |
- remote_shell_destroy, remote_shell_get_remote_surface}; |
+ remote_shell_destroy, remote_shell_get_remote_surface, |
+ remote_shell_get_notification_surface}; |
-const uint32_t remote_shell_version = 3; |
+const uint32_t remote_shell_version = 4; |
void bind_remote_shell(wl_client* client, |
void* data, |