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 const ui::EventType kScrollBeginTypes[] = { | 44 const ui::EventType kScrollBeginTypes[] = { |
43 ui::ET_MOUSE_ENTERED, ui::ET_MOUSE_PRESSED, ui::ET_MOUSE_DRAGGED, | 45 ui::ET_MOUSE_ENTERED, ui::ET_MOUSE_PRESSED, ui::ET_MOUSE_DRAGGED, |
44 ui::ET_UNKNOWN }; | 46 ui::ET_UNKNOWN }; |
45 | 47 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 focused_window_(NULL), | 122 focused_window_(NULL), |
121 ALLOW_THIS_IN_INITIALIZER_LIST( | 123 ALLOW_THIS_IN_INITIALIZER_LIST( |
122 gesture_recognizer_(ui::GestureRecognizer::Create(this))), | 124 gesture_recognizer_(ui::GestureRecognizer::Create(this))), |
123 capture_window_flags_(0), | 125 capture_window_flags_(0), |
124 synthesize_mouse_move_(false), | 126 synthesize_mouse_move_(false), |
125 waiting_on_compositing_end_(false), | 127 waiting_on_compositing_end_(false), |
126 draw_on_compositing_end_(false), | 128 draw_on_compositing_end_(false), |
127 defer_draw_scheduling_(false), | 129 defer_draw_scheduling_(false), |
128 mouse_move_hold_count_(0), | 130 mouse_move_hold_count_(0), |
129 should_hold_mouse_moves_(false), | 131 should_hold_mouse_moves_(false), |
132 force_hide_cursor_(false), | |
130 compositor_lock_(NULL), | 133 compositor_lock_(NULL), |
131 draw_on_compositor_unlock_(false), | 134 draw_on_compositor_unlock_(false), |
132 draw_trace_count_(0) { | 135 draw_trace_count_(0) { |
133 SetName("RootWindow"); | 136 SetName("RootWindow"); |
134 should_hold_mouse_moves_ = !CommandLine::ForCurrentProcess()->HasSwitch( | 137 should_hold_mouse_moves_ = !CommandLine::ForCurrentProcess()->HasSwitch( |
135 switches::kAuraDisableHoldMouseMoves); | 138 switches::kAuraDisableHoldMouseMoves); |
136 | 139 |
137 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget())); | 140 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget())); |
138 DCHECK(compositor_.get()); | 141 DCHECK(compositor_.get()); |
139 compositor_->AddObserver(this); | 142 compositor_->AddObserver(this); |
(...skipping 17 matching lines...) Expand all Loading... | |
157 // An observer may have been added by an animation on the RootWindow. | 160 // An observer may have been added by an animation on the RootWindow. |
158 layer()->GetAnimator()->RemoveObserver(this); | 161 layer()->GetAnimator()->RemoveObserver(this); |
159 } | 162 } |
160 | 163 |
161 void RootWindow::Init() { | 164 void RootWindow::Init() { |
162 compositor()->SetScaleAndSize(GetDeviceScaleFactorFromMonitor(this), | 165 compositor()->SetScaleAndSize(GetDeviceScaleFactorFromMonitor(this), |
163 host_->GetBounds().size()); | 166 host_->GetBounds().size()); |
164 Window::Init(ui::LAYER_NOT_DRAWN); | 167 Window::Init(ui::LAYER_NOT_DRAWN); |
165 last_mouse_location_ = | 168 last_mouse_location_ = |
166 ui::ConvertPointToDIP(layer(), host_->QueryMouseLocation()); | 169 ui::ConvertPointToDIP(layer(), host_->QueryMouseLocation()); |
167 compositor()->SetRootLayer(layer()); | 170 |
171 magnification_layer_.reset(new ui::Layer(ui::LAYER_TEXTURED)); | |
172 magnification_layer_->SetVisible(false); | |
173 magnification_layer_->SetFillsBoundsOpaquely(true); | |
174 magnification_layer_->Add(layer()); | |
175 magnification_layer_->SetVisible(true); | |
176 | |
177 compositor()->SetRootLayer(magnification_layer_.get()); | |
178 | |
168 SetBounds( | 179 SetBounds( |
169 ui::ConvertRectToDIP(layer(), gfx::Rect(host_->GetBounds().size()))); | 180 ui::ConvertRectToDIP(layer(), gfx::Rect(host_->GetBounds().size()))); |
170 Show(); | 181 Show(); |
171 host_->SetRootWindow(this); | 182 host_->SetRootWindow(this); |
172 } | 183 } |
173 | 184 |
174 void RootWindow::ShowRootWindow() { | 185 void RootWindow::ShowRootWindow() { |
175 host_->Show(); | 186 host_->Show(); |
176 } | 187 } |
177 | 188 |
(...skipping 26 matching lines...) Expand all Loading... | |
204 } | 215 } |
205 | 216 |
206 void RootWindow::SetCursor(gfx::NativeCursor cursor) { | 217 void RootWindow::SetCursor(gfx::NativeCursor cursor) { |
207 last_cursor_ = cursor; | 218 last_cursor_ = cursor; |
208 // A lot of code seems to depend on NULL cursors actually showing an arrow, | 219 // A lot of code seems to depend on NULL cursors actually showing an arrow, |
209 // so just pass everything along to the host. | 220 // so just pass everything along to the host. |
210 host_->SetCursor(cursor); | 221 host_->SetCursor(cursor); |
211 } | 222 } |
212 | 223 |
213 void RootWindow::ShowCursor(bool show) { | 224 void RootWindow::ShowCursor(bool show) { |
225 if (force_hide_cursor_ && show) | |
226 show = false; | |
227 | |
214 cursor_shown_ = show; | 228 cursor_shown_ = show; |
215 host_->ShowCursor(show); | 229 host_->ShowCursor(show); |
216 } | 230 } |
217 | 231 |
218 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { | 232 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { |
219 host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location_in_dip)); | 233 host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location_in_dip)); |
220 } | 234 } |
221 | 235 |
222 bool RootWindow::ConfineCursorToWindow() { | 236 bool RootWindow::ConfineCursorToWindow() { |
223 // We would like to be able to confine the cursor to that window. However, | 237 // 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... | |
302 if (IsNonClientLocation(target, location_in_window)) | 316 if (IsNonClientLocation(target, location_in_window)) |
303 flags |= ui::EF_IS_NON_CLIENT; | 317 flags |= ui::EF_IS_NON_CLIENT; |
304 ScrollEvent translated_event(*event, this, target, event->type(), flags); | 318 ScrollEvent translated_event(*event, this, target, event->type(), flags); |
305 return ProcessMouseEvent(target, &translated_event); | 319 return ProcessMouseEvent(target, &translated_event); |
306 } | 320 } |
307 return false; | 321 return false; |
308 } | 322 } |
309 | 323 |
310 bool RootWindow::DispatchTouchEvent(TouchEvent* event) { | 324 bool RootWindow::DispatchTouchEvent(TouchEvent* event) { |
311 DispatchHeldMouseMove(); | 325 DispatchHeldMouseMove(); |
326 | |
327 // Touch event should be transformed by magnifition transform matrix. | |
328 event->UpdateForRootTransform(magnification_layer()->transform()); | |
sky
2012/05/16 15:40:48
Why wouldn't it effect mouse or gesture events?
yoshiki
2012/05/17 17:19:32
This CL magnifies the screen with |magnification_l
| |
329 | |
312 if (ui::IsDIPEnabled()) { | 330 if (ui::IsDIPEnabled()) { |
313 float scale = ui::GetDeviceScaleFactor(layer()); | 331 float scale = ui::GetDeviceScaleFactor(layer()); |
314 ui::Transform transform = layer()->transform(); | 332 ui::Transform transform = layer()->transform(); |
315 transform.ConcatScale(scale, scale); | 333 transform.ConcatScale(scale, scale); |
316 event->UpdateForRootTransform(transform); | 334 event->UpdateForRootTransform(transform); |
317 } else { | 335 } else { |
318 event->UpdateForRootTransform(layer()->transform()); | 336 event->UpdateForRootTransform(layer()->transform()); |
319 } | 337 } |
320 bool handled = false; | 338 bool handled = false; |
321 | 339 |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1031 void RootWindow::UnlockCompositor() { | 1049 void RootWindow::UnlockCompositor() { |
1032 DCHECK(compositor_lock_); | 1050 DCHECK(compositor_lock_); |
1033 compositor_lock_ = NULL; | 1051 compositor_lock_ = NULL; |
1034 if (draw_on_compositor_unlock_) { | 1052 if (draw_on_compositor_unlock_) { |
1035 draw_on_compositor_unlock_ = false; | 1053 draw_on_compositor_unlock_ = false; |
1036 ScheduleDraw(); | 1054 ScheduleDraw(); |
1037 } | 1055 } |
1038 } | 1056 } |
1039 | 1057 |
1040 } // namespace aura | 1058 } // namespace aura |
OLD | NEW |