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

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

Issue 2780623002: exo: Fix multi-display hardware cursor (Closed)
Patch Set: Address comments 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();
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(const gfx::Point& hotspot);
reveman 2017/05/25 10:52:55 why do we need to pass hotspot as an argument to t
Dominik Laskowski 2017/05/31 02:06:27 As discussed offline, the bitmap and hotspot are u
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(const gfx::Point& hotspot,
82 std::unique_ptr<cc::CopyOutputResult> result); 82 std::unique_ptr<cc::CopyOutputResult> result);
83 83
84 // Update cursor to reflect the current value of |cursor_|. 84 // Synchronously update the cursor to the latest snapshot.
85 void UpdateCursor(); 85 void UpdateCursor();
86 86
87 void SetCursor(gfx::NativeCursor cursor);
reveman 2017/05/25 10:52:55 Please a comment for this function and I think we
Dominik Laskowski 2017/05/31 02:06:27 Done.
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. 101 // The display-independent scale applied to the cursor.
100 float cursor_scale_ = 1.0f; 102 float cursor_scale_ = 1.0f;
reveman 2017/05/25 10:52:55 Please keep this the scale of |cursor_| as before.
Dominik Laskowski 2017/05/31 02:06:26 Removed per offline chat.
101 103
104 // Device scale factor of the display where the cursor sprite is located.
105 float cursor_device_scale_factor_ = 1.0f;
reveman 2017/05/25 10:52:55 Actually, I don't think we need this as all it sho
Dominik Laskowski 2017/05/31 02:06:27 Removed per offline chat.
106
107 // Rotation of the display where the cursor sprite is located.
108 display::Display::Rotation cursor_rotation_ = display::Display::ROTATE_0;
109
102 // The position of the pointer surface relative to the pointer location. 110 // The position of the pointer surface relative to the pointer location.
103 gfx::Point hotspot_; 111 gfx::Point hotspot_;
104 112
105 // The current cursor. 113 // Latest cursor snapshot.
106 ui::Cursor cursor_; 114 SkBitmap cursor_bitmap_;
reveman 2017/05/25 10:52:55 Please keep cursor in addition to bitmap as it's h
Dominik Laskowski 2017/05/31 02:06:27 Done.
107 115
108 // Source used for cursor capture copy output requests. 116 // Source used for cursor capture copy output requests.
109 const base::UnguessableToken cursor_capture_source_id_; 117 const base::UnguessableToken cursor_capture_source_id_;
110 118
111 // Last received event type. 119 // Last received event type.
112 ui::EventType last_event_type_ = ui::ET_UNKNOWN; 120 ui::EventType last_event_type_ = ui::ET_UNKNOWN;
113 121
114 // Weak pointer factory used for cursor capture callbacks. 122 // Weak pointer factory used for cursor capture callbacks.
115 base::WeakPtrFactory<Pointer> cursor_capture_weak_ptr_factory_; 123 base::WeakPtrFactory<Pointer> cursor_capture_weak_ptr_factory_;
116 124
117 DISALLOW_COPY_AND_ASSIGN(Pointer); 125 DISALLOW_COPY_AND_ASSIGN(Pointer);
118 }; 126 };
119 127
120 } // namespace exo 128 } // namespace exo
121 129
122 #endif // COMPONENTS_EXO_POINTER_H_ 130 #endif // COMPONENTS_EXO_POINTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698