| 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 "ui/aura/env_observer.h" | 7 #include "ui/aura/env_observer.h" |
| 8 #include "ui/aura/input_state_lookup.h" | 8 #include "ui/aura/input_state_lookup.h" |
| 9 #include "ui/compositor/compositor.h" | |
| 10 #include "ui/events/event_target_iterator.h" | 9 #include "ui/events/event_target_iterator.h" |
| 11 #include "ui/events/platform/platform_event_source.h" | 10 #include "ui/events/platform/platform_event_source.h" |
| 12 | 11 |
| 13 namespace aura { | 12 namespace aura { |
| 14 | 13 |
| 15 // static | 14 // static |
| 16 Env* Env::instance_ = NULL; | 15 Env* Env::instance_ = NULL; |
| 17 | 16 |
| 18 //////////////////////////////////////////////////////////////////////////////// | 17 //////////////////////////////////////////////////////////////////////////////// |
| 19 // Env, public: | 18 // Env, public: |
| 20 | 19 |
| 21 Env::Env() | 20 Env::Env() |
| 22 : mouse_button_flags_(0), | 21 : mouse_button_flags_(0), |
| 23 is_touch_down_(false), | 22 is_touch_down_(false), |
| 24 input_state_lookup_(InputStateLookup::Create().Pass()) { | 23 input_state_lookup_(InputStateLookup::Create().Pass()) { |
| 25 } | 24 } |
| 26 | 25 |
| 27 Env::~Env() { | 26 Env::~Env() { |
| 28 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWillDestroyEnv()); | 27 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWillDestroyEnv()); |
| 29 | |
| 30 ui::Compositor::Terminate(); | |
| 31 } | 28 } |
| 32 | 29 |
| 33 //static | 30 //static |
| 34 void Env::CreateInstance(bool create_event_source) { | 31 void Env::CreateInstance(bool create_event_source) { |
| 35 if (!instance_) { | 32 if (!instance_) { |
| 36 instance_ = new Env; | 33 instance_ = new Env; |
| 37 instance_->Init(create_event_source); | 34 instance_->Init(create_event_source); |
| 38 } | 35 } |
| 39 } | 36 } |
| 40 | 37 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 61 | 58 |
| 62 bool Env::IsMouseButtonDown() const { | 59 bool Env::IsMouseButtonDown() const { |
| 63 return input_state_lookup_.get() ? input_state_lookup_->IsMouseButtonDown() : | 60 return input_state_lookup_.get() ? input_state_lookup_->IsMouseButtonDown() : |
| 64 mouse_button_flags_ != 0; | 61 mouse_button_flags_ != 0; |
| 65 } | 62 } |
| 66 | 63 |
| 67 //////////////////////////////////////////////////////////////////////////////// | 64 //////////////////////////////////////////////////////////////////////////////// |
| 68 // Env, private: | 65 // Env, private: |
| 69 | 66 |
| 70 void Env::Init(bool create_event_source) { | 67 void Env::Init(bool create_event_source) { |
| 71 ui::Compositor::Initialize(); | |
| 72 | |
| 73 if (create_event_source && !ui::PlatformEventSource::GetInstance()) | 68 if (create_event_source && !ui::PlatformEventSource::GetInstance()) |
| 74 event_source_ = ui::PlatformEventSource::CreateDefault(); | 69 event_source_ = ui::PlatformEventSource::CreateDefault(); |
| 75 } | 70 } |
| 76 | 71 |
| 77 void Env::NotifyWindowInitialized(Window* window) { | 72 void Env::NotifyWindowInitialized(Window* window) { |
| 78 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWindowInitialized(window)); | 73 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWindowInitialized(window)); |
| 79 } | 74 } |
| 80 | 75 |
| 81 void Env::NotifyHostInitialized(WindowTreeHost* host) { | 76 void Env::NotifyHostInitialized(WindowTreeHost* host) { |
| 82 FOR_EACH_OBSERVER(EnvObserver, observers_, OnHostInitialized(host)); | 77 FOR_EACH_OBSERVER(EnvObserver, observers_, OnHostInitialized(host)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 100 scoped_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { | 95 scoped_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { |
| 101 return scoped_ptr<ui::EventTargetIterator>(); | 96 return scoped_ptr<ui::EventTargetIterator>(); |
| 102 } | 97 } |
| 103 | 98 |
| 104 ui::EventTargeter* Env::GetEventTargeter() { | 99 ui::EventTargeter* Env::GetEventTargeter() { |
| 105 NOTREACHED(); | 100 NOTREACHED(); |
| 106 return NULL; | 101 return NULL; |
| 107 } | 102 } |
| 108 | 103 |
| 109 } // namespace aura | 104 } // namespace aura |
| OLD | NEW |