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" | |
12 #include "ui/aura/root_window_host.h" | 11 #include "ui/aura/root_window_host.h" |
13 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
14 #include "ui/compositor/compositor.h" | 13 #include "ui/compositor/compositor.h" |
15 #include "ui/compositor/compositor_switches.h" | 14 #include "ui/compositor/compositor_switches.h" |
16 | 15 |
17 #if defined(USE_X11) | 16 #if defined(USE_X11) |
18 #include "base/message_pump_aurax11.h" | 17 #include "base/message_pump_aurax11.h" |
19 #include "ui/aura/display_change_observer_x11.h" | |
20 #endif | 18 #endif |
21 | 19 |
22 namespace aura { | 20 namespace aura { |
23 | 21 |
24 // static | 22 // static |
25 Env* Env::instance_ = NULL; | 23 Env* Env::instance_ = NULL; |
26 | 24 |
27 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
28 // Env, public: | 26 // Env, public: |
29 | 27 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 if (is_cursor_hidden_) | 80 if (is_cursor_hidden_) |
83 last_mouse_location_ = hidden_cursor_location_; | 81 last_mouse_location_ = hidden_cursor_location_; |
84 is_cursor_hidden_ = false; | 82 is_cursor_hidden_ = false; |
85 } else { | 83 } else { |
86 hidden_cursor_location_ = last_mouse_location_; | 84 hidden_cursor_location_ = last_mouse_location_; |
87 last_mouse_location_ = gfx::Point(-10000, -10000); | 85 last_mouse_location_ = gfx::Point(-10000, -10000); |
88 is_cursor_hidden_ = true; | 86 is_cursor_hidden_ = true; |
89 } | 87 } |
90 } | 88 } |
91 | 89 |
92 void Env::SetDisplayManager(DisplayManager* display_manager) { | |
93 display_manager_.reset(display_manager); | |
94 #if defined(USE_X11) | |
95 // Update the display manager with latest info. | |
96 display_change_observer_->NotifyDisplayChange(); | |
97 #endif | |
98 } | |
99 | |
100 #if !defined(OS_MACOSX) | 90 #if !defined(OS_MACOSX) |
101 MessageLoop::Dispatcher* Env::GetDispatcher() { | 91 MessageLoop::Dispatcher* Env::GetDispatcher() { |
102 #if defined(USE_X11) | 92 #if defined(USE_X11) |
103 return base::MessagePumpAuraX11::Current(); | 93 return base::MessagePumpAuraX11::Current(); |
104 #else | 94 #else |
105 return dispatcher_.get(); | 95 return dispatcher_.get(); |
106 #endif | 96 #endif |
107 } | 97 } |
108 #endif | 98 #endif |
109 | 99 |
110 //////////////////////////////////////////////////////////////////////////////// | 100 //////////////////////////////////////////////////////////////////////////////// |
111 // Env, private: | 101 // Env, private: |
112 | 102 |
113 void Env::Init() { | 103 void Env::Init() { |
114 #if !defined(USE_X11) | 104 #if !defined(USE_X11) |
115 dispatcher_.reset(CreateDispatcher()); | 105 dispatcher_.reset(CreateDispatcher()); |
116 #endif | 106 #endif |
117 #if defined(USE_X11) | 107 #if defined(USE_X11) |
118 display_change_observer_.reset(new internal::DisplayChangeObserverX11); | |
119 | |
120 // We can't do this with a root window listener because XI_HierarchyChanged | 108 // We can't do this with a root window listener because XI_HierarchyChanged |
121 // messages don't have a target window. | 109 // messages don't have a target window. |
122 base::MessagePumpAuraX11::Current()->AddObserver( | 110 base::MessagePumpAuraX11::Current()->AddObserver( |
123 &device_list_updater_aurax11_); | 111 &device_list_updater_aurax11_); |
124 #endif | 112 #endif |
125 ui::Compositor::Initialize( | 113 ui::Compositor::Initialize( |
126 CommandLine::ForCurrentProcess()->HasSwitch( | 114 CommandLine::ForCurrentProcess()->HasSwitch( |
127 switches::kUIEnableThreadedCompositing)); | 115 switches::kUIEnableThreadedCompositing)); |
128 } | 116 } |
129 | 117 |
130 void Env::NotifyWindowInitialized(Window* window) { | 118 void Env::NotifyWindowInitialized(Window* window) { |
131 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWindowInitialized(window)); | 119 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWindowInitialized(window)); |
132 } | 120 } |
133 | 121 |
134 //////////////////////////////////////////////////////////////////////////////// | 122 //////////////////////////////////////////////////////////////////////////////// |
135 // Env, ui::EventTarget implementation: | 123 // Env, ui::EventTarget implementation: |
136 | 124 |
137 bool Env::CanAcceptEvents() { | 125 bool Env::CanAcceptEvents() { |
138 return true; | 126 return true; |
139 } | 127 } |
140 | 128 |
141 ui::EventTarget* Env::GetParentTarget() { | 129 ui::EventTarget* Env::GetParentTarget() { |
142 return NULL; | 130 return NULL; |
143 } | 131 } |
144 | 132 |
145 } // namespace aura | 133 } // namespace aura |
OLD | NEW |