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

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

Issue 2780623002: exo: Fix multi-display hardware cursor (Closed)
Patch Set: Rebase properly Created 3 years, 8 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 "ui/base/cursor/cursor.h" 16 #include "ui/base/cursor/cursor.h"
17 #include "ui/display/display.h"
17 #include "ui/events/event_handler.h" 18 #include "ui/events/event_handler.h"
18 #include "ui/gfx/geometry/point.h" 19 #include "ui/gfx/geometry/point.h"
19 #include "ui/gfx/geometry/point_f.h" 20 #include "ui/gfx/geometry/point_f.h"
20 #include "ui/gfx/native_widget_types.h" 21 #include "ui/gfx/native_widget_types.h"
21 22
22 namespace cc { 23 namespace cc {
23 class CopyOutputResult; 24 class CopyOutputResult;
24 } 25 }
25 26
26 namespace ui { 27 namespace ui {
(...skipping 24 matching lines...) Expand all
51 52
52 // Returns the current cursor for the pointer. 53 // Returns the current cursor for the pointer.
53 gfx::NativeCursor GetCursor(); 54 gfx::NativeCursor GetCursor();
54 55
55 // Overridden from ui::EventHandler: 56 // Overridden from ui::EventHandler:
56 void OnMouseEvent(ui::MouseEvent* event) override; 57 void OnMouseEvent(ui::MouseEvent* event) override;
57 void OnScrollEvent(ui::ScrollEvent* event) override; 58 void OnScrollEvent(ui::ScrollEvent* event) override;
58 59
59 // Overridden from WMHelper::CursorObserver: 60 // Overridden from WMHelper::CursorObserver:
60 void OnCursorSetChanged(ui::CursorSetType cursor_set) override; 61 void OnCursorSetChanged(ui::CursorSetType cursor_set) override;
62 void OnCursorDisplayChanging(const display::Display& display) override;
61 63
62 // Overridden from SurfaceDelegate: 64 // Overridden from SurfaceDelegate:
63 void OnSurfaceCommit() override; 65 void OnSurfaceCommit() override;
64 bool IsSurfaceSynchronized() const override; 66 bool IsSurfaceSynchronized() const override;
65 67
66 // Overridden from SurfaceObserver: 68 // Overridden from SurfaceObserver:
67 void OnSurfaceDestroying(Surface* surface) override; 69 void OnSurfaceDestroying(Surface* surface) override;
68 70
69 private: 71 private:
70 // Returns the effective target for |event|. 72 // Returns the effective target for |event|.
71 Surface* GetEffectiveTargetForEvent(ui::Event* event) const; 73 Surface* GetEffectiveTargetForEvent(ui::Event* event) const;
72 74
73 // Recompute cursor scale and update cursor if scale changed.
74 void UpdateCursorScale();
75
76 // Asynchronously update the cursor by capturing a snapshot of |surface_|. 75 // Asynchronously update the cursor by capturing a snapshot of |surface_|.
77 void CaptureCursor(); 76 void CaptureCursor(bool force);
reveman 2017/03/30 07:47:53 why do we need |force|? can the behavior with forc
Dominik Laskowski 2017/04/05 17:59:25 No, it should only be used to bypass cursor lockin
78 77
79 // Called when cursor snapshot has been captured. 78 // Called when cursor snapshot has been captured.
80 void OnCursorCaptured(const gfx::Point& hotspot, 79 void OnCursorCaptured(gfx::Point hotspot,
reveman 2017/03/30 07:47:53 why not const?
Dominik Laskowski 2017/04/05 17:59:25 Belongs to the dependent CL. Moved.
80 bool force,
81 std::unique_ptr<cc::CopyOutputResult> result); 81 std::unique_ptr<cc::CopyOutputResult> result);
82 82
83 // Update cursor to reflect the current value of |cursor_|. 83 // If |force| is true, the cursor is updated even if locked.
84 void UpdateCursor(); 84 void UpdateCursor(gfx::NativeCursor cursor, bool force);
85 85
86 // The delegate instance that all events are dispatched to. 86 // The delegate instance that all events are dispatched to.
87 PointerDelegate* const delegate_; 87 PointerDelegate* const delegate_;
88 88
89 // The current pointer surface. 89 // The current pointer surface.
90 Surface* surface_ = nullptr; 90 Surface* surface_ = nullptr;
91 91
92 // The current focus surface for the pointer. 92 // The current focus surface for the pointer.
93 Surface* focus_ = nullptr; 93 Surface* focus_ = nullptr;
94 94
95 // The location of the pointer in the current focus surface. 95 // The location of the pointer in the current focus surface.
96 gfx::PointF location_; 96 gfx::PointF location_;
97 97
98 // The scale applied to the cursor to compensate for the UI scale. 98 // The display-dependent scale applied to the cursor.
99 float display_scale_ = 1.0f;
100
101 // The display-independent scale applied to the cursor.
99 float cursor_scale_ = 1.0f; 102 float cursor_scale_ = 1.0f;
100 103
104 float device_scale_factor_ = 1.0f;
reveman 2017/03/30 07:47:53 Please add a comment here for consistency.
Dominik Laskowski 2017/04/05 17:59:25 Done.
105
101 // The position of the pointer surface relative to the pointer location. 106 // The position of the pointer surface relative to the pointer location.
102 gfx::Point hotspot_; 107 gfx::Point hotspot_;
103 108
104 // The current cursor. 109 const std::unique_ptr<aura::Window> cursor_;
reveman 2017/03/30 07:47:53 why do we have to change this? We should avoid usi
Dominik Laskowski 2017/04/05 17:59:25 The snapshot is requested on this layer, because t
105 ui::Cursor cursor_;
106 110
107 // Source used for cursor capture copy output requests. 111 // Source used for cursor capture copy output requests.
108 const base::UnguessableToken cursor_capture_source_id_; 112 base::UnguessableToken cursor_capture_source_id_;
109 113
110 // Weak pointer factory used for cursor capture callbacks. 114 // Weak pointer factory used for cursor capture callbacks.
111 base::WeakPtrFactory<Pointer> cursor_capture_weak_ptr_factory_; 115 base::WeakPtrFactory<Pointer> cursor_capture_weak_ptr_factory_;
112 116
113 DISALLOW_COPY_AND_ASSIGN(Pointer); 117 DISALLOW_COPY_AND_ASSIGN(Pointer);
114 }; 118 };
115 119
116 } // namespace exo 120 } // namespace exo
117 121
118 #endif // COMPONENTS_EXO_POINTER_H_ 122 #endif // COMPONENTS_EXO_POINTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698