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

Side by Side Diff: components/exo/pointer.h

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
« no previous file with comments | « no previous file | components/exo/pointer.cc » ('j') | components/exo/pointer.cc » ('J')
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 #ifndef COMPONENTS_EXO_POINTER_H_ 5 #ifndef COMPONENTS_EXO_POINTER_H_
6 #define COMPONENTS_EXO_POINTER_H_ 6 #define COMPONENTS_EXO_POINTER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "components/exo/surface_delegate.h" 11 #include "components/exo/surface_delegate.h"
12 #include "components/exo/surface_observer.h" 12 #include "components/exo/surface_observer.h"
13 #include "ui/aura/client/cursor_client_observer.h" 13 #include "ui/aura/client/cursor_client_observer.h"
14 #include "ui/events/event_handler.h" 14 #include "ui/events/event_handler.h"
15 #include "ui/gfx/geometry/point.h" 15 #include "ui/gfx/geometry/point.h"
16 #include "ui/gfx/geometry/point_f.h" 16 #include "ui/gfx/geometry/point_f.h"
17 17
18 namespace ui { 18 namespace ui {
19 class Event; 19 class Event;
20 class MouseEvent; 20 class MouseEvent;
21 class MouseWheelEvent; 21 class MouseWheelEvent;
22 } 22 }
23 23
24 namespace views { 24 namespace views {
25 class Widget; 25 class Widget;
26 } 26 }
27 27
28 namespace exo { 28 namespace exo {
29 class PointerDelegate; 29 class PointerDelegate;
30 class PointerStylusDelegate;
30 class Surface; 31 class Surface;
31 32
32 // This class implements a client pointer that represents one or more input 33 // This class implements a client pointer that represents one or more input
33 // devices, such as mice, which control the pointer location and pointer focus. 34 // devices, such as mice, which control the pointer location and pointer focus.
34 class Pointer : public ui::EventHandler, 35 class Pointer : public ui::EventHandler,
35 public aura::client::CursorClientObserver, 36 public aura::client::CursorClientObserver,
36 public SurfaceDelegate, 37 public SurfaceDelegate,
37 public SurfaceObserver { 38 public SurfaceObserver {
38 public: 39 public:
39 explicit Pointer(PointerDelegate* delegate); 40 explicit Pointer(PointerDelegate* delegate);
40 ~Pointer() override; 41 ~Pointer() override;
41 42
42 // Set the pointer surface, i.e., the surface that contains the pointer image 43 // Set the pointer surface, i.e., the surface that contains the pointer image
43 // (cursor). The |hotspot| argument defines the position of the pointer 44 // (cursor). The |hotspot| argument defines the position of the pointer
44 // surface relative to the pointer location. Its top-left corner is always at 45 // surface relative to the pointer location. Its top-left corner is always at
45 // (x, y) - (hotspot.x, hotspot.y), where (x, y) are the coordinates of the 46 // (x, y) - (hotspot.x, hotspot.y), where (x, y) are the coordinates of the
46 // pointer location, in surface local coordinates. 47 // pointer location, in surface local coordinates.
47 void SetCursor(Surface* surface, const gfx::Point& hotspot); 48 void SetCursor(Surface* surface, const gfx::Point& hotspot);
48 49
50 // Set delegate for stylus events.
51 void SetStylusDelegate(PointerStylusDelegate* delegate);
52
49 // Overridden from ui::EventHandler: 53 // Overridden from ui::EventHandler:
50 void OnMouseEvent(ui::MouseEvent* event) override; 54 void OnMouseEvent(ui::MouseEvent* event) override;
51 void OnScrollEvent(ui::ScrollEvent* event) override; 55 void OnScrollEvent(ui::ScrollEvent* event) override;
52 56
53 // Overridden from aura::client::CursorClientObserver: 57 // Overridden from aura::client::CursorClientObserver:
54 void OnCursorSetChanged(ui::CursorSetType cursor_set) override; 58 void OnCursorSetChanged(ui::CursorSetType cursor_set) override;
55 59
56 // Overridden from SurfaceDelegate: 60 // Overridden from SurfaceDelegate:
57 void OnSurfaceCommit() override; 61 void OnSurfaceCommit() override;
58 bool IsSurfaceSynchronized() const override; 62 bool IsSurfaceSynchronized() const override;
59 63
60 // Overridden from SurfaceObserver: 64 // Overridden from SurfaceObserver:
61 void OnSurfaceDestroying(Surface* surface) override; 65 void OnSurfaceDestroying(Surface* surface) override;
62 66
63 private: 67 private:
64 // Creates the |widget_| for pointer. 68 // Creates the |widget_| for pointer.
65 void CreatePointerWidget(); 69 void CreatePointerWidget();
66 70
67 // Updates the scale of the cursor with the latest state. 71 // Updates the scale of the cursor with the latest state.
68 void UpdateCursorScale(); 72 void UpdateCursorScale();
69 73
70 // Returns the effective target for |event|. 74 // Returns the effective target for |event|.
71 Surface* GetEffectiveTargetForEvent(ui::Event* event) const; 75 Surface* GetEffectiveTargetForEvent(ui::Event* event) const;
72 76
73 // The delegate instance that all events are dispatched to. 77 // The delegate instance that all events are dispatched to.
74 PointerDelegate* const delegate_; 78 PointerDelegate* const delegate_;
75 79
80 // The delegate instance that all stylus related events are dispatched to.
81 PointerStylusDelegate* stylus_delegate_ = nullptr;
82
76 // The widget for the pointer cursor. 83 // The widget for the pointer cursor.
77 std::unique_ptr<views::Widget> widget_; 84 std::unique_ptr<views::Widget> widget_;
78 85
79 // The current pointer surface. 86 // The current pointer surface.
80 Surface* surface_ = nullptr; 87 Surface* surface_ = nullptr;
81 88
82 // The current focus surface for the pointer. 89 // The current focus surface for the pointer.
83 Surface* focus_ = nullptr; 90 Surface* focus_ = nullptr;
84 91
85 // The location of the pointer in the current focus surface. 92 // The location of the pointer in the current focus surface.
86 gfx::PointF location_; 93 gfx::PointF location_;
87 94
88 // The scale applied to the cursor to compensate for the UI scale. 95 // The scale applied to the cursor to compensate for the UI scale.
89 float cursor_scale_ = 1.0f; 96 float cursor_scale_ = 1.0f;
90 97
91 // The position of the pointer surface relative to the pointer location. 98 // The position of the pointer surface relative to the pointer location.
92 gfx::Point hotspot_; 99 gfx::Point hotspot_;
93 100
101 // The current pointer type.
102 ui::EventPointerType pointer_type_;
103
104 // The current pointer tilt.
105 gfx::Vector2dF tilt_;
106
107 // The current pointer force.
108 float force_;
109
94 DISALLOW_COPY_AND_ASSIGN(Pointer); 110 DISALLOW_COPY_AND_ASSIGN(Pointer);
95 }; 111 };
96 112
97 } // namespace exo 113 } // namespace exo
98 114
99 #endif // COMPONENTS_EXO_POINTER_H_ 115 #endif // COMPONENTS_EXO_POINTER_H_
OLDNEW
« no previous file with comments | « no previous file | components/exo/pointer.cc » ('j') | components/exo/pointer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698