| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 //////////////////////////////////////////////////////////////////////////////// | 110 //////////////////////////////////////////////////////////////////////////////// |
| 111 // RootWindow, public: | 111 // RootWindow, public: |
| 112 | 112 |
| 113 RootWindow::RootWindow(const gfx::Rect& initial_bounds) | 113 RootWindow::RootWindow(const gfx::Rect& initial_bounds) |
| 114 : Window(NULL), | 114 : Window(NULL), |
| 115 host_(aura::RootWindowHost::Create(initial_bounds)), | 115 host_(aura::RootWindowHost::Create(initial_bounds)), |
| 116 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), | 116 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), |
| 117 ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)), | 117 ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)), |
| 118 mouse_button_flags_(0), | 118 mouse_button_flags_(0), |
| 119 touch_ids_down_(0), |
| 119 last_cursor_(ui::kCursorNull), | 120 last_cursor_(ui::kCursorNull), |
| 120 cursor_shown_(true), | 121 cursor_shown_(true), |
| 121 capture_window_(NULL), | 122 capture_window_(NULL), |
| 122 mouse_pressed_handler_(NULL), | 123 mouse_pressed_handler_(NULL), |
| 123 mouse_moved_handler_(NULL), | 124 mouse_moved_handler_(NULL), |
| 124 ALLOW_THIS_IN_INITIALIZER_LIST( | 125 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 125 gesture_recognizer_(ui::GestureRecognizer::Create(this))), | 126 gesture_recognizer_(ui::GestureRecognizer::Create(this))), |
| 126 synthesize_mouse_move_(false), | 127 synthesize_mouse_move_(false), |
| 127 waiting_on_compositing_end_(false), | 128 waiting_on_compositing_end_(false), |
| 128 draw_on_compositing_end_(false), | 129 draw_on_compositing_end_(false), |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 if (IsNonClientLocation(target, location_in_window)) | 302 if (IsNonClientLocation(target, location_in_window)) |
| 302 flags |= ui::EF_IS_NON_CLIENT; | 303 flags |= ui::EF_IS_NON_CLIENT; |
| 303 ScrollEvent translated_event(*event, this, target, event->type(), flags); | 304 ScrollEvent translated_event(*event, this, target, event->type(), flags); |
| 304 return ProcessMouseEvent(target, &translated_event); | 305 return ProcessMouseEvent(target, &translated_event); |
| 305 } | 306 } |
| 306 return false; | 307 return false; |
| 307 } | 308 } |
| 308 | 309 |
| 309 bool RootWindow::DispatchTouchEvent(TouchEvent* event) { | 310 bool RootWindow::DispatchTouchEvent(TouchEvent* event) { |
| 310 DispatchHeldMouseMove(); | 311 DispatchHeldMouseMove(); |
| 312 switch (event->type()) { |
| 313 case ui::ET_TOUCH_PRESSED: |
| 314 touch_ids_down_ |= (1 << event->touch_id()); |
| 315 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); |
| 316 break; |
| 317 |
| 318 // Don't handle ET_TOUCH_CANCELLED since we always get a ET_TOUCH_RELEASED. |
| 319 case ui::ET_TOUCH_RELEASED: |
| 320 touch_ids_down_ = (touch_ids_down_ | (1 << event->touch_id())) ^ |
| 321 (1 << event->touch_id()); |
| 322 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); |
| 323 break; |
| 324 |
| 325 default: |
| 326 break; |
| 327 } |
| 311 float scale = ui::GetDeviceScaleFactor(layer()); | 328 float scale = ui::GetDeviceScaleFactor(layer()); |
| 312 ui::Transform transform = layer()->transform(); | 329 ui::Transform transform = layer()->transform(); |
| 313 transform.ConcatScale(scale, scale); | 330 transform.ConcatScale(scale, scale); |
| 314 event->UpdateForRootTransform(transform); | 331 event->UpdateForRootTransform(transform); |
| 315 bool handled = false; | 332 bool handled = false; |
| 316 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN; | 333 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN; |
| 317 Window* target = capture_window_; | 334 Window* target = capture_window_; |
| 318 if (!target) { | 335 if (!target) { |
| 319 target = ConsumerToWindow( | 336 target = ConsumerToWindow( |
| 320 gesture_recognizer_->GetTouchLockedTarget(event)); | 337 gesture_recognizer_->GetTouchLockedTarget(event)); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 for (EventFilters::const_reverse_iterator it = filters.rbegin(), | 753 for (EventFilters::const_reverse_iterator it = filters.rbegin(), |
| 737 rend = filters.rend(); | 754 rend = filters.rend(); |
| 738 it != rend; ++it) { | 755 it != rend; ++it) { |
| 739 status = (*it)->PreHandleGestureEvent(target, event); | 756 status = (*it)->PreHandleGestureEvent(target, event); |
| 740 if (status != ui::GESTURE_STATUS_UNKNOWN) | 757 if (status != ui::GESTURE_STATUS_UNKNOWN) |
| 741 return status; | 758 return status; |
| 742 } | 759 } |
| 743 | 760 |
| 744 if (target->delegate()) | 761 if (target->delegate()) |
| 745 status = target->delegate()->OnGestureEvent(event); | 762 status = target->delegate()->OnGestureEvent(event); |
| 746 if (status == ui::GESTURE_STATUS_UNKNOWN) { | 763 if (status == ui::GESTURE_STATUS_UNKNOWN && |
| 764 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 765 switches::kAuraDisableMouseEventsFromTouch)) { |
| 747 // The gesture was unprocessed. Generate corresponding mouse events here | 766 // The gesture was unprocessed. Generate corresponding mouse events here |
| 748 // (e.g. tap to click). | 767 // (e.g. tap to click). |
| 749 const ui::EventType* types = NULL; | 768 const ui::EventType* types = NULL; |
| 750 bool generate_move = false; | 769 bool generate_move = false; |
| 751 switch (event->type()) { | 770 switch (event->type()) { |
| 752 case ui::ET_GESTURE_TAP: | 771 case ui::ET_GESTURE_TAP: |
| 753 case ui::ET_GESTURE_DOUBLE_TAP: // Double click is special cased below. | 772 case ui::ET_GESTURE_DOUBLE_TAP: // Double click is special cased below. |
| 754 generate_move = true; | 773 generate_move = true; |
| 755 types = kTapTypes; | 774 types = kTapTypes; |
| 756 break; | 775 break; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 void RootWindow::UnlockCompositor() { | 1029 void RootWindow::UnlockCompositor() { |
| 1011 DCHECK(compositor_lock_); | 1030 DCHECK(compositor_lock_); |
| 1012 compositor_lock_ = NULL; | 1031 compositor_lock_ = NULL; |
| 1013 if (draw_on_compositor_unlock_) { | 1032 if (draw_on_compositor_unlock_) { |
| 1014 draw_on_compositor_unlock_ = false; | 1033 draw_on_compositor_unlock_ = false; |
| 1015 ScheduleDraw(); | 1034 ScheduleDraw(); |
| 1016 } | 1035 } |
| 1017 } | 1036 } |
| 1018 | 1037 |
| 1019 } // namespace aura | 1038 } // namespace aura |
| OLD | NEW |