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 <grp.h> | 7 #include <grp.h> |
| 8 #include <linux/input.h> | 8 #include <linux/input.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 #include "components/exo/buffer.h" | 44 #include "components/exo/buffer.h" |
| 45 #include "components/exo/display.h" | 45 #include "components/exo/display.h" |
| 46 #include "components/exo/gamepad.h" | 46 #include "components/exo/gamepad.h" |
| 47 #include "components/exo/gamepad_delegate.h" | 47 #include "components/exo/gamepad_delegate.h" |
| 48 #include "components/exo/keyboard.h" | 48 #include "components/exo/keyboard.h" |
| 49 #include "components/exo/keyboard_delegate.h" | 49 #include "components/exo/keyboard_delegate.h" |
| 50 #include "components/exo/notification_surface.h" | 50 #include "components/exo/notification_surface.h" |
| 51 #include "components/exo/notification_surface_manager.h" | 51 #include "components/exo/notification_surface_manager.h" |
| 52 #include "components/exo/pointer.h" | 52 #include "components/exo/pointer.h" |
| 53 #include "components/exo/pointer_delegate.h" | 53 #include "components/exo/pointer_delegate.h" |
| 54 #include "components/exo/pointer_stylus_delegate.h" | |
| 55 #include "components/exo/shared_memory.h" | 54 #include "components/exo/shared_memory.h" |
| 56 #include "components/exo/shell_surface.h" | 55 #include "components/exo/shell_surface.h" |
| 57 #include "components/exo/sub_surface.h" | 56 #include "components/exo/sub_surface.h" |
| 58 #include "components/exo/surface.h" | 57 #include "components/exo/surface.h" |
| 59 #include "components/exo/surface_property.h" | 58 #include "components/exo/surface_property.h" |
| 60 #include "components/exo/touch.h" | 59 #include "components/exo/touch.h" |
| 61 #include "components/exo/touch_delegate.h" | 60 #include "components/exo/touch_delegate.h" |
| 61 #include "components/exo/touch_stylus_delegate.h" | |
| 62 #include "components/exo/wm_helper.h" | 62 #include "components/exo/wm_helper.h" |
| 63 #include "third_party/skia/include/core/SkRegion.h" | 63 #include "third_party/skia/include/core/SkRegion.h" |
| 64 #include "ui/aura/window_property.h" | 64 #include "ui/aura/window_property.h" |
| 65 #include "ui/base/hit_test.h" | 65 #include "ui/base/hit_test.h" |
| 66 #include "ui/base/ui_features.h" | 66 #include "ui/base/ui_features.h" |
| 67 #include "ui/compositor/compositor_vsync_manager.h" | 67 #include "ui/compositor/compositor_vsync_manager.h" |
| 68 #include "ui/display/display_observer.h" | 68 #include "ui/display/display_observer.h" |
| 69 #include "ui/display/manager/managed_display_info.h" | 69 #include "ui/display/manager/managed_display_info.h" |
| 70 #include "ui/display/screen.h" | 70 #include "ui/display/screen.h" |
| 71 #include "ui/events/keycodes/dom/keycode_converter.h" | 71 #include "ui/events/keycodes/dom/keycode_converter.h" |
| (...skipping 2853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2925 std::unique_ptr<base::Thread> gaming_input_thread( | 2925 std::unique_ptr<base::Thread> gaming_input_thread( |
| 2926 new base::Thread("Exo gaming input polling thread.")); | 2926 new base::Thread("Exo gaming input polling thread.")); |
| 2927 gaming_input_thread->StartWithOptions( | 2927 gaming_input_thread->StartWithOptions( |
| 2928 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 2928 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 2929 | 2929 |
| 2930 SetImplementation(resource, &gaming_input_implementation, | 2930 SetImplementation(resource, &gaming_input_implementation, |
| 2931 std::move(gaming_input_thread)); | 2931 std::move(gaming_input_thread)); |
| 2932 } | 2932 } |
| 2933 | 2933 |
| 2934 //////////////////////////////////////////////////////////////////////////////// | 2934 //////////////////////////////////////////////////////////////////////////////// |
| 2935 // pointer_stylus interface: | 2935 // touch_stylus interface: |
| 2936 | 2936 |
| 2937 class WaylandPointerStylusDelegate : public PointerStylusDelegate { | 2937 class WaylandTouchStylusDelegate : public TouchStylusDelegate { |
| 2938 public: | 2938 public: |
| 2939 WaylandPointerStylusDelegate(wl_resource* resource, Pointer* pointer) | 2939 WaylandTouchStylusDelegate(wl_resource* resource, Touch* touch) |
| 2940 : resource_(resource), pointer_(pointer) { | 2940 : resource_(resource), touch_(touch) { |
| 2941 pointer_->SetStylusDelegate(this); | 2941 touch_->SetStylusDelegate(this); |
| 2942 } | 2942 } |
| 2943 ~WaylandPointerStylusDelegate() override { | 2943 ~WaylandTouchStylusDelegate() override { |
| 2944 if (pointer_ != nullptr) | 2944 if (touch_ != nullptr) |
| 2945 pointer_->SetStylusDelegate(nullptr); | 2945 touch_->SetStylusDelegate(nullptr); |
| 2946 } | 2946 } |
| 2947 void OnPointerDestroying(Pointer* pointer) override { pointer_ = nullptr; } | 2947 void OnTouchDestroying(Touch* touch) override { touch_ = nullptr; } |
| 2948 void OnPointerToolChange(ui::EventPointerType type) override { | 2948 void OnTouchTool(int touch_id, ui::EventPointerType type) override { |
| 2949 uint wayland_type = ZCR_POINTER_STYLUS_V1_TOOL_TYPE_MOUSE; | 2949 uint wayland_type = ZCR_POINTER_STYLUS_V1_TOOL_TYPE_MOUSE; |
| 2950 if (type == ui::EventPointerType::POINTER_TYPE_PEN) | 2950 if (type == ui::EventPointerType::POINTER_TYPE_PEN) |
| 2951 wayland_type = ZCR_POINTER_STYLUS_V1_TOOL_TYPE_PEN; | 2951 wayland_type = ZCR_POINTER_STYLUS_V1_TOOL_TYPE_PEN; |
| 2952 else if (type == ui::EventPointerType::POINTER_TYPE_ERASER) | 2952 else if (type == ui::EventPointerType::POINTER_TYPE_ERASER) |
| 2953 wayland_type = ZCR_POINTER_STYLUS_V1_TOOL_TYPE_ERASER; | 2953 wayland_type = ZCR_POINTER_STYLUS_V1_TOOL_TYPE_ERASER; |
| 2954 zcr_pointer_stylus_v1_send_tool_change(resource_, wayland_type); | 2954 zcr_touch_stylus_v1_send_tool(resource_, touch_id, wayland_type); |
| 2955 } | 2955 } |
| 2956 void OnPointerForce(base::TimeTicks time_stamp, float force) override { | 2956 void OnTouchForce(base::TimeTicks time_stamp, |
| 2957 zcr_pointer_stylus_v1_send_force(resource_, | 2957 int touch_id, |
| 2958 TimeTicksToMilliseconds(time_stamp), | 2958 float force) override { |
| 2959 wl_fixed_from_double(force)); | 2959 zcr_touch_stylus_v1_send_force(resource_, |
| 2960 TimeTicksToMilliseconds(time_stamp), | |
| 2961 touch_id, wl_fixed_from_double(force)); | |
| 2960 } | 2962 } |
| 2961 void OnPointerTilt(base::TimeTicks time_stamp, gfx::Vector2dF tilt) override { | 2963 void OnTouchTilt(base::TimeTicks time_stamp, |
| 2962 zcr_pointer_stylus_v1_send_tilt( | 2964 int touch_id, |
| 2963 resource_, TimeTicksToMilliseconds(time_stamp), | 2965 gfx::Vector2dF tilt) override { |
| 2966 zcr_touch_stylus_v1_send_tilt( | |
| 2967 resource_, TimeTicksToMilliseconds(time_stamp), touch_id, | |
| 2964 wl_fixed_from_double(tilt.x()), wl_fixed_from_double(tilt.y())); | 2968 wl_fixed_from_double(tilt.x()), wl_fixed_from_double(tilt.y())); |
| 2965 } | 2969 } |
| 2966 | 2970 |
| 2967 private: | 2971 private: |
| 2968 wl_resource* resource_; | 2972 wl_resource* resource_; |
| 2969 Pointer* pointer_; | 2973 Touch* touch_; |
| 2970 | 2974 |
| 2971 // The client who own this pointer stylus instance. | 2975 DISALLOW_COPY_AND_ASSIGN(WaylandTouchStylusDelegate); |
| 2972 wl_client* client() const { return wl_resource_get_client(resource_); } | 2976 }; |
| 2973 | 2977 |
| 2974 DISALLOW_COPY_AND_ASSIGN(WaylandPointerStylusDelegate); | 2978 void touch_stylus_destroy(wl_client* client, wl_resource* resource) { |
| 2975 }; | 2979 wl_resource_destroy(resource); |
| 2980 } | |
| 2981 | |
| 2982 const struct zcr_touch_stylus_v1_interface touch_stylus_implementation = { | |
| 2983 touch_stylus_destroy}; | |
| 2984 | |
| 2985 //////////////////////////////////////////////////////////////////////////////// | |
| 2986 // stylus_v2 interface: | |
| 2987 | |
| 2988 void stylus_get_touch_stylus(wl_client* client, | |
| 2989 wl_resource* resource, | |
| 2990 uint32_t id, | |
| 2991 wl_resource* touch_resource) { | |
| 2992 Touch* touch = GetUserDataAs<Touch>(touch_resource); | |
| 2993 | |
| 2994 wl_resource* stylus_resource = | |
| 2995 wl_resource_create(client, &zcr_touch_stylus_v1_interface, 1, id); | |
| 2996 | |
| 2997 SetImplementation( | |
| 2998 stylus_resource, &touch_stylus_implementation, | |
| 2999 base::MakeUnique<WaylandTouchStylusDelegate>(stylus_resource, touch)); | |
| 3000 } | |
| 3001 | |
| 3002 const struct zcr_stylus_v2_interface stylus_v2_implementation = { | |
| 3003 stylus_get_touch_stylus}; | |
| 3004 | |
| 3005 void bind_stylus_v2(wl_client* client, | |
| 3006 void* data, | |
| 3007 uint32_t version, | |
| 3008 uint32_t id) { | |
| 3009 wl_resource* resource = | |
| 3010 wl_resource_create(client, &zcr_stylus_v2_interface, version, id); | |
| 3011 wl_resource_set_implementation(resource, &stylus_v2_implementation, data, | |
| 3012 nullptr); | |
| 3013 } | |
| 3014 | |
| 3015 //////////////////////////////////////////////////////////////////////////////// | |
| 3016 // pointer_stylus interface (deprecated) | |
| 3017 // TODO(denniskempin): Remove once client no longer depends on this interface. | |
| 2976 | 3018 |
| 2977 void pointer_stylus_destroy(wl_client* client, wl_resource* resource) { | 3019 void pointer_stylus_destroy(wl_client* client, wl_resource* resource) { |
| 2978 wl_resource_destroy(resource); | 3020 wl_resource_destroy(resource); |
| 2979 } | 3021 } |
| 2980 | 3022 |
| 2981 const struct zcr_pointer_stylus_v1_interface pointer_stylus_implementation = { | 3023 const struct zcr_pointer_stylus_v1_interface pointer_stylus_implementation = { |
| 2982 pointer_stylus_destroy}; | 3024 pointer_stylus_destroy}; |
| 2983 | 3025 |
| 2984 //////////////////////////////////////////////////////////////////////////////// | 3026 //////////////////////////////////////////////////////////////////////////////// |
| 2985 // stylus interface: | 3027 // stylus_v1 interface (deprecated): |
| 3028 // TODO(denniskempin): Remove once client no longer depends on this interface. | |
| 2986 | 3029 |
| 2987 void stylus_get_pointer_stylus(wl_client* client, | 3030 void stylus_get_pointer_stylus(wl_client* client, |
| 2988 wl_resource* resource, | 3031 wl_resource* resource, |
| 2989 uint32_t id, | 3032 uint32_t id, |
| 2990 wl_resource* pointer_resource) { | 3033 wl_resource* touch_resource) { |
| 2991 Pointer* pointer = GetUserDataAs<Pointer>(pointer_resource); | |
| 2992 | |
| 2993 wl_resource* stylus_resource = | 3034 wl_resource* stylus_resource = |
| 2994 wl_resource_create(client, &zcr_pointer_stylus_v1_interface, 1, id); | 3035 wl_resource_create(client, &zcr_pointer_stylus_v1_interface, 1, id); |
| 2995 | 3036 wl_resource_set_implementation( |
| 2996 SetImplementation( | 3037 stylus_resource, &pointer_stylus_implementation, nullptr, nullptr); |
| 2997 stylus_resource, &pointer_stylus_implementation, | |
| 2998 base::MakeUnique<WaylandPointerStylusDelegate>(stylus_resource, pointer)); | |
| 2999 } | 3038 } |
| 3000 | 3039 |
| 3001 const struct zcr_stylus_v1_interface stylus_implementation = { | 3040 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.
| |
| 3002 stylus_get_pointer_stylus}; | 3041 stylus_get_pointer_stylus}; |
| 3003 | 3042 |
| 3004 void bind_stylus(wl_client* client, void* data, uint32_t version, uint32_t id) { | 3043 void bind_stylus_v1(wl_client* client, |
| 3044 void* data, | |
| 3045 uint32_t version, | |
| 3046 uint32_t id) { | |
| 3005 wl_resource* resource = | 3047 wl_resource* resource = |
| 3006 wl_resource_create(client, &zcr_stylus_v1_interface, version, id); | 3048 wl_resource_create(client, &zcr_stylus_v1_interface, version, id); |
| 3007 wl_resource_set_implementation(resource, &stylus_implementation, data, | 3049 wl_resource_set_implementation(resource, &stylus_v1_implementation, data, |
| 3008 nullptr); | 3050 nullptr); |
| 3009 } | 3051 } |
| 3010 | 3052 |
| 3011 } // namespace | 3053 } // namespace |
| 3012 | 3054 |
| 3013 //////////////////////////////////////////////////////////////////////////////// | 3055 //////////////////////////////////////////////////////////////////////////////// |
| 3014 // Server, public: | 3056 // Server, public: |
| 3015 | 3057 |
| 3016 Server::Server(Display* display) | 3058 Server::Server(Display* display) |
| 3017 : display_(display), wl_display_(wl_display_create()) { | 3059 : display_(display), wl_display_(wl_display_create()) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 3042 bind_viewporter); | 3084 bind_viewporter); |
| 3043 wl_global_create(wl_display_.get(), &zcr_secure_output_v1_interface, 1, | 3085 wl_global_create(wl_display_.get(), &zcr_secure_output_v1_interface, 1, |
| 3044 display_, bind_secure_output); | 3086 display_, bind_secure_output); |
| 3045 wl_global_create(wl_display_.get(), &zcr_alpha_compositing_v1_interface, 1, | 3087 wl_global_create(wl_display_.get(), &zcr_alpha_compositing_v1_interface, 1, |
| 3046 display_, bind_alpha_compositing); | 3088 display_, bind_alpha_compositing); |
| 3047 wl_global_create(wl_display_.get(), &zcr_remote_shell_v1_interface, | 3089 wl_global_create(wl_display_.get(), &zcr_remote_shell_v1_interface, |
| 3048 remote_shell_version, display_, bind_remote_shell); | 3090 remote_shell_version, display_, bind_remote_shell); |
| 3049 wl_global_create(wl_display_.get(), &zcr_gaming_input_v1_interface, 1, | 3091 wl_global_create(wl_display_.get(), &zcr_gaming_input_v1_interface, 1, |
| 3050 display_, bind_gaming_input); | 3092 display_, bind_gaming_input); |
| 3051 wl_global_create(wl_display_.get(), &zcr_stylus_v1_interface, 1, display_, | 3093 wl_global_create(wl_display_.get(), &zcr_stylus_v1_interface, 1, display_, |
| 3052 bind_stylus); | 3094 bind_stylus_v1); |
| 3095 wl_global_create(wl_display_.get(), &zcr_stylus_v2_interface, 1, display_, | |
| 3096 bind_stylus_v2); | |
| 3053 } | 3097 } |
| 3054 | 3098 |
| 3055 Server::~Server() {} | 3099 Server::~Server() {} |
| 3056 | 3100 |
| 3057 // static | 3101 // static |
| 3058 std::unique_ptr<Server> Server::Create(Display* display) { | 3102 std::unique_ptr<Server> Server::Create(Display* display) { |
| 3059 std::unique_ptr<Server> server(new Server(display)); | 3103 std::unique_ptr<Server> server(new Server(display)); |
| 3060 | 3104 |
| 3061 char* runtime_dir = getenv("XDG_RUNTIME_DIR"); | 3105 char* runtime_dir = getenv("XDG_RUNTIME_DIR"); |
| 3062 if (!runtime_dir) { | 3106 if (!runtime_dir) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3114 DCHECK(event_loop); | 3158 DCHECK(event_loop); |
| 3115 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 3159 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
| 3116 } | 3160 } |
| 3117 | 3161 |
| 3118 void Server::Flush() { | 3162 void Server::Flush() { |
| 3119 wl_display_flush_clients(wl_display_.get()); | 3163 wl_display_flush_clients(wl_display_.get()); |
| 3120 } | 3164 } |
| 3121 | 3165 |
| 3122 } // namespace wayland | 3166 } // namespace wayland |
| 3123 } // namespace exo | 3167 } // namespace exo |
| OLD | NEW |