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/root_window.h" | 5 #include "ui/aura/root_window.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 #include "ui/base/gestures/gesture_recognizer.h" | 26 #include "ui/base/gestures/gesture_recognizer.h" |
27 #include "ui/base/gestures/gesture_types.h" | 27 #include "ui/base/gestures/gesture_types.h" |
28 #include "ui/base/hit_test.h" | 28 #include "ui/base/hit_test.h" |
29 #include "ui/compositor/compositor.h" | 29 #include "ui/compositor/compositor.h" |
30 #include "ui/compositor/dip_util.h" | 30 #include "ui/compositor/dip_util.h" |
31 #include "ui/compositor/layer.h" | 31 #include "ui/compositor/layer.h" |
32 #include "ui/compositor/layer_animator.h" | 32 #include "ui/compositor/layer_animator.h" |
33 #include "ui/gfx/monitor.h" | 33 #include "ui/gfx/monitor.h" |
34 #include "ui/gfx/screen.h" | 34 #include "ui/gfx/screen.h" |
35 | 35 |
36 #include "ui/compositor/layer_type.h" | |
37 | |
36 using std::vector; | 38 using std::vector; |
37 | 39 |
38 namespace aura { | 40 namespace aura { |
39 | 41 |
40 namespace { | 42 namespace { |
41 | 43 |
42 // These are the mouse events generated when a gesture goes unprocessed. | 44 // These are the mouse events generated when a gesture goes unprocessed. |
43 const ui::EventType kScrollBeginTypes[] = { | 45 const ui::EventType kScrollBeginTypes[] = { |
44 ui::ET_MOUSE_PRESSED, ui::ET_MOUSE_DRAGGED, ui::ET_UNKNOWN }; | 46 ui::ET_MOUSE_PRESSED, ui::ET_MOUSE_DRAGGED, ui::ET_UNKNOWN }; |
45 | 47 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 mouse_moved_handler_(NULL), | 124 mouse_moved_handler_(NULL), |
123 focused_window_(NULL), | 125 focused_window_(NULL), |
124 ALLOW_THIS_IN_INITIALIZER_LIST( | 126 ALLOW_THIS_IN_INITIALIZER_LIST( |
125 gesture_recognizer_(ui::GestureRecognizer::Create(this))), | 127 gesture_recognizer_(ui::GestureRecognizer::Create(this))), |
126 synthesize_mouse_move_(false), | 128 synthesize_mouse_move_(false), |
127 waiting_on_compositing_end_(false), | 129 waiting_on_compositing_end_(false), |
128 draw_on_compositing_end_(false), | 130 draw_on_compositing_end_(false), |
129 defer_draw_scheduling_(false), | 131 defer_draw_scheduling_(false), |
130 mouse_move_hold_count_(0), | 132 mouse_move_hold_count_(0), |
131 should_hold_mouse_moves_(false), | 133 should_hold_mouse_moves_(false), |
134 force_hide_cursor_(false), | |
132 compositor_lock_(NULL), | 135 compositor_lock_(NULL), |
133 draw_on_compositor_unlock_(false), | 136 draw_on_compositor_unlock_(false), |
134 draw_trace_count_(0) { | 137 draw_trace_count_(0) { |
135 SetName("RootWindow"); | 138 SetName("RootWindow"); |
136 should_hold_mouse_moves_ = !CommandLine::ForCurrentProcess()->HasSwitch( | 139 should_hold_mouse_moves_ = !CommandLine::ForCurrentProcess()->HasSwitch( |
137 switches::kAuraDisableHoldMouseMoves); | 140 switches::kAuraDisableHoldMouseMoves); |
138 | 141 |
139 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget())); | 142 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget())); |
140 DCHECK(compositor_.get()); | 143 DCHECK(compositor_.get()); |
141 compositor_->AddObserver(this); | 144 compositor_->AddObserver(this); |
(...skipping 17 matching lines...) Expand all Loading... | |
159 // An observer may have been added by an animation on the RootWindow. | 162 // An observer may have been added by an animation on the RootWindow. |
160 layer()->GetAnimator()->RemoveObserver(this); | 163 layer()->GetAnimator()->RemoveObserver(this); |
161 } | 164 } |
162 | 165 |
163 void RootWindow::Init() { | 166 void RootWindow::Init() { |
164 compositor()->SetScaleAndSize(GetDeviceScaleFactorFromMonitor(this), | 167 compositor()->SetScaleAndSize(GetDeviceScaleFactorFromMonitor(this), |
165 host_->GetBounds().size()); | 168 host_->GetBounds().size()); |
166 Window::Init(ui::LAYER_NOT_DRAWN); | 169 Window::Init(ui::LAYER_NOT_DRAWN); |
167 last_mouse_location_ = | 170 last_mouse_location_ = |
168 ui::ConvertPointToDIP(layer(), host_->QueryMouseLocation()); | 171 ui::ConvertPointToDIP(layer(), host_->QueryMouseLocation()); |
169 compositor()->SetRootLayer(layer()); | 172 |
173 magnification_layer_.reset(new ui::Layer(ui::LAYER_TEXTURED)); | |
piman
2012/05/18 03:09:49
Does this need to be LAYER_TEXTURED? Since it has
| |
174 magnification_layer_->SetVisible(false); | |
175 magnification_layer_->SetFillsBoundsOpaquely(true); | |
176 magnification_layer_->Add(layer()); | |
177 magnification_layer_->SetVisible(true); | |
piman
2012/05/18 03:09:49
Is this layer needed at all? If it's just there to
| |
178 | |
179 compositor()->SetRootLayer(magnification_layer_.get()); | |
180 | |
170 SetBounds( | 181 SetBounds( |
171 ui::ConvertRectToDIP(layer(), gfx::Rect(host_->GetBounds().size()))); | 182 ui::ConvertRectToDIP(layer(), gfx::Rect(host_->GetBounds().size()))); |
172 Show(); | 183 Show(); |
173 host_->SetRootWindow(this); | 184 host_->SetRootWindow(this); |
174 } | 185 } |
175 | 186 |
176 void RootWindow::ShowRootWindow() { | 187 void RootWindow::ShowRootWindow() { |
177 host_->Show(); | 188 host_->Show(); |
178 } | 189 } |
179 | 190 |
(...skipping 25 matching lines...) Expand all Loading... | |
205 return host_->GetBounds().origin(); | 216 return host_->GetBounds().origin(); |
206 } | 217 } |
207 | 218 |
208 void RootWindow::SetCursor(gfx::NativeCursor cursor) { | 219 void RootWindow::SetCursor(gfx::NativeCursor cursor) { |
209 last_cursor_ = cursor; | 220 last_cursor_ = cursor; |
210 // A lot of code seems to depend on NULL cursors actually showing an arrow, | 221 // A lot of code seems to depend on NULL cursors actually showing an arrow, |
211 // so just pass everything along to the host. | 222 // so just pass everything along to the host. |
212 host_->SetCursor(cursor); | 223 host_->SetCursor(cursor); |
213 } | 224 } |
214 | 225 |
226 void RootWindow::SetForceHideCursor(bool hide) { | |
227 force_hide_cursor_ = hide; | |
228 ShowCursor(!hide); | |
piman
2012/05/18 03:09:49
This makes SetForceHideCursor and ShowCursor non-o
| |
229 } | |
230 | |
215 void RootWindow::ShowCursor(bool show) { | 231 void RootWindow::ShowCursor(bool show) { |
232 if (force_hide_cursor_ && show) | |
233 show = false; | |
234 | |
216 cursor_shown_ = show; | 235 cursor_shown_ = show; |
217 host_->ShowCursor(show); | 236 host_->ShowCursor(show); |
218 } | 237 } |
219 | 238 |
220 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { | 239 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { |
221 host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location_in_dip)); | 240 host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location_in_dip)); |
222 } | 241 } |
223 | 242 |
224 bool RootWindow::ConfineCursorToWindow() { | 243 bool RootWindow::ConfineCursorToWindow() { |
225 // We would like to be able to confine the cursor to that window. However, | 244 // We would like to be able to confine the cursor to that window. However, |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 if (IsNonClientLocation(target, location_in_window)) | 323 if (IsNonClientLocation(target, location_in_window)) |
305 flags |= ui::EF_IS_NON_CLIENT; | 324 flags |= ui::EF_IS_NON_CLIENT; |
306 ScrollEvent translated_event(*event, this, target, event->type(), flags); | 325 ScrollEvent translated_event(*event, this, target, event->type(), flags); |
307 return ProcessMouseEvent(target, &translated_event); | 326 return ProcessMouseEvent(target, &translated_event); |
308 } | 327 } |
309 return false; | 328 return false; |
310 } | 329 } |
311 | 330 |
312 bool RootWindow::DispatchTouchEvent(TouchEvent* event) { | 331 bool RootWindow::DispatchTouchEvent(TouchEvent* event) { |
313 DispatchHeldMouseMove(); | 332 DispatchHeldMouseMove(); |
333 | |
334 // Touch event should be transformed by magnifition transform matrix. | |
335 event->UpdateForRootTransform(magnification_layer()->transform()); | |
336 | |
314 if (ui::IsDIPEnabled()) { | 337 if (ui::IsDIPEnabled()) { |
315 float scale = ui::GetDeviceScaleFactor(layer()); | 338 float scale = ui::GetDeviceScaleFactor(layer()); |
316 ui::Transform transform = layer()->transform(); | 339 ui::Transform transform = layer()->transform(); |
317 transform.ConcatScale(scale, scale); | 340 transform.ConcatScale(scale, scale); |
318 event->UpdateForRootTransform(transform); | 341 event->UpdateForRootTransform(transform); |
319 } else { | 342 } else { |
320 event->UpdateForRootTransform(layer()->transform()); | 343 event->UpdateForRootTransform(layer()->transform()); |
321 } | 344 } |
322 bool handled = false; | 345 bool handled = false; |
323 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN; | 346 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN; |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1029 void RootWindow::UnlockCompositor() { | 1052 void RootWindow::UnlockCompositor() { |
1030 DCHECK(compositor_lock_); | 1053 DCHECK(compositor_lock_); |
1031 compositor_lock_ = NULL; | 1054 compositor_lock_ = NULL; |
1032 if (draw_on_compositor_unlock_) { | 1055 if (draw_on_compositor_unlock_) { |
1033 draw_on_compositor_unlock_ = false; | 1056 draw_on_compositor_unlock_ = false; |
1034 ScheduleDraw(); | 1057 ScheduleDraw(); |
1035 } | 1058 } |
1036 } | 1059 } |
1037 | 1060 |
1038 } // namespace aura | 1061 } // namespace aura |
OLD | NEW |