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

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

Issue 2780623002: exo: Fix multi-display hardware cursor (Closed)
Patch Set: Fix accessibility test Created 3 years, 6 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
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 "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/unguessable_token.h" 12 #include "base/unguessable_token.h"
13 #include "components/exo/surface_delegate.h" 13 #include "components/exo/surface_delegate.h"
14 #include "components/exo/surface_observer.h" 14 #include "components/exo/surface_observer.h"
15 #include "components/exo/wm_helper.h" 15 #include "components/exo/wm_helper.h"
16 #include "third_party/skia/include/core/SkBitmap.h"
16 #include "ui/base/cursor/cursor.h" 17 #include "ui/base/cursor/cursor.h"
17 #include "ui/events/event_constants.h" 18 #include "ui/events/event_constants.h"
18 #include "ui/events/event_handler.h" 19 #include "ui/events/event_handler.h"
19 #include "ui/gfx/geometry/point.h" 20 #include "ui/gfx/geometry/point.h"
20 #include "ui/gfx/geometry/point_f.h" 21 #include "ui/gfx/geometry/point_f.h"
21 #include "ui/gfx/native_widget_types.h" 22 #include "ui/gfx/native_widget_types.h"
22 23
23 namespace cc { 24 namespace cc {
24 class CopyOutputResult; 25 class CopyOutputResult;
25 } 26 }
(...skipping 26 matching lines...) Expand all
52 53
53 // Returns the current cursor for the pointer. 54 // Returns the current cursor for the pointer.
54 gfx::NativeCursor GetCursor(); 55 gfx::NativeCursor GetCursor();
55 56
56 // Overridden from ui::EventHandler: 57 // Overridden from ui::EventHandler:
57 void OnMouseEvent(ui::MouseEvent* event) override; 58 void OnMouseEvent(ui::MouseEvent* event) override;
58 void OnScrollEvent(ui::ScrollEvent* event) override; 59 void OnScrollEvent(ui::ScrollEvent* event) override;
59 60
60 // Overridden from WMHelper::CursorObserver: 61 // Overridden from WMHelper::CursorObserver:
61 void OnCursorSetChanged(ui::CursorSetType cursor_set) override; 62 void OnCursorSetChanged(ui::CursorSetType cursor_set) override;
63 void OnCursorDisplayChanged(const display::Display& display) override;
62 64
63 // Overridden from SurfaceDelegate: 65 // Overridden from SurfaceDelegate:
64 void OnSurfaceCommit() override; 66 void OnSurfaceCommit() override;
65 bool IsSurfaceSynchronized() const override; 67 bool IsSurfaceSynchronized() const override;
66 68
67 // Overridden from SurfaceObserver: 69 // Overridden from SurfaceObserver:
68 void OnSurfaceDestroying(Surface* surface) override; 70 void OnSurfaceDestroying(Surface* surface) override;
69 71
70 private: 72 private:
71 // Returns the effective target for |event|. 73 // Returns the effective target for |event|.
72 Surface* GetEffectiveTargetForEvent(ui::Event* event) const; 74 Surface* GetEffectiveTargetForEvent(ui::Event* event) const;
73 75
74 // Recompute cursor scale and update cursor if scale changed.
75 void UpdateCursorScale();
76
77 // Asynchronously update the cursor by capturing a snapshot of |surface_|. 76 // Asynchronously update the cursor by capturing a snapshot of |surface_|.
78 void CaptureCursor(); 77 void CaptureCursor(const gfx::Point& hotspot);
79 78
80 // Called when cursor snapshot has been captured. 79 // Called when cursor snapshot has been captured.
81 void OnCursorCaptured(const gfx::Point& hotspot, 80 void OnCursorCaptured(const gfx::Point& hotspot,
82 std::unique_ptr<cc::CopyOutputResult> result); 81 std::unique_ptr<cc::CopyOutputResult> result);
83 82
83 // Synchronously update the cursor to the latest snapshot.
reveman 2017/05/31 03:33:10 nit: not sure synchronously needs to be mentioned
Dominik Laskowski 2017/05/31 20:35:55 Done.
84 void UpdateCursor();
85
84 // Update cursor to reflect the current value of |cursor_|. 86 // Update cursor to reflect the current value of |cursor_|.
85 void UpdateCursor(); 87 void SetCursor();
86 88
87 // The delegate instance that all events are dispatched to. 89 // The delegate instance that all events are dispatched to.
88 PointerDelegate* const delegate_; 90 PointerDelegate* const delegate_;
89 91
90 // The current pointer surface. 92 // The current pointer surface.
91 Surface* surface_ = nullptr; 93 Surface* surface_ = nullptr;
92 94
93 // The current focus surface for the pointer. 95 // The current focus surface for the pointer.
94 Surface* focus_ = nullptr; 96 Surface* focus_ = nullptr;
95 97
96 // The location of the pointer in the current focus surface. 98 // The location of the pointer in the current focus surface.
97 gfx::PointF location_; 99 gfx::PointF location_;
98 100
99 // The scale applied to the cursor to compensate for the UI scale.
100 float cursor_scale_ = 1.0f;
101
102 // The position of the pointer surface relative to the pointer location. 101 // The position of the pointer surface relative to the pointer location.
103 gfx::Point hotspot_; 102 gfx::Point hotspot_;
104 103
104 // Latest cursor snapshot.
105 SkBitmap cursor_bitmap_;
106
105 // The current cursor. 107 // The current cursor.
106 ui::Cursor cursor_; 108 ui::Cursor cursor_;
107 109
108 // Source used for cursor capture copy output requests. 110 // Source used for cursor capture copy output requests.
109 const base::UnguessableToken cursor_capture_source_id_; 111 const base::UnguessableToken cursor_capture_source_id_;
110 112
111 // Last received event type. 113 // Last received event type.
112 ui::EventType last_event_type_ = ui::ET_UNKNOWN; 114 ui::EventType last_event_type_ = ui::ET_UNKNOWN;
113 115
114 // Weak pointer factory used for cursor capture callbacks. 116 // Weak pointer factory used for cursor capture callbacks.
115 base::WeakPtrFactory<Pointer> cursor_capture_weak_ptr_factory_; 117 base::WeakPtrFactory<Pointer> cursor_capture_weak_ptr_factory_;
116 118
117 DISALLOW_COPY_AND_ASSIGN(Pointer); 119 DISALLOW_COPY_AND_ASSIGN(Pointer);
118 }; 120 };
119 121
120 } // namespace exo 122 } // namespace exo
121 123
122 #endif // COMPONENTS_EXO_POINTER_H_ 124 #endif // COMPONENTS_EXO_POINTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698