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

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, 7 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"
18 #include "ui/display/display.h"
17 #include "ui/events/event_constants.h" 19 #include "ui/events/event_constants.h"
18 #include "ui/events/event_handler.h" 20 #include "ui/events/event_handler.h"
19 #include "ui/gfx/geometry/point.h" 21 #include "ui/gfx/geometry/point.h"
20 #include "ui/gfx/geometry/point_f.h" 22 #include "ui/gfx/geometry/point_f.h"
21 #include "ui/gfx/native_widget_types.h" 23 #include "ui/gfx/native_widget_types.h"
22 24
23 namespace cc { 25 namespace cc {
24 class CopyOutputResult; 26 class CopyOutputResult;
25 } 27 }
26 28
(...skipping 25 matching lines...) Expand all
52 54
53 // Returns the current cursor for the pointer. 55 // Returns the current cursor for the pointer.
54 gfx::NativeCursor GetCursor(); 56 gfx::NativeCursor GetCursor();
55 57
56 // Overridden from ui::EventHandler: 58 // Overridden from ui::EventHandler:
57 void OnMouseEvent(ui::MouseEvent* event) override; 59 void OnMouseEvent(ui::MouseEvent* event) override;
58 void OnScrollEvent(ui::ScrollEvent* event) override; 60 void OnScrollEvent(ui::ScrollEvent* event) override;
59 61
60 // Overridden from WMHelper::CursorObserver: 62 // Overridden from WMHelper::CursorObserver:
61 void OnCursorSetChanged(ui::CursorSetType cursor_set) override; 63 void OnCursorSetChanged(ui::CursorSetType cursor_set) override;
64 void OnCursorDisplayChanging(const display::Display& display) override;
62 65
63 // Overridden from SurfaceDelegate: 66 // Overridden from SurfaceDelegate:
64 void OnSurfaceCommit() override; 67 void OnSurfaceCommit() override;
65 bool IsSurfaceSynchronized() const override; 68 bool IsSurfaceSynchronized() const override;
66 69
67 // Overridden from SurfaceObserver: 70 // Overridden from SurfaceObserver:
68 void OnSurfaceDestroying(Surface* surface) override; 71 void OnSurfaceDestroying(Surface* surface) override;
69 72
70 private: 73 private:
71 // Returns the effective target for |event|. 74 // Returns the effective target for |event|.
72 Surface* GetEffectiveTargetForEvent(ui::Event* event) const; 75 Surface* GetEffectiveTargetForEvent(ui::Event* event) const;
73 76
74 // Recompute cursor scale and update cursor if scale changed.
75 void UpdateCursorScale();
reveman 2017/05/23 17:06:58 Can we keep this and instead add a UpdateCursorDev
Dominik Laskowski 2017/05/24 00:43:04 Checking for scale/rotation changes for each mouse
reveman 2017/05/25 10:52:55 Yes, let's rename this to UpdateCursor() and call
Dominik Laskowski 2017/05/31 02:06:26 Done.
76
77 // Asynchronously update the cursor by capturing a snapshot of |surface_|. 77 // Asynchronously update the cursor by capturing a snapshot of |surface_|.
78 void CaptureCursor(); 78 void CaptureCursor();
79 79
80 // Called when cursor snapshot has been captured. 80 // Called when cursor snapshot has been captured.
81 void OnCursorCaptured(const gfx::Point& hotspot, 81 void OnCursorCaptured(std::unique_ptr<cc::CopyOutputResult> result);
reveman 2017/05/23 17:06:57 I think we need to have hotspot updates flow throu
Dominik Laskowski 2017/05/24 00:43:04 Good point. I've updated SetCursor to save the hot
82 std::unique_ptr<cc::CopyOutputResult> result);
83 82
84 // Update cursor to reflect the current value of |cursor_|. 83 // Synchronously update the cursor to the latest snapshot.
85 void UpdateCursor(); 84 void UpdateCursor();
86 85
86 void SetCursor(gfx::NativeCursor cursor);
87
87 // The delegate instance that all events are dispatched to. 88 // The delegate instance that all events are dispatched to.
88 PointerDelegate* const delegate_; 89 PointerDelegate* const delegate_;
89 90
90 // The current pointer surface. 91 // The current pointer surface.
91 Surface* surface_ = nullptr; 92 Surface* surface_ = nullptr;
92 93
93 // The current focus surface for the pointer. 94 // The current focus surface for the pointer.
94 Surface* focus_ = nullptr; 95 Surface* focus_ = nullptr;
95 96
96 // The location of the pointer in the current focus surface. 97 // The location of the pointer in the current focus surface.
97 gfx::PointF location_; 98 gfx::PointF location_;
98 99
99 // The scale applied to the cursor to compensate for the UI scale. 100 // The display-independent scale applied to the cursor.
100 float cursor_scale_ = 1.0f; 101 float cursor_scale_ = 1.0f;
101 102
103 // Device scale factor of the display where the mouse is located.
104 float device_scale_factor_ = 1.0f;
reveman 2017/05/23 17:06:58 nit: s/device_scale_factor_/cursor_device_scale_fa
Dominik Laskowski 2017/05/24 00:43:04 Done.
105
106 // Rotation of the display where the mouse is located.
107 display::Display::Rotation rotation_ = display::Display::ROTATE_0;
reveman 2017/05/23 17:06:58 nit: s/rotation_/cursor_rotation_/ and s/mouse/cur
Dominik Laskowski 2017/05/24 00:43:04 Done.
108
102 // The position of the pointer surface relative to the pointer location. 109 // The position of the pointer surface relative to the pointer location.
103 gfx::Point hotspot_; 110 gfx::Point hotspot_;
104 111
105 // The current cursor. 112 // Latest cursor snapshot.
106 ui::Cursor cursor_; 113 SkBitmap cursor_;
reveman 2017/05/23 17:06:58 Please keep this as before and add another member
Dominik Laskowski 2017/05/24 00:43:04 Renamed, but the ui::Cursor is redundant, i.e. Cur
107 114
108 // Source used for cursor capture copy output requests. 115 // Source used for cursor capture copy output requests.
109 const base::UnguessableToken cursor_capture_source_id_; 116 const base::UnguessableToken cursor_capture_source_id_;
110 117
111 // Last received event type. 118 // Last received event type.
112 ui::EventType last_event_type_ = ui::ET_UNKNOWN; 119 ui::EventType last_event_type_ = ui::ET_UNKNOWN;
113 120
114 // Weak pointer factory used for cursor capture callbacks. 121 // Weak pointer factory used for cursor capture callbacks.
115 base::WeakPtrFactory<Pointer> cursor_capture_weak_ptr_factory_; 122 base::WeakPtrFactory<Pointer> cursor_capture_weak_ptr_factory_;
116 123
117 DISALLOW_COPY_AND_ASSIGN(Pointer); 124 DISALLOW_COPY_AND_ASSIGN(Pointer);
118 }; 125 };
119 126
120 } // namespace exo 127 } // namespace exo
121 128
122 #endif // COMPONENTS_EXO_POINTER_H_ 129 #endif // COMPONENTS_EXO_POINTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698