Index: components/exo/wayland/server.cc |
diff --git a/components/exo/wayland/server.cc b/components/exo/wayland/server.cc |
index 099429624c776812176b9109acb65ebd7e8fd236..a9d28e314c1f778be284bf648eafb7d55b2ef817 100644 |
--- a/components/exo/wayland/server.cc |
+++ b/components/exo/wayland/server.cc |
@@ -5,6 +5,7 @@ |
#include "components/exo/wayland/server.h" |
#include <alpha-compositing-unstable-v1-server-protocol.h> |
+#include <annotation-unstable-v1-server-protocol.h> |
#include <gaming-input-unstable-v1-server-protocol.h> |
#include <gaming-input-unstable-v2-server-protocol.h> |
#include <grp.h> |
@@ -164,6 +165,10 @@ DEFINE_UI_CLASS_PROPERTY_KEY(bool, kSurfaceHasBlendingKey, false); |
// to ignore the activation event originated by creation. |
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kIgnoreWindowActivated, true); |
+// A property key containing a boolean set to true if the window is |
+// an annotation layer. |
+DEFINE_UI_CLASS_PROPERTY_KEY(bool, kSurfaceHasAnnotationKey, false); |
+ |
wl_resource* GetSurfaceResource(Surface* surface) { |
return surface->GetProperty(kSurfaceResourceKey); |
} |
@@ -3839,6 +3844,105 @@ void bind_keyboard_configuration(wl_client* client, |
resource, &keyboard_configuration_implementation, data, nullptr); |
} |
+//////////////////////////////////////////////////////////////////////////////// |
+// annotation_features interface: |
+ |
+class AnnotationFeatures : public SurfaceObserver { |
+ public: |
+ explicit AnnotationFeatures(Surface* surface) : surface_(surface) { |
+ surface_->AddSurfaceObserver(this); |
+ surface_->SetProperty(kSurfaceHasAnnotationKey, true); |
+ surface_->SetAnnotationLayer(true); |
reveman
2017/05/23 16:41:06
Can we add an explicit request for turning this on
Vladislav Kaznacheev
2017/05/23 23:48:56
Done.
|
+ } |
+ ~AnnotationFeatures() override { |
+ if (surface_) { |
+ surface_->RemoveSurfaceObserver(this); |
+ surface_->SetProperty(kSurfaceHasAnnotationKey, false); |
+ surface_->SetAnnotationLayer(false); |
+ } |
+ } |
+ |
+ void SetStylusOnly(bool stylus_only) { |
+ // TODO: |
reveman
2017/05/23 16:41:06
TODO(kaznacheev) and a short explanation and link
Vladislav Kaznacheev
2017/05/23 23:48:56
Removed TODO
|
+ } |
+ |
+ // Overridden from SurfaceObserver: |
+ void OnSurfaceDestroying(Surface* surface) override { |
+ surface->RemoveSurfaceObserver(this); |
+ surface_ = nullptr; |
+ } |
+ |
+ private: |
+ Surface* surface_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AnnotationFeatures); |
+}; |
+ |
+void annotation_features_destroy(wl_client* client, wl_resource* resource) { |
+ wl_resource_destroy(resource); |
+} |
+ |
+void annotation_features_set_input_mode(wl_client* client, |
+ wl_resource* resource, |
+ uint32_t mode) { |
+ switch (mode) { |
+ case ZCR_ANNOTATION_FEATURES_V1_INPUT_MODE_DEFAULT: |
+ GetUserDataAs<AnnotationFeatures>(resource)->SetStylusOnly(false); |
+ break; |
+ case ZCR_ANNOTATION_FEATURES_V1_INPUT_MODE_STYLUS_ONLY: |
+ GetUserDataAs<AnnotationFeatures>(resource)->SetStylusOnly(true); |
+ break; |
+ default: |
+ DLOG(WARNING) << "Unsupported input mode: " << mode; |
+ break; |
+ } |
+} |
+ |
+const struct zcr_annotation_features_v1_interface |
+ annotation_features_implementation = {annotation_features_destroy, |
+ annotation_features_set_input_mode}; |
+ |
+//////////////////////////////////////////////////////////////////////////////// |
+// annotation interface: |
+ |
+void annotation_destroy(wl_client* client, wl_resource* resource) { |
+ wl_resource_destroy(resource); |
+} |
+ |
+void annotation_get_annotation_features(wl_client* client, |
+ wl_resource* resource, |
+ uint32_t id, |
+ wl_resource* surface_resource) { |
+ Surface* surface = GetUserDataAs<Surface>(surface_resource); |
+ if (surface->GetProperty(kSurfaceHasAnnotationKey)) { |
+ wl_resource_post_error( |
+ resource, ZCR_ANNOTATION_V1_ERROR_ANNOTATION_FEATURES_EXISTS, |
+ "an annotation_features object for that surface already exists"); |
+ return; |
+ } |
+ |
+ wl_resource* annotation_features_resource = |
+ wl_resource_create(client, &zcr_annotation_features_v1_interface, 1, id); |
+ |
+ SetImplementation(annotation_features_resource, |
+ &annotation_features_implementation, |
+ base::MakeUnique<AnnotationFeatures>(surface)); |
+} |
+ |
+const struct zcr_annotation_v1_interface annotation_implementation = { |
+ annotation_destroy, annotation_get_annotation_features}; |
+ |
+void bind_annotation(wl_client* client, |
+ void* data, |
+ uint32_t version, |
+ uint32_t id) { |
+ wl_resource* resource = |
+ wl_resource_create(client, &zcr_annotation_v1_interface, 1, id); |
+ |
+ wl_resource_set_implementation(resource, &annotation_implementation, data, |
+ nullptr); |
+} |
+ |
} // namespace |
//////////////////////////////////////////////////////////////////////////////// |
@@ -3891,6 +3995,8 @@ Server::Server(Display* display) |
bind_stylus_v2); |
wl_global_create(wl_display_.get(), &zcr_keyboard_configuration_v1_interface, |
2, display_, bind_keyboard_configuration); |
+ wl_global_create(wl_display_.get(), &zcr_annotation_v1_interface, 1, display_, |
+ bind_annotation); |
} |
Server::~Server() {} |