| 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" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // receiving touch events from ui::WindowManagerConnection, it calls | 26 // receiving touch events from ui::WindowManagerConnection, it calls |
| 27 // ash::TouchHudRenderer to draw out touch points. | 27 // ash::TouchHudRenderer to draw out touch points. |
| 28 class TouchHudUI : public views::WidgetDelegateView, | 28 class TouchHudUI : public views::WidgetDelegateView, |
| 29 public views::PointerWatcher { | 29 public views::PointerWatcher { |
| 30 public: | 30 public: |
| 31 TouchHudUI(views::WindowManagerConnection* window_manager_connection, | 31 TouchHudUI(views::WindowManagerConnection* window_manager_connection, |
| 32 views::Widget* widget) | 32 views::Widget* widget) |
| 33 : window_manager_connection_(window_manager_connection), | 33 : window_manager_connection_(window_manager_connection), |
| 34 touch_hud_renderer_(new TouchHudRenderer(widget)) { | 34 touch_hud_renderer_(new TouchHudRenderer(widget)) { |
| 35 window_manager_connection_->pointer_watcher_event_router() | 35 window_manager_connection_->pointer_watcher_event_router() |
| 36 ->AddPointerWatcher(this, false /* want_moves */); | 36 ->AddPointerWatcher(this, true /* want_moves */); |
| 37 } | 37 } |
| 38 ~TouchHudUI() override { | 38 ~TouchHudUI() override { |
| 39 window_manager_connection_->pointer_watcher_event_router() | 39 window_manager_connection_->pointer_watcher_event_router() |
| 40 ->RemovePointerWatcher(this); | 40 ->RemovePointerWatcher(this); |
| 41 } | 41 } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 // Overridden from views::WidgetDelegate: | 44 // Overridden from views::WidgetDelegate: |
| 45 views::View* GetContentsView() override { return this; } | 45 views::View* GetContentsView() override { return this; } |
| 46 base::string16 GetWindowTitle() const override { | 46 base::string16 GetWindowTitle() const override { |
| 47 // TODO(beng): use resources. | 47 // TODO(beng): use resources. |
| 48 return base::ASCIIToUTF16("TouchHud"); | 48 return base::ASCIIToUTF16("TouchHud"); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Overridden from views::PointerWatcher: | 51 // Overridden from views::PointerWatcher: |
| 52 void OnPointerEventObserved(const ui::PointerEvent& event, | 52 void OnPointerEventObserved(const ui::PointerEvent& event, |
| 53 const gfx::Point& location_in_screen, | 53 const gfx::Point& location_in_screen, |
| 54 views::Widget* target) override { | 54 views::Widget* target) override { |
| 55 if (event.IsTouchPointerEvent()) | 55 if (event.IsTouchPointerEvent()) |
| 56 touch_hud_renderer_->HandleTouchEvent(event); | 56 touch_hud_renderer_->HandleTouchEvent(event); |
| 57 } | 57 } |
| 58 | 58 |
| 59 views::WindowManagerConnection* window_manager_connection_; | 59 views::WindowManagerConnection* window_manager_connection_; |
| 60 TouchHudRenderer* touch_hud_renderer_; | 60 TouchHudRenderer* touch_hud_renderer_; |
| 61 | 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(TouchHudUI); | 62 DISALLOW_COPY_AND_ASSIGN(TouchHudUI); |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 TouchHudApplication::TouchHudApplication() : binding_(this) {} | 65 TouchHudApplication::TouchHudApplication() {} |
| 66 TouchHudApplication::~TouchHudApplication() {} | 66 TouchHudApplication::~TouchHudApplication() {} |
| 67 | 67 |
| 68 void TouchHudApplication::OnStart(const shell::Identity& identity) { | 68 void TouchHudApplication::OnStart(const shell::Identity& identity) { |
| 69 aura_init_.reset(new views::AuraInit(connector(), "views_mus_resources.pak")); | 69 aura_init_.reset(new views::AuraInit(connector(), "views_mus_resources.pak")); |
| 70 window_manager_connection_ = | 70 window_manager_connection_ = |
| 71 views::WindowManagerConnection::Create(connector(), identity); | 71 views::WindowManagerConnection::Create(connector(), identity); |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool TouchHudApplication::OnConnect(const shell::Identity& remote_identity, | 74 bool TouchHudApplication::OnConnect(const shell::Identity& remote_identity, |
| 75 shell::InterfaceRegistry* registry) { | 75 shell::InterfaceRegistry* registry) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 101 widget_->Init(params); | 101 widget_->Init(params); |
| 102 widget_->Show(); | 102 widget_->Show(); |
| 103 } else { | 103 } else { |
| 104 widget_->Close(); | 104 widget_->Close(); |
| 105 base::MessageLoop::current()->QuitWhenIdle(); | 105 base::MessageLoop::current()->QuitWhenIdle(); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 void TouchHudApplication::Create(const shell::Identity& remote_identity, | 109 void TouchHudApplication::Create(const shell::Identity& remote_identity, |
| 110 mash::mojom::LaunchableRequest request) { | 110 mash::mojom::LaunchableRequest request) { |
| 111 binding_.Bind(std::move(request)); | 111 bindings_.AddBinding(this, std::move(request)); |
| 112 } | 112 } |
| 113 | 113 |
| 114 } // namespace touch_hud | 114 } // namespace touch_hud |
| 115 } // namespace ash | 115 } // namespace ash |
| OLD | NEW |