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

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

Issue 2780623002: exo: Fix multi-display hardware cursor (Closed)
Patch Set: Remove capture on mouse enter 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();
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(const gfx::Point& hotspot,
81 std::unique_ptr<cc::CopyOutputResult> result); 80 std::unique_ptr<cc::CopyOutputResult> result);
82 81
83 // Update cursor to reflect the current value of |cursor_|. 82 void UpdateCursor(gfx::NativeCursor cursor);
84 void UpdateCursor();
85 83
86 // The delegate instance that all events are dispatched to. 84 // The delegate instance that all events are dispatched to.
87 PointerDelegate* const delegate_; 85 PointerDelegate* const delegate_;
88 86
89 // The current pointer surface. 87 // The current pointer surface.
90 Surface* surface_ = nullptr; 88 Surface* surface_ = nullptr;
91 89
92 // The current focus surface for the pointer. 90 // The current focus surface for the pointer.
93 Surface* focus_ = nullptr; 91 Surface* focus_ = nullptr;
94 92
95 // The location of the pointer in the current focus surface. 93 // The location of the pointer in the current focus surface.
96 gfx::PointF location_; 94 gfx::PointF location_;
97 95
98 // The scale applied to the cursor to compensate for the UI scale. 96 // The display-dependent scale applied to the cursor.
97 float display_scale_ = 1.0f;
98
99 // The display-independent scale applied to the cursor.
99 float cursor_scale_ = 1.0f; 100 float cursor_scale_ = 1.0f;
100 101
102 // Device scale factor of the display where the mouse is located.
103 float device_scale_factor_ = 1.0f;
104
101 // The position of the pointer surface relative to the pointer location. 105 // The position of the pointer surface relative to the pointer location.
102 gfx::Point hotspot_; 106 gfx::Point hotspot_;
103 107
104 // The current cursor. 108 const std::unique_ptr<aura::Window> cursor_;
105 ui::Cursor cursor_;
106 109
107 // Source used for cursor capture copy output requests. 110 // Source used for cursor capture copy output requests.
108 const base::UnguessableToken cursor_capture_source_id_; 111 const base::UnguessableToken cursor_capture_source_id_;
109 112
110 // Weak pointer factory used for cursor capture callbacks. 113 // Weak pointer factory used for cursor capture callbacks.
111 base::WeakPtrFactory<Pointer> cursor_capture_weak_ptr_factory_; 114 base::WeakPtrFactory<Pointer> cursor_capture_weak_ptr_factory_;
112 115
113 DISALLOW_COPY_AND_ASSIGN(Pointer); 116 DISALLOW_COPY_AND_ASSIGN(Pointer);
114 }; 117 };
115 118
116 } // namespace exo 119 } // namespace exo
117 120
118 #endif // COMPONENTS_EXO_POINTER_H_ 121 #endif // COMPONENTS_EXO_POINTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698