| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_hud/mus/touch_hud_application.h" | 5 #include "ash/touch_hud/mus/touch_hud_application.h" |
| 6 | 6 |
| 7 #include "ash/public/interfaces/container.mojom.h" | 7 #include "ash/public/interfaces/container.mojom.h" |
| 8 #include "ash/touch_hud/touch_hud_renderer.h" | 8 #include "ash/touch_hud/touch_hud_renderer.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "services/shell/public/cpp/connector.h" | 11 #include "services/shell/public/cpp/connector.h" |
| 12 #include "services/ui/public/cpp/property_type_converters.h" | 12 #include "services/ui/public/cpp/property_type_converters.h" |
| 13 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" | 13 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
| 14 #include "ui/views/mus/aura_init.h" | 14 #include "ui/views/mus/aura_init.h" |
| 15 #include "ui/views/mus/native_widget_mus.h" | 15 #include "ui/views/mus/native_widget_mus.h" |
| 16 #include "ui/views/mus/window_manager_connection.h" | 16 #include "ui/views/mus/window_manager_connection.h" |
| 17 #include "ui/views/touch_event_watcher.h" | 17 #include "ui/views/pointer_watcher.h" |
| 18 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 19 #include "ui/views/widget/widget_delegate.h" | 19 #include "ui/views/widget/widget_delegate.h" |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 namespace touch_hud { | 22 namespace touch_hud { |
| 23 | 23 |
| 24 // TouchHudUI handles events on the widget of the touch-hud app. After | 24 // TouchHudUI handles events on the widget of the touch-hud app. After |
| 25 // receiving touch events from ui::WindowManagerConnection, it calls | 25 // receiving touch events from ui::WindowManagerConnection, it calls |
| 26 // ash::TouchHudRenderer to draw out touch points. | 26 // ash::TouchHudRenderer to draw out touch points. |
| 27 class TouchHudUI : public views::WidgetDelegateView, | 27 class TouchHudUI : public views::WidgetDelegateView, |
| 28 public views::TouchEventWatcher { | 28 public views::PointerWatcher { |
| 29 public: | 29 public: |
| 30 TouchHudUI(views::WindowManagerConnection* window_manager_connection, | 30 TouchHudUI(views::WindowManagerConnection* window_manager_connection, |
| 31 views::Widget* widget) | 31 views::Widget* widget) |
| 32 : window_manager_connection_(window_manager_connection), | 32 : window_manager_connection_(window_manager_connection), |
| 33 touch_hud_renderer_(new TouchHudRenderer(widget)) { | 33 touch_hud_renderer_(new TouchHudRenderer(widget)) { |
| 34 window_manager_connection_->AddTouchEventWatcher(this); | 34 window_manager_connection_->AddPointerWatcher(this, true /* want_moves */); |
| 35 } | 35 } |
| 36 ~TouchHudUI() override { | 36 ~TouchHudUI() override { |
| 37 window_manager_connection_->RemoveTouchEventWatcher(this); | 37 window_manager_connection_->RemovePointerWatcher(this); |
| 38 } | 38 } |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 // Overridden from views::WidgetDelegate: | 41 // Overridden from views::WidgetDelegate: |
| 42 views::View* GetContentsView() override { return this; } | 42 views::View* GetContentsView() override { return this; } |
| 43 base::string16 GetWindowTitle() const override { | 43 base::string16 GetWindowTitle() const override { |
| 44 // TODO(beng): use resources. | 44 // TODO(beng): use resources. |
| 45 return base::ASCIIToUTF16("TouchHud"); | 45 return base::ASCIIToUTF16("TouchHud"); |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Overridden from views::TouchEventWatcher: | 48 // Overridden from views::PointerWatcher: |
| 49 void OnTouchEventObserved(const ui::LocatedEvent& event, | 49 void OnPointerEventObserved(const ui::LocatedEvent& event, |
| 50 views::Widget* target) override { | 50 const gfx::Point& location_in_screen, |
| 51 touch_hud_renderer_->HandleTouchEvent(event); | 51 views::Widget* target) override { |
| 52 if (event.IsTouchEvent() || event.IsTouchPointerEvent()) |
| 53 touch_hud_renderer_->HandleTouchEvent(event); |
| 52 } | 54 } |
| 53 | 55 |
| 54 views::WindowManagerConnection* window_manager_connection_; | 56 views::WindowManagerConnection* window_manager_connection_; |
| 55 TouchHudRenderer* touch_hud_renderer_; | 57 TouchHudRenderer* touch_hud_renderer_; |
| 56 | 58 |
| 57 DISALLOW_COPY_AND_ASSIGN(TouchHudUI); | 59 DISALLOW_COPY_AND_ASSIGN(TouchHudUI); |
| 58 }; | 60 }; |
| 59 | 61 |
| 60 TouchHudApplication::TouchHudApplication() : binding_(this) {} | 62 TouchHudApplication::TouchHudApplication() : binding_(this) {} |
| 61 TouchHudApplication::~TouchHudApplication() {} | 63 TouchHudApplication::~TouchHudApplication() {} |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 105 } |
| 104 } | 106 } |
| 105 | 107 |
| 106 void TouchHudApplication::Create(shell::Connection* connection, | 108 void TouchHudApplication::Create(shell::Connection* connection, |
| 107 mash::mojom::LaunchableRequest request) { | 109 mash::mojom::LaunchableRequest request) { |
| 108 binding_.Bind(std::move(request)); | 110 binding_.Bind(std::move(request)); |
| 109 } | 111 } |
| 110 | 112 |
| 111 } // namespace touch_hud | 113 } // namespace touch_hud |
| 112 } // namespace ash | 114 } // namespace ash |
| OLD | NEW |