| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/touch/touch_hud_debug.h" | 5 #include "ash/touch/touch_hud_debug.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ash/display/display_manager.h" | 11 #include "ash/display/display_manager.h" |
| 12 #include "ash/root_window_controller.h" | 12 #include "ash/root_window_controller.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "base/json/json_string_value_serializer.h" | 14 #include "base/json/json_string_value_serializer.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "third_party/skia/include/core/SkPath.h" | 18 #include "third_party/skia/include/core/SkPath.h" |
| 19 #include "ui/aura/window_event_dispatcher.h" | 19 #include "ui/aura/window_event_dispatcher.h" |
| 20 #include "ui/display/display.h" |
| 20 #include "ui/events/event.h" | 21 #include "ui/events/event.h" |
| 21 #include "ui/gfx/animation/animation_delegate.h" | 22 #include "ui/gfx/animation/animation_delegate.h" |
| 22 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
| 23 #include "ui/gfx/display.h" | |
| 24 #include "ui/gfx/geometry/size.h" | 24 #include "ui/gfx/geometry/size.h" |
| 25 #include "ui/gfx/geometry/vector2d.h" | 25 #include "ui/gfx/geometry/vector2d.h" |
| 26 #include "ui/gfx/transform.h" | 26 #include "ui/gfx/transform.h" |
| 27 #include "ui/views/controls/label.h" | 27 #include "ui/views/controls/label.h" |
| 28 #include "ui/views/layout/box_layout.h" | 28 #include "ui/views/layout/box_layout.h" |
| 29 #include "ui/views/widget/widget.h" | 29 #include "ui/views/widget/widget.h" |
| 30 | 30 |
| 31 #if defined(USE_X11) | 31 #if defined(USE_X11) |
| 32 #include <X11/extensions/XInput2.h> | 32 #include <X11/extensions/XInput2.h> |
| 33 #include <X11/Xlib.h> | 33 #include <X11/Xlib.h> |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 321 |
| 322 DISALLOW_COPY_AND_ASSIGN(TouchHudCanvas); | 322 DISALLOW_COPY_AND_ASSIGN(TouchHudCanvas); |
| 323 }; | 323 }; |
| 324 | 324 |
| 325 TouchHudDebug::TouchHudDebug(aura::Window* initial_root) | 325 TouchHudDebug::TouchHudDebug(aura::Window* initial_root) |
| 326 : TouchObserverHUD(initial_root), | 326 : TouchObserverHUD(initial_root), |
| 327 mode_(FULLSCREEN), | 327 mode_(FULLSCREEN), |
| 328 touch_log_(new TouchLog()), | 328 touch_log_(new TouchLog()), |
| 329 canvas_(NULL), | 329 canvas_(NULL), |
| 330 label_container_(NULL) { | 330 label_container_(NULL) { |
| 331 const gfx::Display& display = | 331 const display::Display& display = |
| 332 Shell::GetInstance()->display_manager()->GetDisplayForId(display_id()); | 332 Shell::GetInstance()->display_manager()->GetDisplayForId(display_id()); |
| 333 | 333 |
| 334 views::View* content = widget()->GetContentsView(); | 334 views::View* content = widget()->GetContentsView(); |
| 335 | 335 |
| 336 canvas_ = new TouchHudCanvas(*touch_log_); | 336 canvas_ = new TouchHudCanvas(*touch_log_); |
| 337 content->AddChildView(canvas_); | 337 content->AddChildView(canvas_); |
| 338 | 338 |
| 339 const gfx::Size& display_size = display.size(); | 339 const gfx::Size& display_size = display.size(); |
| 340 canvas_->SetSize(display_size); | 340 canvas_->SetSize(display_size); |
| 341 | 341 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 void TouchHudDebug::OnTouchEvent(ui::TouchEvent* event) { | 451 void TouchHudDebug::OnTouchEvent(ui::TouchEvent* event) { |
| 452 if (event->touch_id() >= kMaxTouchPoints) | 452 if (event->touch_id() >= kMaxTouchPoints) |
| 453 return; | 453 return; |
| 454 | 454 |
| 455 touch_log_->AddTouchPoint(*event); | 455 touch_log_->AddTouchPoint(*event); |
| 456 canvas_->TouchPointAdded(event->touch_id()); | 456 canvas_->TouchPointAdded(event->touch_id()); |
| 457 UpdateTouchPointLabel(event->touch_id()); | 457 UpdateTouchPointLabel(event->touch_id()); |
| 458 label_container_->SetSize(label_container_->GetPreferredSize()); | 458 label_container_->SetSize(label_container_->GetPreferredSize()); |
| 459 } | 459 } |
| 460 | 460 |
| 461 void TouchHudDebug::OnDisplayMetricsChanged(const gfx::Display& display, | 461 void TouchHudDebug::OnDisplayMetricsChanged(const display::Display& display, |
| 462 uint32_t metrics) { | 462 uint32_t metrics) { |
| 463 TouchObserverHUD::OnDisplayMetricsChanged(display, metrics); | 463 TouchObserverHUD::OnDisplayMetricsChanged(display, metrics); |
| 464 | 464 |
| 465 if (display.id() != display_id() || !(metrics & DISPLAY_METRIC_BOUNDS)) | 465 if (display.id() != display_id() || !(metrics & DISPLAY_METRIC_BOUNDS)) |
| 466 return; | 466 return; |
| 467 const gfx::Size& size = display.size(); | 467 const gfx::Size& size = display.size(); |
| 468 canvas_->SetSize(size); | 468 canvas_->SetSize(size); |
| 469 label_container_->SetY(size.height() / kReducedScale); | 469 label_container_->SetY(size.height() / kReducedScale); |
| 470 } | 470 } |
| 471 | 471 |
| 472 void TouchHudDebug::SetHudForRootWindowController( | 472 void TouchHudDebug::SetHudForRootWindowController( |
| 473 RootWindowController* controller) { | 473 RootWindowController* controller) { |
| 474 controller->set_touch_hud_debug(this); | 474 controller->set_touch_hud_debug(this); |
| 475 } | 475 } |
| 476 | 476 |
| 477 void TouchHudDebug::UnsetHudForRootWindowController( | 477 void TouchHudDebug::UnsetHudForRootWindowController( |
| 478 RootWindowController* controller) { | 478 RootWindowController* controller) { |
| 479 controller->set_touch_hud_debug(NULL); | 479 controller->set_touch_hud_debug(NULL); |
| 480 } | 480 } |
| 481 | 481 |
| 482 } // namespace ash | 482 } // namespace ash |
| OLD | NEW |