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 <gaming-input-unstable-v1-server-protocol.h> | 8 #include <gaming-input-unstable-v1-server-protocol.h> |
9 #include <gaming-input-unstable-v2-server-protocol.h> | 9 #include <gaming-input-unstable-v2-server-protocol.h> |
10 #include <grp.h> | 10 #include <grp.h> |
11 #include <keyboard-configuration-unstable-v1-server-protocol.h> | 11 #include <keyboard-configuration-unstable-v1-server-protocol.h> |
12 #include <linux/input.h> | 12 #include <linux/input.h> |
13 #include <presentation-time-server-protocol.h> | 13 #include <presentation-time-server-protocol.h> |
14 #include <remote-shell-unstable-v1-server-protocol.h> | 14 #include <remote-shell-unstable-v1-server-protocol.h> |
15 #include <secure-output-unstable-v1-server-protocol.h> | 15 #include <secure-output-unstable-v1-server-protocol.h> |
16 #include <stddef.h> | 16 #include <stddef.h> |
17 #include <stdint.h> | 17 #include <stdint.h> |
| 18 #include <stylus-tools-unstable-v1-server-protocol.h> |
18 #include <stylus-unstable-v1-server-protocol.h> | 19 #include <stylus-unstable-v1-server-protocol.h> |
19 #include <stylus-unstable-v2-server-protocol.h> | 20 #include <stylus-unstable-v2-server-protocol.h> |
20 #include <viewporter-server-protocol.h> | 21 #include <viewporter-server-protocol.h> |
21 #include <vsync-feedback-unstable-v1-server-protocol.h> | 22 #include <vsync-feedback-unstable-v1-server-protocol.h> |
22 #include <wayland-server-core.h> | 23 #include <wayland-server-core.h> |
23 #include <wayland-server-protocol-core.h> | 24 #include <wayland-server-protocol-core.h> |
24 #include <xdg-shell-unstable-v5-server-protocol.h> | 25 #include <xdg-shell-unstable-v5-server-protocol.h> |
25 #include <xdg-shell-unstable-v6-server-protocol.h> | 26 #include <xdg-shell-unstable-v6-server-protocol.h> |
26 | 27 |
27 #include <algorithm> | 28 #include <algorithm> |
(...skipping 129 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 stylus_tool |
| 169 // object is associated with a window. |
| 170 DEFINE_UI_CLASS_PROPERTY_KEY(bool, kSurfaceHasStylusToolKey, 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 // stylus_tool interface: |
| 3849 |
| 3850 class StylusTool : public SurfaceObserver { |
| 3851 public: |
| 3852 explicit StylusTool(Surface* surface) : surface_(surface) { |
| 3853 surface_->AddSurfaceObserver(this); |
| 3854 surface_->SetProperty(kSurfaceHasStylusToolKey, true); |
| 3855 } |
| 3856 ~StylusTool() override { |
| 3857 if (surface_) { |
| 3858 surface_->RemoveSurfaceObserver(this); |
| 3859 surface_->SetProperty(kSurfaceHasStylusToolKey, false); |
| 3860 } |
| 3861 } |
| 3862 |
| 3863 void SetStylusOnly() { surface_->SetStylusOnly(); } |
| 3864 |
| 3865 // Overridden from SurfaceObserver: |
| 3866 void OnSurfaceDestroying(Surface* surface) override { |
| 3867 surface->RemoveSurfaceObserver(this); |
| 3868 surface_ = nullptr; |
| 3869 } |
| 3870 |
| 3871 private: |
| 3872 Surface* surface_; |
| 3873 |
| 3874 DISALLOW_COPY_AND_ASSIGN(StylusTool); |
| 3875 }; |
| 3876 |
| 3877 void stylus_tool_destroy(wl_client* client, wl_resource* resource) { |
| 3878 wl_resource_destroy(resource); |
| 3879 } |
| 3880 |
| 3881 void stylus_tool_set_stylus_only(wl_client* client, wl_resource* resource) { |
| 3882 GetUserDataAs<StylusTool>(resource)->SetStylusOnly(); |
| 3883 } |
| 3884 |
| 3885 const struct zcr_stylus_tool_v1_interface stylus_tool_implementation = { |
| 3886 stylus_tool_destroy, stylus_tool_set_stylus_only}; |
| 3887 |
| 3888 //////////////////////////////////////////////////////////////////////////////// |
| 3889 // stylus_tools interface: |
| 3890 |
| 3891 void stylus_tools_destroy(wl_client* client, wl_resource* resource) { |
| 3892 wl_resource_destroy(resource); |
| 3893 } |
| 3894 |
| 3895 void stylus_tools_get_stylus_tool(wl_client* client, |
| 3896 wl_resource* resource, |
| 3897 uint32_t id, |
| 3898 wl_resource* surface_resource) { |
| 3899 Surface* surface = GetUserDataAs<Surface>(surface_resource); |
| 3900 if (surface->GetProperty(kSurfaceHasStylusToolKey)) { |
| 3901 wl_resource_post_error( |
| 3902 resource, ZCR_STYLUS_TOOLS_V1_ERROR_STYLUS_TOOL_EXISTS, |
| 3903 "a stylus_tool object for that surface already exists"); |
| 3904 return; |
| 3905 } |
| 3906 |
| 3907 wl_resource* stylus_tool_resource = |
| 3908 wl_resource_create(client, &zcr_stylus_tool_v1_interface, 1, id); |
| 3909 |
| 3910 SetImplementation(stylus_tool_resource, &stylus_tool_implementation, |
| 3911 base::MakeUnique<StylusTool>(surface)); |
| 3912 } |
| 3913 |
| 3914 const struct zcr_stylus_tools_v1_interface stylus_tools_implementation = { |
| 3915 stylus_tools_destroy, stylus_tools_get_stylus_tool}; |
| 3916 |
| 3917 void bind_stylus_tools(wl_client* client, |
| 3918 void* data, |
| 3919 uint32_t version, |
| 3920 uint32_t id) { |
| 3921 wl_resource* resource = |
| 3922 wl_resource_create(client, &zcr_stylus_tools_v1_interface, 1, id); |
| 3923 |
| 3924 wl_resource_set_implementation(resource, &stylus_tools_implementation, data, |
| 3925 nullptr); |
| 3926 } |
| 3927 |
3842 } // namespace | 3928 } // namespace |
3843 | 3929 |
3844 //////////////////////////////////////////////////////////////////////////////// | 3930 //////////////////////////////////////////////////////////////////////////////// |
3845 // Server, public: | 3931 // Server, public: |
3846 | 3932 |
3847 Server::Server(Display* display) | 3933 Server::Server(Display* display) |
3848 : display_(display), wl_display_(wl_display_create()) { | 3934 : display_(display), wl_display_(wl_display_create()) { |
3849 wl_global_create(wl_display_.get(), &wl_compositor_interface, | 3935 wl_global_create(wl_display_.get(), &wl_compositor_interface, |
3850 compositor_version, display_, bind_compositor); | 3936 compositor_version, display_, bind_compositor); |
3851 wl_global_create(wl_display_.get(), &wl_shm_interface, 1, display_, bind_shm); | 3937 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, | 3970 wl_global_create(wl_display_.get(), &zcr_gaming_input_v1_interface, 1, |
3885 display_, bind_gaming_input_v1_DEPRECATED); | 3971 display_, bind_gaming_input_v1_DEPRECATED); |
3886 wl_global_create(wl_display_.get(), &zcr_gaming_input_v2_interface, 1, | 3972 wl_global_create(wl_display_.get(), &zcr_gaming_input_v2_interface, 1, |
3887 display_, bind_gaming_input); | 3973 display_, bind_gaming_input); |
3888 wl_global_create(wl_display_.get(), &zcr_stylus_v1_interface, 2, display_, | 3974 wl_global_create(wl_display_.get(), &zcr_stylus_v1_interface, 2, display_, |
3889 bind_stylus_v1_DEPRECATED); | 3975 bind_stylus_v1_DEPRECATED); |
3890 wl_global_create(wl_display_.get(), &zcr_stylus_v2_interface, 1, display_, | 3976 wl_global_create(wl_display_.get(), &zcr_stylus_v2_interface, 1, display_, |
3891 bind_stylus_v2); | 3977 bind_stylus_v2); |
3892 wl_global_create(wl_display_.get(), &zcr_keyboard_configuration_v1_interface, | 3978 wl_global_create(wl_display_.get(), &zcr_keyboard_configuration_v1_interface, |
3893 2, display_, bind_keyboard_configuration); | 3979 2, display_, bind_keyboard_configuration); |
| 3980 wl_global_create(wl_display_.get(), &zcr_stylus_tools_v1_interface, 1, |
| 3981 display_, bind_stylus_tools); |
3894 } | 3982 } |
3895 | 3983 |
3896 Server::~Server() {} | 3984 Server::~Server() {} |
3897 | 3985 |
3898 // static | 3986 // static |
3899 std::unique_ptr<Server> Server::Create(Display* display) { | 3987 std::unique_ptr<Server> Server::Create(Display* display) { |
3900 std::unique_ptr<Server> server(new Server(display)); | 3988 std::unique_ptr<Server> server(new Server(display)); |
3901 | 3989 |
3902 char* runtime_dir = getenv("XDG_RUNTIME_DIR"); | 3990 char* runtime_dir = getenv("XDG_RUNTIME_DIR"); |
3903 if (!runtime_dir) { | 3991 if (!runtime_dir) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3955 DCHECK(event_loop); | 4043 DCHECK(event_loop); |
3956 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 4044 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
3957 } | 4045 } |
3958 | 4046 |
3959 void Server::Flush() { | 4047 void Server::Flush() { |
3960 wl_display_flush_clients(wl_display_.get()); | 4048 wl_display_flush_clients(wl_display_.get()); |
3961 } | 4049 } |
3962 | 4050 |
3963 } // namespace wayland | 4051 } // namespace wayland |
3964 } // namespace exo | 4052 } // namespace exo |
OLD | NEW |