Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/exo/wayland/server.h" | 5 #include "components/exo/wayland/server.h" |
| 6 | 6 |
| 7 #include <alpha-compositing-unstable-v1-server-protocol.h> | 7 #include <alpha-compositing-unstable-v1-server-protocol.h> |
| 8 #include <annotation-unstable-v1-server-protocol.h> | |
| 8 #include <gaming-input-unstable-v1-server-protocol.h> | 9 #include <gaming-input-unstable-v1-server-protocol.h> |
| 9 #include <gaming-input-unstable-v2-server-protocol.h> | 10 #include <gaming-input-unstable-v2-server-protocol.h> |
| 10 #include <grp.h> | 11 #include <grp.h> |
| 11 #include <keyboard-configuration-unstable-v1-server-protocol.h> | 12 #include <keyboard-configuration-unstable-v1-server-protocol.h> |
| 12 #include <linux/input.h> | 13 #include <linux/input.h> |
| 13 #include <presentation-time-server-protocol.h> | 14 #include <presentation-time-server-protocol.h> |
| 14 #include <remote-shell-unstable-v1-server-protocol.h> | 15 #include <remote-shell-unstable-v1-server-protocol.h> |
| 15 #include <secure-output-unstable-v1-server-protocol.h> | 16 #include <secure-output-unstable-v1-server-protocol.h> |
| 16 #include <stddef.h> | 17 #include <stddef.h> |
| 17 #include <stdint.h> | 18 #include <stdint.h> |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 | 158 |
| 158 // A property key containing a boolean set to true if a blending object is | 159 // A property key containing a boolean set to true if a blending object is |
| 159 // associated with window. | 160 // associated with window. |
| 160 DEFINE_UI_CLASS_PROPERTY_KEY(bool, kSurfaceHasBlendingKey, false); | 161 DEFINE_UI_CLASS_PROPERTY_KEY(bool, kSurfaceHasBlendingKey, false); |
| 161 | 162 |
| 162 // A property key containing a boolean set to true whether the current | 163 // A property key containing a boolean set to true whether the current |
| 163 // OnWindowActivated invocation should be ignored. The defualt is true | 164 // OnWindowActivated invocation should be ignored. The defualt is true |
| 164 // to ignore the activation event originated by creation. | 165 // to ignore the activation event originated by creation. |
| 165 DEFINE_UI_CLASS_PROPERTY_KEY(bool, kIgnoreWindowActivated, true); | 166 DEFINE_UI_CLASS_PROPERTY_KEY(bool, kIgnoreWindowActivated, true); |
| 166 | 167 |
| 168 // A property key containing a boolean set to true if the window is | |
| 169 // an annotation layer. | |
| 170 DEFINE_UI_CLASS_PROPERTY_KEY(bool, kSurfaceHasAnnotationKey, false); | |
| 171 | |
| 167 wl_resource* GetSurfaceResource(Surface* surface) { | 172 wl_resource* GetSurfaceResource(Surface* surface) { |
| 168 return surface->GetProperty(kSurfaceResourceKey); | 173 return surface->GetProperty(kSurfaceResourceKey); |
| 169 } | 174 } |
| 170 | 175 |
| 171 //////////////////////////////////////////////////////////////////////////////// | 176 //////////////////////////////////////////////////////////////////////////////// |
| 172 // wl_buffer_interface: | 177 // wl_buffer_interface: |
| 173 | 178 |
| 174 void buffer_destroy(wl_client* client, wl_resource* resource) { | 179 void buffer_destroy(wl_client* client, wl_resource* resource) { |
| 175 wl_resource_destroy(resource); | 180 wl_resource_destroy(resource); |
| 176 } | 181 } |
| (...skipping 3655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3832 void bind_keyboard_configuration(wl_client* client, | 3837 void bind_keyboard_configuration(wl_client* client, |
| 3833 void* data, | 3838 void* data, |
| 3834 uint32_t version, | 3839 uint32_t version, |
| 3835 uint32_t id) { | 3840 uint32_t id) { |
| 3836 wl_resource* resource = wl_resource_create( | 3841 wl_resource* resource = wl_resource_create( |
| 3837 client, &zcr_keyboard_configuration_v1_interface, version, id); | 3842 client, &zcr_keyboard_configuration_v1_interface, version, id); |
| 3838 wl_resource_set_implementation( | 3843 wl_resource_set_implementation( |
| 3839 resource, &keyboard_configuration_implementation, data, nullptr); | 3844 resource, &keyboard_configuration_implementation, data, nullptr); |
| 3840 } | 3845 } |
| 3841 | 3846 |
| 3847 //////////////////////////////////////////////////////////////////////////////// | |
| 3848 // annotation_features interface: | |
| 3849 | |
| 3850 class AnnotationFeatures : public SurfaceObserver { | |
| 3851 public: | |
| 3852 explicit AnnotationFeatures(Surface* surface) : surface_(surface) { | |
| 3853 surface_->AddSurfaceObserver(this); | |
| 3854 surface_->SetProperty(kSurfaceHasAnnotationKey, true); | |
| 3855 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.
| |
| 3856 } | |
| 3857 ~AnnotationFeatures() override { | |
| 3858 if (surface_) { | |
| 3859 surface_->RemoveSurfaceObserver(this); | |
| 3860 surface_->SetProperty(kSurfaceHasAnnotationKey, false); | |
| 3861 surface_->SetAnnotationLayer(false); | |
| 3862 } | |
| 3863 } | |
| 3864 | |
| 3865 void SetStylusOnly(bool stylus_only) { | |
| 3866 // 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
| |
| 3867 } | |
| 3868 | |
| 3869 // Overridden from SurfaceObserver: | |
| 3870 void OnSurfaceDestroying(Surface* surface) override { | |
| 3871 surface->RemoveSurfaceObserver(this); | |
| 3872 surface_ = nullptr; | |
| 3873 } | |
| 3874 | |
| 3875 private: | |
| 3876 Surface* surface_; | |
| 3877 | |
| 3878 DISALLOW_COPY_AND_ASSIGN(AnnotationFeatures); | |
| 3879 }; | |
| 3880 | |
| 3881 void annotation_features_destroy(wl_client* client, wl_resource* resource) { | |
| 3882 wl_resource_destroy(resource); | |
| 3883 } | |
| 3884 | |
| 3885 void annotation_features_set_input_mode(wl_client* client, | |
| 3886 wl_resource* resource, | |
| 3887 uint32_t mode) { | |
| 3888 switch (mode) { | |
| 3889 case ZCR_ANNOTATION_FEATURES_V1_INPUT_MODE_DEFAULT: | |
| 3890 GetUserDataAs<AnnotationFeatures>(resource)->SetStylusOnly(false); | |
| 3891 break; | |
| 3892 case ZCR_ANNOTATION_FEATURES_V1_INPUT_MODE_STYLUS_ONLY: | |
| 3893 GetUserDataAs<AnnotationFeatures>(resource)->SetStylusOnly(true); | |
| 3894 break; | |
| 3895 default: | |
| 3896 DLOG(WARNING) << "Unsupported input mode: " << mode; | |
| 3897 break; | |
| 3898 } | |
| 3899 } | |
| 3900 | |
| 3901 const struct zcr_annotation_features_v1_interface | |
| 3902 annotation_features_implementation = {annotation_features_destroy, | |
| 3903 annotation_features_set_input_mode}; | |
| 3904 | |
| 3905 //////////////////////////////////////////////////////////////////////////////// | |
| 3906 // annotation interface: | |
| 3907 | |
| 3908 void annotation_destroy(wl_client* client, wl_resource* resource) { | |
| 3909 wl_resource_destroy(resource); | |
| 3910 } | |
| 3911 | |
| 3912 void annotation_get_annotation_features(wl_client* client, | |
| 3913 wl_resource* resource, | |
| 3914 uint32_t id, | |
| 3915 wl_resource* surface_resource) { | |
| 3916 Surface* surface = GetUserDataAs<Surface>(surface_resource); | |
| 3917 if (surface->GetProperty(kSurfaceHasAnnotationKey)) { | |
| 3918 wl_resource_post_error( | |
| 3919 resource, ZCR_ANNOTATION_V1_ERROR_ANNOTATION_FEATURES_EXISTS, | |
| 3920 "an annotation_features object for that surface already exists"); | |
| 3921 return; | |
| 3922 } | |
| 3923 | |
| 3924 wl_resource* annotation_features_resource = | |
| 3925 wl_resource_create(client, &zcr_annotation_features_v1_interface, 1, id); | |
| 3926 | |
| 3927 SetImplementation(annotation_features_resource, | |
| 3928 &annotation_features_implementation, | |
| 3929 base::MakeUnique<AnnotationFeatures>(surface)); | |
| 3930 } | |
| 3931 | |
| 3932 const struct zcr_annotation_v1_interface annotation_implementation = { | |
| 3933 annotation_destroy, annotation_get_annotation_features}; | |
| 3934 | |
| 3935 void bind_annotation(wl_client* client, | |
| 3936 void* data, | |
| 3937 uint32_t version, | |
| 3938 uint32_t id) { | |
| 3939 wl_resource* resource = | |
| 3940 wl_resource_create(client, &zcr_annotation_v1_interface, 1, id); | |
| 3941 | |
| 3942 wl_resource_set_implementation(resource, &annotation_implementation, data, | |
| 3943 nullptr); | |
| 3944 } | |
| 3945 | |
| 3842 } // namespace | 3946 } // namespace |
| 3843 | 3947 |
| 3844 //////////////////////////////////////////////////////////////////////////////// | 3948 //////////////////////////////////////////////////////////////////////////////// |
| 3845 // Server, public: | 3949 // Server, public: |
| 3846 | 3950 |
| 3847 Server::Server(Display* display) | 3951 Server::Server(Display* display) |
| 3848 : display_(display), wl_display_(wl_display_create()) { | 3952 : display_(display), wl_display_(wl_display_create()) { |
| 3849 wl_global_create(wl_display_.get(), &wl_compositor_interface, | 3953 wl_global_create(wl_display_.get(), &wl_compositor_interface, |
| 3850 compositor_version, display_, bind_compositor); | 3954 compositor_version, display_, bind_compositor); |
| 3851 wl_global_create(wl_display_.get(), &wl_shm_interface, 1, display_, bind_shm); | 3955 wl_global_create(wl_display_.get(), &wl_shm_interface, 1, display_, bind_shm); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3884 wl_global_create(wl_display_.get(), &zcr_gaming_input_v1_interface, 1, | 3988 wl_global_create(wl_display_.get(), &zcr_gaming_input_v1_interface, 1, |
| 3885 display_, bind_gaming_input_v1_DEPRECATED); | 3989 display_, bind_gaming_input_v1_DEPRECATED); |
| 3886 wl_global_create(wl_display_.get(), &zcr_gaming_input_v2_interface, 1, | 3990 wl_global_create(wl_display_.get(), &zcr_gaming_input_v2_interface, 1, |
| 3887 display_, bind_gaming_input); | 3991 display_, bind_gaming_input); |
| 3888 wl_global_create(wl_display_.get(), &zcr_stylus_v1_interface, 2, display_, | 3992 wl_global_create(wl_display_.get(), &zcr_stylus_v1_interface, 2, display_, |
| 3889 bind_stylus_v1_DEPRECATED); | 3993 bind_stylus_v1_DEPRECATED); |
| 3890 wl_global_create(wl_display_.get(), &zcr_stylus_v2_interface, 1, display_, | 3994 wl_global_create(wl_display_.get(), &zcr_stylus_v2_interface, 1, display_, |
| 3891 bind_stylus_v2); | 3995 bind_stylus_v2); |
| 3892 wl_global_create(wl_display_.get(), &zcr_keyboard_configuration_v1_interface, | 3996 wl_global_create(wl_display_.get(), &zcr_keyboard_configuration_v1_interface, |
| 3893 2, display_, bind_keyboard_configuration); | 3997 2, display_, bind_keyboard_configuration); |
| 3998 wl_global_create(wl_display_.get(), &zcr_annotation_v1_interface, 1, display_, | |
| 3999 bind_annotation); | |
| 3894 } | 4000 } |
| 3895 | 4001 |
| 3896 Server::~Server() {} | 4002 Server::~Server() {} |
| 3897 | 4003 |
| 3898 // static | 4004 // static |
| 3899 std::unique_ptr<Server> Server::Create(Display* display) { | 4005 std::unique_ptr<Server> Server::Create(Display* display) { |
| 3900 std::unique_ptr<Server> server(new Server(display)); | 4006 std::unique_ptr<Server> server(new Server(display)); |
| 3901 | 4007 |
| 3902 char* runtime_dir = getenv("XDG_RUNTIME_DIR"); | 4008 char* runtime_dir = getenv("XDG_RUNTIME_DIR"); |
| 3903 if (!runtime_dir) { | 4009 if (!runtime_dir) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3955 DCHECK(event_loop); | 4061 DCHECK(event_loop); |
| 3956 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 4062 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
| 3957 } | 4063 } |
| 3958 | 4064 |
| 3959 void Server::Flush() { | 4065 void Server::Flush() { |
| 3960 wl_display_flush_clients(wl_display_.get()); | 4066 wl_display_flush_clients(wl_display_.get()); |
| 3961 } | 4067 } |
| 3962 | 4068 |
| 3963 } // namespace wayland | 4069 } // namespace wayland |
| 3964 } // namespace exo | 4070 } // namespace exo |
| OLD | NEW |