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" | |
9 #include "ui/aura/env_observer.h" | 8 #include "ui/aura/env_observer.h" |
10 #include "ui/aura/root_window_host.h" | 9 #include "ui/aura/root_window_host.h" |
11 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
12 #include "ui/compositor/compositor.h" | 11 #include "ui/compositor/compositor.h" |
13 #include "ui/compositor/compositor_switches.h" | 12 #include "ui/compositor/compositor_switches.h" |
14 | 13 |
15 #if defined(USE_X11) | 14 #if defined(USE_X11) |
16 #include "base/message_pump_aurax11.h" | 15 #include "base/message_pump_aurax11.h" |
17 #endif | 16 #endif |
18 | 17 |
19 namespace aura { | 18 namespace aura { |
20 | 19 |
21 // static | 20 // static |
22 Env* Env::instance_ = NULL; | 21 Env* Env::instance_ = NULL; |
23 | 22 |
24 //////////////////////////////////////////////////////////////////////////////// | 23 //////////////////////////////////////////////////////////////////////////////// |
25 // Env, public: | 24 // Env, public: |
26 | 25 |
27 Env::Env() | 26 Env::Env() |
28 : mouse_button_flags_(0), | 27 : mouse_button_flags_(0), |
29 is_cursor_hidden_(false), | |
30 is_touch_down_(false), | 28 is_touch_down_(false), |
31 render_white_bg_(true), | 29 render_white_bg_(true), |
32 stacking_client_(NULL) { | 30 stacking_client_(NULL) { |
33 } | 31 } |
34 | 32 |
35 Env::~Env() { | 33 Env::~Env() { |
36 #if defined(USE_X11) | 34 #if defined(USE_X11) |
37 base::MessagePumpAuraX11::Current()->RemoveObserver( | 35 base::MessagePumpAuraX11::Current()->RemoveObserver( |
38 &device_list_updater_aurax11_); | 36 &device_list_updater_aurax11_); |
39 #endif | 37 #endif |
(...skipping 17 matching lines...) Expand all Loading... |
57 } | 55 } |
58 | 56 |
59 void Env::AddObserver(EnvObserver* observer) { | 57 void Env::AddObserver(EnvObserver* observer) { |
60 observers_.AddObserver(observer); | 58 observers_.AddObserver(observer); |
61 } | 59 } |
62 | 60 |
63 void Env::RemoveObserver(EnvObserver* observer) { | 61 void Env::RemoveObserver(EnvObserver* observer) { |
64 observers_.RemoveObserver(observer); | 62 observers_.RemoveObserver(observer); |
65 } | 63 } |
66 | 64 |
67 void Env::SetLastMouseLocation(const Window& window, | |
68 const gfx::Point& location_in_root) { | |
69 last_mouse_location_ = location_in_root; | |
70 client::ScreenPositionClient* client = | |
71 client::GetScreenPositionClient(window.GetRootWindow()); | |
72 if (client) | |
73 client->ConvertPointToScreen(&window, &last_mouse_location_); | |
74 } | |
75 | |
76 void Env::SetCursorShown(bool cursor_shown) { | |
77 if (cursor_shown) { | |
78 // Protect against restoring a position that hadn't been saved. | |
79 if (is_cursor_hidden_) | |
80 last_mouse_location_ = hidden_cursor_location_; | |
81 is_cursor_hidden_ = false; | |
82 } else { | |
83 hidden_cursor_location_ = last_mouse_location_; | |
84 last_mouse_location_ = gfx::Point(-10000, -10000); | |
85 is_cursor_hidden_ = true; | |
86 } | |
87 } | |
88 | |
89 #if !defined(OS_MACOSX) | 65 #if !defined(OS_MACOSX) |
90 MessageLoop::Dispatcher* Env::GetDispatcher() { | 66 MessageLoop::Dispatcher* Env::GetDispatcher() { |
91 #if defined(USE_X11) | 67 #if defined(USE_X11) |
92 return base::MessagePumpAuraX11::Current(); | 68 return base::MessagePumpAuraX11::Current(); |
93 #else | 69 #else |
94 return dispatcher_.get(); | 70 return dispatcher_.get(); |
95 #endif | 71 #endif |
96 } | 72 } |
97 #endif | 73 #endif |
98 | 74 |
(...skipping 29 matching lines...) Expand all Loading... |
128 | 104 |
129 bool Env::CanAcceptEvent(const ui::Event& event) { | 105 bool Env::CanAcceptEvent(const ui::Event& event) { |
130 return true; | 106 return true; |
131 } | 107 } |
132 | 108 |
133 ui::EventTarget* Env::GetParentTarget() { | 109 ui::EventTarget* Env::GetParentTarget() { |
134 return NULL; | 110 return NULL; |
135 } | 111 } |
136 | 112 |
137 } // namespace aura | 113 } // namespace aura |
OLD | NEW |