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

Side by Side Diff: ui/aura/env.h

Issue 2657283003: mash: make Env::last_mouse_location() accurate for Mus (Closed)
Patch Set: fix test Created 3 years, 10 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 | « ui/aura/BUILD.gn ('k') | ui/aura/env.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_AURA_ENV_H_ 5 #ifndef UI_AURA_ENV_H_
6 #define UI_AURA_ENV_H_ 6 #define UI_AURA_ENV_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 14 matching lines...) Expand all
25 namespace client { 25 namespace client {
26 class FocusClient; 26 class FocusClient;
27 } 27 }
28 28
29 namespace test { 29 namespace test {
30 class EnvTestHelper; 30 class EnvTestHelper;
31 } 31 }
32 32
33 class EnvObserver; 33 class EnvObserver;
34 class InputStateLookup; 34 class InputStateLookup;
35 class MusMouseLocationUpdater;
35 class Window; 36 class Window;
36 class WindowPort; 37 class WindowPort;
37 class WindowTreeClient; 38 class WindowTreeClient;
38 class WindowTreeHost; 39 class WindowTreeHost;
39 40
40 // A singleton object that tracks general state within Aura. 41 // A singleton object that tracks general state within Aura.
41 class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData { 42 class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData {
42 public: 43 public:
43 enum class Mode { 44 enum class Mode {
44 // Classic aura. 45 // Classic aura.
(...skipping 22 matching lines...) Expand all
67 int mouse_button_flags() const { return mouse_button_flags_; } 68 int mouse_button_flags() const { return mouse_button_flags_; }
68 void set_mouse_button_flags(int mouse_button_flags) { 69 void set_mouse_button_flags(int mouse_button_flags) {
69 mouse_button_flags_ = mouse_button_flags; 70 mouse_button_flags_ = mouse_button_flags;
70 } 71 }
71 // Returns true if a mouse button is down. This may query the native OS, 72 // Returns true if a mouse button is down. This may query the native OS,
72 // otherwise it uses |mouse_button_flags_|. 73 // otherwise it uses |mouse_button_flags_|.
73 bool IsMouseButtonDown() const; 74 bool IsMouseButtonDown() const;
74 75
75 // Gets/sets the last mouse location seen in a mouse event in the screen 76 // Gets/sets the last mouse location seen in a mouse event in the screen
76 // coordinates. 77 // coordinates.
77 const gfx::Point& last_mouse_location() const { return last_mouse_location_; } 78 const gfx::Point& last_mouse_location();
sadrul 2017/02/01 17:30:14 Alternatively, maybe we could keep this const, and
sky 2017/02/01 17:58:09 Done.
78 void set_last_mouse_location(const gfx::Point& last_mouse_location) { 79 void set_last_mouse_location(const gfx::Point& last_mouse_location) {
79 last_mouse_location_ = last_mouse_location; 80 last_mouse_location_ = last_mouse_location;
80 } 81 }
81 82
82 // Whether any touch device is currently down. 83 // Whether any touch device is currently down.
83 bool is_touch_down() const { return is_touch_down_; } 84 bool is_touch_down() const { return is_touch_down_; }
84 void set_touch_down(bool value) { is_touch_down_ = value; } 85 void set_touch_down(bool value) { is_touch_down_ = value; }
85 86
86 void set_context_factory(ui::ContextFactory* context_factory) { 87 void set_context_factory(ui::ContextFactory* context_factory) {
87 context_factory_ = context_factory; 88 context_factory_ = context_factory;
(...skipping 17 matching lines...) Expand all
105 // |window| may be null, which indicates all windows share a FocusClient. 106 // |window| may be null, which indicates all windows share a FocusClient.
106 void SetActiveFocusClient(client::FocusClient* focus_client, 107 void SetActiveFocusClient(client::FocusClient* focus_client,
107 Window* focus_client_root); 108 Window* focus_client_root);
108 client::FocusClient* active_focus_client() { return active_focus_client_; } 109 client::FocusClient* active_focus_client() { return active_focus_client_; }
109 Window* active_focus_client_root() { return active_focus_client_root_; } 110 Window* active_focus_client_root() { return active_focus_client_root_; }
110 111
111 private: 112 private:
112 class ActiveFocusClientWindowObserver; 113 class ActiveFocusClientWindowObserver;
113 114
114 friend class test::EnvTestHelper; 115 friend class test::EnvTestHelper;
116 friend class MusMouseLocationUpdater;
115 friend class Window; 117 friend class Window;
116 friend class WindowTreeHost; 118 friend class WindowTreeHost;
117 119
118 explicit Env(Mode mode); 120 explicit Env(Mode mode);
119 121
120 void Init(); 122 void Init();
121 123
122 // Called by the Window when it is initialized. Notifies observers. 124 // Called by the Window when it is initialized. Notifies observers.
123 void NotifyWindowInitialized(Window* window); 125 void NotifyWindowInitialized(Window* window);
124 126
(...skipping 15 matching lines...) Expand all
140 // to reset the value. 142 // to reset the value.
141 Mode mode_; 143 Mode mode_;
142 WindowTreeClient* window_tree_client_ = nullptr; 144 WindowTreeClient* window_tree_client_ = nullptr;
143 145
144 base::ObserverList<EnvObserver> observers_; 146 base::ObserverList<EnvObserver> observers_;
145 147
146 int mouse_button_flags_; 148 int mouse_button_flags_;
147 // Location of last mouse event, in screen coordinates. 149 // Location of last mouse event, in screen coordinates.
148 gfx::Point last_mouse_location_; 150 gfx::Point last_mouse_location_;
149 bool is_touch_down_; 151 bool is_touch_down_;
152 bool get_last_mouse_location_from_mus_;
153 // This may be set to true in tests to force using |last_mouse_location_|
154 // rather than querying WindowTreeClient.
155 bool always_use_last_mouse_location_ = false;
150 156
151 std::unique_ptr<InputStateLookup> input_state_lookup_; 157 std::unique_ptr<InputStateLookup> input_state_lookup_;
152 std::unique_ptr<ui::PlatformEventSource> event_source_; 158 std::unique_ptr<ui::PlatformEventSource> event_source_;
153 159
154 ui::ContextFactory* context_factory_; 160 ui::ContextFactory* context_factory_;
155 ui::ContextFactoryPrivate* context_factory_private_; 161 ui::ContextFactoryPrivate* context_factory_private_;
156 162
157 Window* active_focus_client_root_ = nullptr; 163 Window* active_focus_client_root_ = nullptr;
158 client::FocusClient* active_focus_client_ = nullptr; 164 client::FocusClient* active_focus_client_ = nullptr;
159 std::unique_ptr<ActiveFocusClientWindowObserver> 165 std::unique_ptr<ActiveFocusClientWindowObserver>
160 active_focus_client_window_observer_; 166 active_focus_client_window_observer_;
161 167
162 DISALLOW_COPY_AND_ASSIGN(Env); 168 DISALLOW_COPY_AND_ASSIGN(Env);
163 }; 169 };
164 170
165 } // namespace aura 171 } // namespace aura
166 172
167 #endif // UI_AURA_ENV_H_ 173 #endif // UI_AURA_ENV_H_
OLDNEW
« no previous file with comments | « ui/aura/BUILD.gn ('k') | ui/aura/env.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698