Chromium Code Reviews| 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 "ui/aura/client/screen_position_client.h" | 8 #include "ui/aura/client/screen_position_client.h" |
| 9 #include "ui/aura/env_observer.h" | 9 #include "ui/aura/env_observer.h" |
| 10 #include "ui/aura/event_filter.h" | 10 #include "ui/aura/event_filter.h" |
| 11 #include "ui/aura/display_manager.h" | 11 #include "ui/aura/display_manager.h" |
| 12 #include "ui/aura/root_window_host.h" | 12 #include "ui/aura/root_window_host.h" |
| 13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 14 #include "ui/compositor/compositor.h" | 14 #include "ui/compositor/compositor.h" |
| 15 #include "ui/compositor/compositor_switches.h" | 15 #include "ui/compositor/compositor_switches.h" |
| 16 | 16 |
| 17 #if defined(USE_X11) | 17 #if defined(USE_X11) |
| 18 #include "base/message_pump_aurax11.h" | |
| 18 #include "ui/aura/display_change_observer_x11.h" | 19 #include "ui/aura/display_change_observer_x11.h" |
| 19 #endif | 20 #endif |
| 20 | 21 |
| 21 namespace aura { | 22 namespace aura { |
| 22 | 23 |
| 23 // static | 24 // static |
| 24 Env* Env::instance_ = NULL; | 25 Env* Env::instance_ = NULL; |
| 25 | 26 |
| 26 //////////////////////////////////////////////////////////////////////////////// | 27 //////////////////////////////////////////////////////////////////////////////// |
| 27 // Env, public: | 28 // Env, public: |
| 28 | 29 |
| 29 Env::Env() | 30 Env::Env() |
| 30 : mouse_button_flags_(0), | 31 : mouse_button_flags_(0), |
| 31 is_cursor_hidden_(false), | 32 is_cursor_hidden_(false), |
| 32 is_touch_down_(false), | 33 is_touch_down_(false), |
| 33 render_white_bg_(true), | 34 render_white_bg_(true), |
| 34 stacking_client_(NULL) { | 35 stacking_client_(NULL) { |
| 35 } | 36 } |
| 36 | 37 |
| 37 Env::~Env() { | 38 Env::~Env() { |
| 39 #if defined(USE_X11) | |
| 40 base::MessagePumpAuraX11::Current()->RemoveObserver( | |
| 41 &device_list_updater_aurax11_); | |
| 42 #endif | |
| 43 | |
| 38 ui::Compositor::Terminate(); | 44 ui::Compositor::Terminate(); |
| 39 } | 45 } |
| 40 | 46 |
| 41 // static | 47 // static |
| 42 Env* Env::GetInstance() { | 48 Env* Env::GetInstance() { |
| 43 if (!instance_) { | 49 if (!instance_) { |
| 44 instance_ = new Env; | 50 instance_ = new Env; |
| 45 instance_->Init(); | 51 instance_->Init(); |
| 46 } | 52 } |
| 47 return instance_; | 53 return instance_; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 display_change_observer_->NotifyDisplayChange(); | 96 display_change_observer_->NotifyDisplayChange(); |
| 91 #endif | 97 #endif |
| 92 } | 98 } |
| 93 | 99 |
| 94 void Env::SetEventFilter(EventFilter* event_filter) { | 100 void Env::SetEventFilter(EventFilter* event_filter) { |
| 95 event_filter_.reset(event_filter); | 101 event_filter_.reset(event_filter); |
| 96 } | 102 } |
| 97 | 103 |
| 98 #if !defined(OS_MACOSX) | 104 #if !defined(OS_MACOSX) |
| 99 MessageLoop::Dispatcher* Env::GetDispatcher() { | 105 MessageLoop::Dispatcher* Env::GetDispatcher() { |
| 106 #if defined(USE_X11) | |
| 107 return base::MessagePumpAuraX11::Current(); | |
| 108 #else | |
| 100 return dispatcher_.get(); | 109 return dispatcher_.get(); |
| 110 #endif | |
| 101 } | 111 } |
| 102 #endif | 112 #endif |
| 103 | 113 |
| 104 //////////////////////////////////////////////////////////////////////////////// | 114 //////////////////////////////////////////////////////////////////////////////// |
| 105 // Env, private: | 115 // Env, private: |
| 106 | 116 |
| 107 void Env::Init() { | 117 void Env::Init() { |
| 108 #if !defined(OS_MACOSX) | 118 #if defined(OS_WIN) |
| 109 dispatcher_.reset(CreateDispatcher()); | 119 dispatcher_.reset(CreateDispatcher()); |
| 110 #endif | 120 #endif |
| 111 #if defined(USE_X11) | 121 #if defined(USE_X11) |
| 112 display_change_observer_.reset(new internal::DisplayChangeObserverX11); | 122 display_change_observer_.reset(new internal::DisplayChangeObserverX11); |
| 123 base::MessagePumpAuraX11::Current()->AddObserver( | |
|
sadrul
2012/08/29 16:01:25
Perhaps add a note here that adding the device-lis
| |
| 124 &device_list_updater_aurax11_); | |
| 113 #endif | 125 #endif |
| 114 ui::Compositor::Initialize( | 126 ui::Compositor::Initialize( |
| 115 CommandLine::ForCurrentProcess()->HasSwitch( | 127 CommandLine::ForCurrentProcess()->HasSwitch( |
| 116 switches::kUIEnableThreadedCompositing)); | 128 switches::kUIEnableThreadedCompositing)); |
| 117 } | 129 } |
| 118 | 130 |
| 119 void Env::NotifyWindowInitialized(Window* window) { | 131 void Env::NotifyWindowInitialized(Window* window) { |
| 120 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWindowInitialized(window)); | 132 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWindowInitialized(window)); |
| 121 } | 133 } |
| 122 | 134 |
| 123 } // namespace aura | 135 } // namespace aura |
| OLD | NEW |