Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: components/exo/wayland/server.cc

Issue 2153503005: exo: Implement support for zwp_stylus_v1 protocol (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@protocol
Patch Set: fixed nits and cleanup Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« components/exo/pointer.cc ('K') | « components/exo/wayland/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 #include <viewporter-server-protocol.h> 11 #include <viewporter-server-protocol.h>
12 #include <wayland-server-core.h> 12 #include <wayland-server-core.h>
13 #include <wayland-server-protocol-core.h> 13 #include <wayland-server-protocol-core.h>
14 14
15 // Note: core wayland headers need to be included before protocol headers. 15 // Note: core wayland headers need to be included before protocol headers.
16 #include <alpha-compositing-unstable-v1-server-protocol.h> // NOLINT 16 #include <alpha-compositing-unstable-v1-server-protocol.h> // NOLINT
17 #include <gaming-input-unstable-v1-server-protocol.h> // NOLINT 17 #include <gaming-input-unstable-v1-server-protocol.h> // NOLINT
18 #include <remote-shell-unstable-v1-server-protocol.h> // NOLINT 18 #include <remote-shell-unstable-v1-server-protocol.h> // NOLINT
19 #include <secure-output-unstable-v1-server-protocol.h> // NOLINT 19 #include <secure-output-unstable-v1-server-protocol.h> // NOLINT
20 #include <stylus-unstable-v1-server-protocol.h> // NOLINT
20 #include <xdg-shell-unstable-v5-server-protocol.h> // NOLINT 21 #include <xdg-shell-unstable-v5-server-protocol.h> // NOLINT
21 #include <vsync-feedback-unstable-v1-server-protocol.h> // NOLINT 22 #include <vsync-feedback-unstable-v1-server-protocol.h> // NOLINT
22 23
23 #include <algorithm> 24 #include <algorithm>
24 #include <cstdlib> 25 #include <cstdlib>
25 #include <iterator> 26 #include <iterator>
26 #include <string> 27 #include <string>
27 #include <utility> 28 #include <utility>
28 29
29 #include "ash/common/display/display_info.h" 30 #include "ash/common/display/display_info.h"
(...skipping 16 matching lines...) Expand all
46 #include "components/exo/buffer.h" 47 #include "components/exo/buffer.h"
47 #include "components/exo/display.h" 48 #include "components/exo/display.h"
48 #include "components/exo/gamepad.h" 49 #include "components/exo/gamepad.h"
49 #include "components/exo/gamepad_delegate.h" 50 #include "components/exo/gamepad_delegate.h"
50 #include "components/exo/keyboard.h" 51 #include "components/exo/keyboard.h"
51 #include "components/exo/keyboard_delegate.h" 52 #include "components/exo/keyboard_delegate.h"
52 #include "components/exo/notification_surface.h" 53 #include "components/exo/notification_surface.h"
53 #include "components/exo/notification_surface_manager.h" 54 #include "components/exo/notification_surface_manager.h"
54 #include "components/exo/pointer.h" 55 #include "components/exo/pointer.h"
55 #include "components/exo/pointer_delegate.h" 56 #include "components/exo/pointer_delegate.h"
57 #include "components/exo/pointer_stylus_delegate.h"
56 #include "components/exo/shared_memory.h" 58 #include "components/exo/shared_memory.h"
57 #include "components/exo/shell_surface.h" 59 #include "components/exo/shell_surface.h"
58 #include "components/exo/sub_surface.h" 60 #include "components/exo/sub_surface.h"
59 #include "components/exo/surface.h" 61 #include "components/exo/surface.h"
60 #include "components/exo/surface_property.h" 62 #include "components/exo/surface_property.h"
61 #include "components/exo/touch.h" 63 #include "components/exo/touch.h"
62 #include "components/exo/touch_delegate.h" 64 #include "components/exo/touch_delegate.h"
63 #include "ipc/unix_domain_socket_util.h" 65 #include "ipc/unix_domain_socket_util.h"
64 #include "third_party/skia/include/core/SkRegion.h" 66 #include "third_party/skia/include/core/SkRegion.h"
65 #include "ui/aura/window_property.h" 67 #include "ui/aura/window_property.h"
(...skipping 2819 matching lines...) Expand 10 before | Expand all | Expand 10 after
2885 2887
2886 std::unique_ptr<base::Thread> gaming_input_thread( 2888 std::unique_ptr<base::Thread> gaming_input_thread(
2887 new base::Thread("Exo gaming input polling thread.")); 2889 new base::Thread("Exo gaming input polling thread."));
2888 gaming_input_thread->StartWithOptions( 2890 gaming_input_thread->StartWithOptions(
2889 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); 2891 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
2890 2892
2891 SetImplementation(resource, &gaming_input_implementation, 2893 SetImplementation(resource, &gaming_input_implementation,
2892 std::move(gaming_input_thread)); 2894 std::move(gaming_input_thread));
2893 } 2895 }
2894 2896
2897 ////////////////////////////////////////////////////////////////////////////////
2898 // zwp_pointer_stylus_v1 interface:
reveman 2016/07/28 04:01:45 nit: "pointer_stylus interface:" is consistent wit
denniskempin 2016/07/28 17:17:39 Done.
2899
2900 class WaylandPointerStylusDelegate : public PointerStylusDelegate {
2901 public:
2902 WaylandPointerStylusDelegate(wl_resource* resource, Pointer* pointer)
2903 : resource_(resource), pointer_(pointer) {
2904 pointer_->SetStylusDelegate(this);
2905 }
2906 ~WaylandPointerStylusDelegate() {
2907 if (pointer_ != nullptr)
2908 pointer_->SetStylusDelegate(nullptr);
2909 }
2910 void OnPointerDestroying(Pointer* pointer) { pointer_ = nullptr; }
2911 void OnPointerToolChange(ui::EventPointerType type) override {
2912 uint wayland_type = ZWP_POINTER_STYLUS_V1_TOOL_TYPE_MOUSE;
2913 if (type == ui::EventPointerType::POINTER_TYPE_PEN)
2914 wayland_type = ZWP_POINTER_STYLUS_V1_TOOL_TYPE_PEN;
2915 zwp_pointer_stylus_v1_send_tool_change(resource_, wayland_type);
2916 }
2917 void OnPointerForce(base::TimeTicks time_stamp, float force) override {
2918 zwp_pointer_stylus_v1_send_force(resource_,
2919 TimeTicksToMilliseconds(time_stamp),
2920 wl_fixed_from_double(force));
2921 }
2922 void OnPointerTilt(base::TimeTicks time_stamp, gfx::Vector2dF tilt) override {
2923 zwp_pointer_stylus_v1_send_tilt(
2924 resource_, TimeTicksToMilliseconds(time_stamp),
2925 wl_fixed_from_double(tilt.x()), wl_fixed_from_double(tilt.y()));
2926 }
2927
2928 private:
2929 wl_resource* resource_;
2930 Pointer* pointer_;
2931
2932 // The client who own this pointer stylus instance.
2933 wl_client* client() const { return wl_resource_get_client(resource_); }
2934
2935 DISALLOW_COPY_AND_ASSIGN(WaylandPointerStylusDelegate);
2936 };
2937
2938 void pointer_stylus_destroy(wl_client* client, wl_resource* resource) {
2939 wl_resource_destroy(resource);
2940 }
2941
2942 const struct zwp_pointer_stylus_v1_interface pointer_stylus_implementation = {
2943 pointer_stylus_destroy};
2944
2945 ////////////////////////////////////////////////////////////////////////////////
2946 // zwp_stylus_v1 interface:
reveman 2016/07/28 04:01:45 nit: "stylus interface:"
denniskempin 2016/07/28 17:17:39 Done.
2947
2948 void stylus_get_pointer_stylus(wl_client* client,
2949 wl_resource* resource,
2950 uint32_t id,
2951 wl_resource* pointer_resource) {
2952 Pointer* pointer = GetUserDataAs<Pointer>(pointer_resource);
2953
2954 wl_resource* stylus_resource =
2955 wl_resource_create(client, &zwp_pointer_stylus_v1_interface, 1, id);
2956
2957 SetImplementation(stylus_resource, &pointer_stylus_implementation,
2958 base::WrapUnique(new WaylandPointerStylusDelegate(
2959 stylus_resource, pointer)));
2960 }
2961
2962 const struct zwp_stylus_v1_interface stylus_implementation = {
2963 stylus_get_pointer_stylus};
2964
2965 const uint32_t stylus_version = 1;
2966
2967 void bind_stylus(wl_client* client, void* data, uint32_t version, uint32_t id) {
2968 wl_resource* resource =
2969 wl_resource_create(client, &zwp_stylus_v1_interface, version, id);
2970 wl_resource_set_implementation(resource, &stylus_implementation, data,
2971 nullptr);
2972 }
2973
2895 } // namespace 2974 } // namespace
2896 2975
2897 //////////////////////////////////////////////////////////////////////////////// 2976 ////////////////////////////////////////////////////////////////////////////////
2898 // Server, public: 2977 // Server, public:
2899 2978
2900 Server::Server(Display* display) 2979 Server::Server(Display* display)
2901 : display_(display), wl_display_(wl_display_create()) { 2980 : display_(display), wl_display_(wl_display_create()) {
2902 wl_global_create(wl_display_.get(), &wl_compositor_interface, 2981 wl_global_create(wl_display_.get(), &wl_compositor_interface,
2903 compositor_version, display_, bind_compositor); 2982 compositor_version, display_, bind_compositor);
2904 wl_global_create(wl_display_.get(), &wl_shm_interface, 1, display_, bind_shm); 2983 wl_global_create(wl_display_.get(), &wl_shm_interface, 1, display_, bind_shm);
(...skipping 20 matching lines...) Expand all
2925 wl_global_create(wl_display_.get(), &wp_viewporter_interface, 1, display_, 3004 wl_global_create(wl_display_.get(), &wp_viewporter_interface, 1, display_,
2926 bind_viewporter); 3005 bind_viewporter);
2927 wl_global_create(wl_display_.get(), &zwp_secure_output_v1_interface, 1, 3006 wl_global_create(wl_display_.get(), &zwp_secure_output_v1_interface, 1,
2928 display_, bind_secure_output); 3007 display_, bind_secure_output);
2929 wl_global_create(wl_display_.get(), &zwp_alpha_compositing_v1_interface, 1, 3008 wl_global_create(wl_display_.get(), &zwp_alpha_compositing_v1_interface, 1,
2930 display_, bind_alpha_compositing); 3009 display_, bind_alpha_compositing);
2931 wl_global_create(wl_display_.get(), &zwp_remote_shell_v1_interface, 3010 wl_global_create(wl_display_.get(), &zwp_remote_shell_v1_interface,
2932 remote_shell_version, display_, bind_remote_shell); 3011 remote_shell_version, display_, bind_remote_shell);
2933 wl_global_create(wl_display_.get(), &zwp_gaming_input_v1_interface, 1, 3012 wl_global_create(wl_display_.get(), &zwp_gaming_input_v1_interface, 1,
2934 display_, bind_gaming_input); 3013 display_, bind_gaming_input);
3014 wl_global_create(wl_display_.get(), &zwp_stylus_v1_interface, 1, display_,
3015 bind_stylus);
2935 } 3016 }
2936 3017
2937 Server::~Server() {} 3018 Server::~Server() {}
2938 3019
2939 // static 3020 // static
2940 std::unique_ptr<Server> Server::Create(Display* display) { 3021 std::unique_ptr<Server> Server::Create(Display* display) {
2941 std::unique_ptr<Server> server(new Server(display)); 3022 std::unique_ptr<Server> server(new Server(display));
2942 3023
2943 char* runtime_dir = getenv("XDG_RUNTIME_DIR"); 3024 char* runtime_dir = getenv("XDG_RUNTIME_DIR");
2944 if (!runtime_dir) { 3025 if (!runtime_dir) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2996 DCHECK(event_loop); 3077 DCHECK(event_loop);
2997 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); 3078 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds());
2998 } 3079 }
2999 3080
3000 void Server::Flush() { 3081 void Server::Flush() {
3001 wl_display_flush_clients(wl_display_.get()); 3082 wl_display_flush_clients(wl_display_.get());
3002 } 3083 }
3003 3084
3004 } // namespace wayland 3085 } // namespace wayland
3005 } // namespace exo 3086 } // namespace exo
OLDNEW
« components/exo/pointer.cc ('K') | « components/exo/wayland/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698