| OLD | NEW |
| 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 Loading... |
| 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() const { |
| 127 if (mode_ == Mode::LOCAL || always_use_last_mouse_location_ || |
| 128 !get_last_mouse_location_from_mus_) { |
| 129 return last_mouse_location_; |
| 130 } |
| 131 |
| 132 // Some tests may not install a WindowTreeClient, and we allow multiple |
| 133 // WindowTreeClients for the case of multiple connections. |
| 134 if (window_tree_client_) |
| 135 last_mouse_location_ = window_tree_client_->GetCursorScreenPoint(); |
| 136 return last_mouse_location_; |
| 137 } |
| 138 |
| 126 void Env::SetWindowTreeClient(WindowTreeClient* window_tree_client) { | 139 void Env::SetWindowTreeClient(WindowTreeClient* window_tree_client) { |
| 127 // The WindowTreeClient should only be set once. Test code may need to change | 140 // The WindowTreeClient should only be set once. Test code may need to change |
| 128 // the value after the fact, to do that use EnvTestHelper. | 141 // the value after the fact, to do that use EnvTestHelper. |
| 129 DCHECK(!window_tree_client_); | 142 DCHECK(!window_tree_client_); |
| 130 window_tree_client_ = window_tree_client; | 143 window_tree_client_ = window_tree_client; |
| 131 } | 144 } |
| 132 | 145 |
| 133 void Env::SetActiveFocusClient(client::FocusClient* focus_client, | 146 void Env::SetActiveFocusClient(client::FocusClient* focus_client, |
| 134 Window* focus_client_root) { | 147 Window* focus_client_root) { |
| 135 if (focus_client == active_focus_client_ && | 148 if (focus_client == active_focus_client_ && |
| (...skipping 12 matching lines...) Expand all Loading... |
| 148 observer.OnActiveFocusClientChanged(focus_client, focus_client_root); | 161 observer.OnActiveFocusClientChanged(focus_client, focus_client_root); |
| 149 } | 162 } |
| 150 | 163 |
| 151 //////////////////////////////////////////////////////////////////////////////// | 164 //////////////////////////////////////////////////////////////////////////////// |
| 152 // Env, private: | 165 // Env, private: |
| 153 | 166 |
| 154 Env::Env(Mode mode) | 167 Env::Env(Mode mode) |
| 155 : mode_(mode), | 168 : mode_(mode), |
| 156 mouse_button_flags_(0), | 169 mouse_button_flags_(0), |
| 157 is_touch_down_(false), | 170 is_touch_down_(false), |
| 171 get_last_mouse_location_from_mus_(mode_ == Mode::MUS), |
| 158 input_state_lookup_(InputStateLookup::Create()), | 172 input_state_lookup_(InputStateLookup::Create()), |
| 159 context_factory_(nullptr), | 173 context_factory_(nullptr), |
| 160 context_factory_private_(nullptr) { | 174 context_factory_private_(nullptr) { |
| 161 DCHECK(lazy_tls_ptr.Pointer()->Get() == NULL); | 175 DCHECK(lazy_tls_ptr.Pointer()->Get() == NULL); |
| 162 lazy_tls_ptr.Pointer()->Set(this); | 176 lazy_tls_ptr.Pointer()->Set(this); |
| 163 } | 177 } |
| 164 | 178 |
| 165 void Env::Init() { | 179 void Env::Init() { |
| 166 if (RunningInsideMus()) | 180 if (RunningInsideMus()) |
| 167 return; | 181 return; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 std::unique_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { | 222 std::unique_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { |
| 209 return nullptr; | 223 return nullptr; |
| 210 } | 224 } |
| 211 | 225 |
| 212 ui::EventTargeter* Env::GetEventTargeter() { | 226 ui::EventTargeter* Env::GetEventTargeter() { |
| 213 NOTREACHED(); | 227 NOTREACHED(); |
| 214 return NULL; | 228 return NULL; |
| 215 } | 229 } |
| 216 | 230 |
| 217 } // namespace aura | 231 } // namespace aura |
| OLD | NEW |