Chromium Code Reviews| Index: components/exo/wayland/server.cc |
| diff --git a/components/exo/wayland/server.cc b/components/exo/wayland/server.cc |
| index 620d1f285fc9af8d8cb9e50a3d789160002de02c..8817ddba83e1aa14547de58493a0a4ee5dc73534 100644 |
| --- a/components/exo/wayland/server.cc |
| +++ b/components/exo/wayland/server.cc |
| @@ -51,7 +51,6 @@ |
| #include "components/exo/notification_surface_manager.h" |
| #include "components/exo/pointer.h" |
| #include "components/exo/pointer_delegate.h" |
| -#include "components/exo/pointer_stylus_delegate.h" |
| #include "components/exo/shared_memory.h" |
| #include "components/exo/shell_surface.h" |
| #include "components/exo/sub_surface.h" |
| @@ -59,6 +58,7 @@ |
| #include "components/exo/surface_property.h" |
| #include "components/exo/touch.h" |
| #include "components/exo/touch_delegate.h" |
| +#include "components/exo/touch_stylus_delegate.h" |
| #include "components/exo/wm_helper.h" |
| #include "third_party/skia/include/core/SkRegion.h" |
| #include "ui/aura/window_property.h" |
| @@ -2932,48 +2932,90 @@ void bind_gaming_input(wl_client* client, |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// pointer_stylus interface: |
| +// touch_stylus interface: |
| -class WaylandPointerStylusDelegate : public PointerStylusDelegate { |
| +class WaylandTouchStylusDelegate : public TouchStylusDelegate { |
| public: |
| - WaylandPointerStylusDelegate(wl_resource* resource, Pointer* pointer) |
| - : resource_(resource), pointer_(pointer) { |
| - pointer_->SetStylusDelegate(this); |
| + WaylandTouchStylusDelegate(wl_resource* resource, Touch* touch) |
| + : resource_(resource), touch_(touch) { |
| + touch_->SetStylusDelegate(this); |
| } |
| - ~WaylandPointerStylusDelegate() override { |
| - if (pointer_ != nullptr) |
| - pointer_->SetStylusDelegate(nullptr); |
| + ~WaylandTouchStylusDelegate() override { |
| + if (touch_ != nullptr) |
| + touch_->SetStylusDelegate(nullptr); |
| } |
| - void OnPointerDestroying(Pointer* pointer) override { pointer_ = nullptr; } |
| - void OnPointerToolChange(ui::EventPointerType type) override { |
| + void OnTouchDestroying(Touch* touch) override { touch_ = nullptr; } |
| + void OnTouchTool(int touch_id, ui::EventPointerType type) override { |
| uint wayland_type = ZCR_POINTER_STYLUS_V1_TOOL_TYPE_MOUSE; |
| if (type == ui::EventPointerType::POINTER_TYPE_PEN) |
| wayland_type = ZCR_POINTER_STYLUS_V1_TOOL_TYPE_PEN; |
| else if (type == ui::EventPointerType::POINTER_TYPE_ERASER) |
| wayland_type = ZCR_POINTER_STYLUS_V1_TOOL_TYPE_ERASER; |
| - zcr_pointer_stylus_v1_send_tool_change(resource_, wayland_type); |
| - } |
| - void OnPointerForce(base::TimeTicks time_stamp, float force) override { |
| - zcr_pointer_stylus_v1_send_force(resource_, |
| - TimeTicksToMilliseconds(time_stamp), |
| - wl_fixed_from_double(force)); |
| - } |
| - void OnPointerTilt(base::TimeTicks time_stamp, gfx::Vector2dF tilt) override { |
| - zcr_pointer_stylus_v1_send_tilt( |
| - resource_, TimeTicksToMilliseconds(time_stamp), |
| + zcr_touch_stylus_v1_send_tool(resource_, touch_id, wayland_type); |
| + } |
| + void OnTouchForce(base::TimeTicks time_stamp, |
| + int touch_id, |
| + float force) override { |
| + zcr_touch_stylus_v1_send_force(resource_, |
| + TimeTicksToMilliseconds(time_stamp), |
| + touch_id, wl_fixed_from_double(force)); |
| + } |
| + void OnTouchTilt(base::TimeTicks time_stamp, |
| + int touch_id, |
| + gfx::Vector2dF tilt) override { |
| + zcr_touch_stylus_v1_send_tilt( |
| + resource_, TimeTicksToMilliseconds(time_stamp), touch_id, |
| wl_fixed_from_double(tilt.x()), wl_fixed_from_double(tilt.y())); |
| } |
| private: |
| wl_resource* resource_; |
| - Pointer* pointer_; |
| - |
| - // The client who own this pointer stylus instance. |
| - wl_client* client() const { return wl_resource_get_client(resource_); } |
| + Touch* touch_; |
| - DISALLOW_COPY_AND_ASSIGN(WaylandPointerStylusDelegate); |
| + DISALLOW_COPY_AND_ASSIGN(WaylandTouchStylusDelegate); |
| }; |
| +void touch_stylus_destroy(wl_client* client, wl_resource* resource) { |
| + wl_resource_destroy(resource); |
| +} |
| + |
| +const struct zcr_touch_stylus_v1_interface touch_stylus_implementation = { |
| + touch_stylus_destroy}; |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// stylus_v2 interface: |
| + |
| +void stylus_get_touch_stylus(wl_client* client, |
| + wl_resource* resource, |
| + uint32_t id, |
| + wl_resource* touch_resource) { |
| + Touch* touch = GetUserDataAs<Touch>(touch_resource); |
| + |
| + wl_resource* stylus_resource = |
| + wl_resource_create(client, &zcr_touch_stylus_v1_interface, 1, id); |
| + |
| + SetImplementation( |
| + stylus_resource, &touch_stylus_implementation, |
| + base::MakeUnique<WaylandTouchStylusDelegate>(stylus_resource, touch)); |
| +} |
| + |
| +const struct zcr_stylus_v2_interface stylus_v2_implementation = { |
| + stylus_get_touch_stylus}; |
| + |
| +void bind_stylus_v2(wl_client* client, |
| + void* data, |
| + uint32_t version, |
| + uint32_t id) { |
| + wl_resource* resource = |
| + wl_resource_create(client, &zcr_stylus_v2_interface, version, id); |
| + wl_resource_set_implementation(resource, &stylus_v2_implementation, data, |
| + nullptr); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// pointer_stylus interface (deprecated) |
| +// TODO(denniskempin): Remove once client no longer depends on this interface. |
| + |
| void pointer_stylus_destroy(wl_client* client, wl_resource* resource) { |
| wl_resource_destroy(resource); |
| } |
| @@ -2982,29 +3024,29 @@ const struct zcr_pointer_stylus_v1_interface pointer_stylus_implementation = { |
| pointer_stylus_destroy}; |
| //////////////////////////////////////////////////////////////////////////////// |
| -// stylus interface: |
| +// stylus_v1 interface (deprecated): |
| +// TODO(denniskempin): Remove once client no longer depends on this interface. |
| void stylus_get_pointer_stylus(wl_client* client, |
| wl_resource* resource, |
| uint32_t id, |
| - wl_resource* pointer_resource) { |
| - Pointer* pointer = GetUserDataAs<Pointer>(pointer_resource); |
| - |
| + wl_resource* touch_resource) { |
| wl_resource* stylus_resource = |
| wl_resource_create(client, &zcr_pointer_stylus_v1_interface, 1, id); |
| - |
| - SetImplementation( |
| - stylus_resource, &pointer_stylus_implementation, |
| - base::MakeUnique<WaylandPointerStylusDelegate>(stylus_resource, pointer)); |
| + wl_resource_set_implementation( |
| + stylus_resource, &pointer_stylus_implementation, nullptr, nullptr); |
| } |
| -const struct zcr_stylus_v1_interface stylus_implementation = { |
| +const struct zcr_stylus_v1_interface stylus_v1_implementation = { |
|
reveman
2016/12/08 23:17:14
Alternatively you can add a _DEPRECATED suffix. Th
denniskempin
2016/12/15 21:16:49
Done.
|
| stylus_get_pointer_stylus}; |
| -void bind_stylus(wl_client* client, void* data, uint32_t version, uint32_t id) { |
| +void bind_stylus_v1(wl_client* client, |
| + void* data, |
| + uint32_t version, |
| + uint32_t id) { |
| wl_resource* resource = |
| wl_resource_create(client, &zcr_stylus_v1_interface, version, id); |
| - wl_resource_set_implementation(resource, &stylus_implementation, data, |
| + wl_resource_set_implementation(resource, &stylus_v1_implementation, data, |
| nullptr); |
| } |
| @@ -3049,7 +3091,9 @@ Server::Server(Display* display) |
| wl_global_create(wl_display_.get(), &zcr_gaming_input_v1_interface, 1, |
| display_, bind_gaming_input); |
| wl_global_create(wl_display_.get(), &zcr_stylus_v1_interface, 1, display_, |
| - bind_stylus); |
| + bind_stylus_v1); |
| + wl_global_create(wl_display_.get(), &zcr_stylus_v2_interface, 1, display_, |
| + bind_stylus_v2); |
| } |
| Server::~Server() {} |