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

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

Issue 2657283003: mash: make Env::last_mouse_location() accurate for Mus (Closed)
Patch Set: cleanup 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
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 #include "ui/aura/env.h" 5 #include "ui/aura/env.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/threading/thread_local.h" 10 #include "base/threading/thread_local.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 void Env::RemoveObserver(EnvObserver* observer) { 117 void Env::RemoveObserver(EnvObserver* observer) {
118 observers_.RemoveObserver(observer); 118 observers_.RemoveObserver(observer);
119 } 119 }
120 120
121 bool Env::IsMouseButtonDown() const { 121 bool Env::IsMouseButtonDown() const {
122 return input_state_lookup_.get() ? input_state_lookup_->IsMouseButtonDown() : 122 return input_state_lookup_.get() ? input_state_lookup_->IsMouseButtonDown() :
123 mouse_button_flags_ != 0; 123 mouse_button_flags_ != 0;
124 } 124 }
125 125
126 const gfx::Point& Env::last_mouse_location() {
127 if (mode_ == Mode::LOCAL || !get_last_mouse_location_from_mus_)
128 return last_mouse_location_;
129
130 DCHECK(window_tree_client_);
131 last_mouse_location_ = window_tree_client_->GetCursorScreenPoint();
132 return last_mouse_location_;
133 }
134
126 void Env::SetWindowTreeClient(WindowTreeClient* window_tree_client) { 135 void Env::SetWindowTreeClient(WindowTreeClient* window_tree_client) {
127 // The WindowTreeClient should only be set once. Test code may need to change 136 // The WindowTreeClient should only be set once. Test code may need to change
128 // the value after the fact, to do that use EnvTestHelper. 137 // the value after the fact, to do that use EnvTestHelper.
129 DCHECK(!window_tree_client_); 138 DCHECK(!window_tree_client_);
130 window_tree_client_ = window_tree_client; 139 window_tree_client_ = window_tree_client;
131 } 140 }
132 141
133 void Env::SetActiveFocusClient(client::FocusClient* focus_client, 142 void Env::SetActiveFocusClient(client::FocusClient* focus_client,
134 Window* focus_client_root) { 143 Window* focus_client_root) {
135 if (focus_client == active_focus_client_ && 144 if (focus_client == active_focus_client_ &&
(...skipping 12 matching lines...) Expand all
148 observer.OnActiveFocusClientChanged(focus_client, focus_client_root); 157 observer.OnActiveFocusClientChanged(focus_client, focus_client_root);
149 } 158 }
150 159
151 //////////////////////////////////////////////////////////////////////////////// 160 ////////////////////////////////////////////////////////////////////////////////
152 // Env, private: 161 // Env, private:
153 162
154 Env::Env(Mode mode) 163 Env::Env(Mode mode)
155 : mode_(mode), 164 : mode_(mode),
156 mouse_button_flags_(0), 165 mouse_button_flags_(0),
157 is_touch_down_(false), 166 is_touch_down_(false),
167 get_last_mouse_location_from_mus_(mode_ == Mode::MUS),
158 input_state_lookup_(InputStateLookup::Create()), 168 input_state_lookup_(InputStateLookup::Create()),
159 context_factory_(nullptr), 169 context_factory_(nullptr),
160 context_factory_private_(nullptr) { 170 context_factory_private_(nullptr) {
161 DCHECK(lazy_tls_ptr.Pointer()->Get() == NULL); 171 DCHECK(lazy_tls_ptr.Pointer()->Get() == NULL);
162 lazy_tls_ptr.Pointer()->Set(this); 172 lazy_tls_ptr.Pointer()->Set(this);
163 } 173 }
164 174
165 void Env::Init() { 175 void Env::Init() {
166 if (RunningInsideMus()) 176 if (RunningInsideMus())
167 return; 177 return;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 std::unique_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { 218 std::unique_ptr<ui::EventTargetIterator> Env::GetChildIterator() const {
209 return nullptr; 219 return nullptr;
210 } 220 }
211 221
212 ui::EventTargeter* Env::GetEventTargeter() { 222 ui::EventTargeter* Env::GetEventTargeter() {
213 NOTREACHED(); 223 NOTREACHED();
214 return NULL; 224 return NULL;
215 } 225 }
216 226
217 } // namespace aura 227 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698