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

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

Issue 2934953002: exo: Reparent pointer surface (Closed)
Patch Set: Add comment 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
« no previous file with comments | « no previous file | components/exo/pointer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 20 matching lines...) Expand all
31 } 31 }
32 32
33 namespace exo { 33 namespace exo {
34 class PointerDelegate; 34 class PointerDelegate;
35 class Surface; 35 class Surface;
36 36
37 // This class implements a client pointer that represents one or more input 37 // This class implements a client pointer that represents one or more input
38 // devices, such as mice, which control the pointer location and pointer focus. 38 // devices, such as mice, which control the pointer location and pointer focus.
39 class Pointer : public ui::EventHandler, 39 class Pointer : public ui::EventHandler,
40 public WMHelper::CursorObserver, 40 public WMHelper::CursorObserver,
41 public WMHelper::DisplayConfigurationObserver,
41 public SurfaceDelegate, 42 public SurfaceDelegate,
42 public SurfaceObserver { 43 public SurfaceObserver {
43 public: 44 public:
44 explicit Pointer(PointerDelegate* delegate); 45 explicit Pointer(PointerDelegate* delegate);
45 ~Pointer() override; 46 ~Pointer() override;
46 47
47 // Set the pointer surface, i.e., the surface that contains the pointer image 48 // Set the pointer surface, i.e., the surface that contains the pointer image
48 // (cursor). The |hotspot| argument defines the position of the pointer 49 // (cursor). The |hotspot| argument defines the position of the pointer
49 // surface relative to the pointer location. Its top-left corner is always at 50 // surface relative to the pointer location. Its top-left corner is always at
50 // (x, y) - (hotspot.x, hotspot.y), where (x, y) are the coordinates of the 51 // (x, y) - (hotspot.x, hotspot.y), where (x, y) are the coordinates of the
51 // pointer location, in surface local coordinates. 52 // pointer location, in surface local coordinates.
52 void SetCursor(Surface* surface, const gfx::Point& hotspot); 53 void SetCursor(Surface* surface, const gfx::Point& hotspot);
53 54
54 // Returns the current cursor for the pointer. 55 // Returns the current cursor for the pointer.
55 gfx::NativeCursor GetCursor(); 56 gfx::NativeCursor GetCursor();
56 57
57 // Overridden from ui::EventHandler: 58 // Overridden from ui::EventHandler:
58 void OnMouseEvent(ui::MouseEvent* event) override; 59 void OnMouseEvent(ui::MouseEvent* event) override;
59 void OnScrollEvent(ui::ScrollEvent* event) override; 60 void OnScrollEvent(ui::ScrollEvent* event) override;
60 61
61 // Overridden from WMHelper::CursorObserver: 62 // Overridden from WMHelper::CursorObserver:
62 void OnCursorSetChanged(ui::CursorSetType cursor_set) override; 63 void OnCursorSetChanged(ui::CursorSetType cursor_set) override;
63 void OnCursorDisplayChanged(const display::Display& display) override; 64 void OnCursorDisplayChanged(const display::Display& display) override;
64 65
66 // Overridden from WMHelper::DisplayConfigurationObserver:
67 void OnDisplayConfigurationChanged() override;
68
65 // Overridden from SurfaceDelegate: 69 // Overridden from SurfaceDelegate:
66 void OnSurfaceCommit() override; 70 void OnSurfaceCommit() override;
67 bool IsSurfaceSynchronized() const override; 71 bool IsSurfaceSynchronized() const override;
68 72
69 // Overridden from SurfaceObserver: 73 // Overridden from SurfaceObserver:
70 void OnSurfaceDestroying(Surface* surface) override; 74 void OnSurfaceDestroying(Surface* surface) override;
71 75
72 private: 76 private:
73 // Returns the effective target for |event|. 77 // Returns the effective target for |event|.
74 Surface* GetEffectiveTargetForEvent(ui::Event* event) const; 78 Surface* GetEffectiveTargetForEvent(ui::Event* event) const;
75 79
80 // Updates the |surface_| from which the cursor is captured.
81 void UpdatePointerSurface(Surface* surface);
82
76 // Asynchronously update the cursor by capturing a snapshot of |surface_|. 83 // Asynchronously update the cursor by capturing a snapshot of |surface_|.
77 void CaptureCursor(const gfx::Point& hotspot); 84 void CaptureCursor(const gfx::Point& hotspot);
78 85
79 // Called when cursor snapshot has been captured. 86 // Called when cursor snapshot has been captured.
80 void OnCursorCaptured(const gfx::Point& hotspot, 87 void OnCursorCaptured(const gfx::Point& hotspot,
81 std::unique_ptr<cc::CopyOutputResult> result); 88 std::unique_ptr<cc::CopyOutputResult> result);
82 89
83 // Update |cursor_| to |cursor_bitmap_| transformed for the current display. 90 // Update |cursor_| to |cursor_bitmap_| transformed for the current display.
84 void UpdateCursor(); 91 void UpdateCursor();
85 92
(...skipping 26 matching lines...) Expand all
112 119
113 // Weak pointer factory used for cursor capture callbacks. 120 // Weak pointer factory used for cursor capture callbacks.
114 base::WeakPtrFactory<Pointer> cursor_capture_weak_ptr_factory_; 121 base::WeakPtrFactory<Pointer> cursor_capture_weak_ptr_factory_;
115 122
116 DISALLOW_COPY_AND_ASSIGN(Pointer); 123 DISALLOW_COPY_AND_ASSIGN(Pointer);
117 }; 124 };
118 125
119 } // namespace exo 126 } // namespace exo
120 127
121 #endif // COMPONENTS_EXO_POINTER_H_ 128 #endif // COMPONENTS_EXO_POINTER_H_
OLDNEW
« no previous file with comments | « no previous file | components/exo/pointer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698