Skip to content

Commit

Permalink
chromeos: Rename "touch_hud" mojo app to "tap_visualizer"
Browse files Browse the repository at this point in the history
It implements the "Show Taps" UI feature and is turned on via the flag
--show-taps, so use a name with "taps" in it.

Bug: 840380
Test: compiles, ash_unittests
Change-Id: I84784115cb7ba26bfcac8c28db293df62b95ebf5
Reviewed-on: https://chromium-review.googlesource.com/1067851
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: James Cook <jamescook@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560907}
  • Loading branch information
James Cook authored and Commit Bot committed May 23, 2018
1 parent d3e894c commit a938409
Show file tree
Hide file tree
Showing 35 changed files with 133 additions and 139 deletions.
8 changes: 4 additions & 4 deletions ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ component("ash") {
"//ash/components/fast_ink",
"//ash/components/quick_launch/public/mojom",
"//ash/components/shortcut_viewer/public/mojom",
"//ash/components/touch_hud/public/mojom",
"//ash/components/tap_visualizer/public/mojom",
"//ash/system/message_center/arc",
"//ash/touch_hud",
"//base",
Expand Down Expand Up @@ -1484,8 +1484,8 @@ static_library("ash_shell_lib_with_content") {
"//ash/components/quick_launch/public/mojom",
"//ash/components/shortcut_viewer:lib",
"//ash/components/shortcut_viewer/public/mojom",
"//ash/components/touch_hud:lib",
"//ash/components/touch_hud/public/mojom",
"//ash/components/tap_visualizer:lib",
"//ash/components/tap_visualizer/public/mojom",
"//ash/public/cpp",
"//ash/shell:resources",
"//base:i18n",
Expand Down Expand Up @@ -1865,7 +1865,7 @@ test("ash_unittests") {
"//ash/components/fast_ink",
"//ash/components/fast_ink:unit_tests",
"//ash/components/shortcut_viewer:unit_tests",
"//ash/components/touch_hud:unit_tests",
"//ash/components/tap_visualizer:unit_tests",
"//ash/public/cpp",
"//ash/public/cpp:unit_tests",
"//ash/public/cpp/vector_icons",
Expand Down
2 changes: 1 addition & 1 deletion ash/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ include_rules = [
# Ash can talk to public interfaces for mini-apps.
"+ash/components/autoclick/public",
"+ash/components/quick_launch/public",
"+ash/components/touch_hud/public",
"+ash/components/tap_visualizer/public",

# Ash sits above content. Exceptions live in //ash/content.
"-content",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import("//services/service_manager/public/service_manifest.gni")

source_set("lib") {
sources = [
"touch_hud_application.cc",
"touch_hud_application.h",
"touch_hud_renderer.cc",
"touch_hud_renderer.h",
"tap_renderer.cc",
"tap_renderer.h",
"tap_visualizer_app.cc",
"tap_visualizer_app.h",
]

deps = [
Expand All @@ -31,14 +31,14 @@ source_set("lib") {
}

service_manifest("manifest") {
name = "touch_hud_app"
name = "tap_visualizer_app"
source = "manifest.json"
}

source_set("unit_tests") {
testonly = true
sources = [
"touch_hud_application_unittest.cc",
"tap_visualizer_app_unittest.cc",
]
deps = [
":lib",
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "touch_hud_app",
"display_name": "Touch Hud",
"name": "tap_visualizer_app",
"display_name": "Show Taps",
"sandbox_type": "none",
"interface_provider_specs": {
"service_manager:connector": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module touch_hud.mojom;
module tap_visualizer.mojom;

const string kServiceName = "touch_hud_app";
const string kServiceName = "tap_visualizer_app";
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/components/touch_hud/touch_hud_renderer.h"
#include "ash/components/tap_visualizer/tap_renderer.h"

#include "base/logging.h"
#include "base/time/time.h"
Expand All @@ -19,7 +19,7 @@
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"

namespace touch_hud {
namespace tap_visualizer {

const int kPointRadius = 20;
const SkColor kProjectionFillColor = SkColorSetRGB(0xF5, 0xF5, 0xDC);
Expand Down Expand Up @@ -115,14 +115,14 @@ class TouchPointView : public views::View, public gfx::AnimationDelegate {
DISALLOW_COPY_AND_ASSIGN(TouchPointView);
};

TouchHudRenderer::TouchHudRenderer(std::unique_ptr<views::Widget> widget)
TapRenderer::TapRenderer(std::unique_ptr<views::Widget> widget)
: widget_(std::move(widget)) {
DCHECK(widget_);
}

TouchHudRenderer::~TouchHudRenderer() = default;
TapRenderer::~TapRenderer() = default;

void TouchHudRenderer::HandleTouchEvent(const ui::PointerEvent& event) {
void TapRenderer::HandleTouchEvent(const ui::PointerEvent& event) {
DCHECK(event.IsTouchPointerEvent());
const int id = event.pointer_details().id;
if (event.type() == ui::ET_POINTER_DOWN) {
Expand Down Expand Up @@ -150,4 +150,4 @@ void TouchHudRenderer::HandleTouchEvent(const ui::PointerEvent& event) {
}
}

} // namespace touch_hud
} // namespace tap_visualizer
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_COMPONENTS_TOUCH_HUD_TOUCH_HUD_RENDERER_H_
#define ASH_COMPONENTS_TOUCH_HUD_TOUCH_HUD_RENDERER_H_
#ifndef ASH_COMPONENTS_TAP_VISUALIZER_TAP_RENDERER_H_
#define ASH_COMPONENTS_TAP_VISUALIZER_TAP_RENDERER_H_

#include <map>
#include <memory>
Expand All @@ -18,30 +18,30 @@ namespace views {
class Widget;
}

namespace touch_hud {
namespace tap_visualizer {
class TouchPointView;

// Renders touch points into a widget.
class TouchHudRenderer {
class TapRenderer {
public:
explicit TouchHudRenderer(std::unique_ptr<views::Widget> widget);
~TouchHudRenderer();
explicit TapRenderer(std::unique_ptr<views::Widget> widget);
~TapRenderer();

// Receives a touch event and draws its touch point.
void HandleTouchEvent(const ui::PointerEvent& event);

private:
friend class TouchHudApplicationTestApi;
friend class TapVisualizerAppTestApi;

// The widget containing the touch point views.
std::unique_ptr<views::Widget> widget_;

// A map of touch ids to TouchPointView.
std::map<int, TouchPointView*> points_;

DISALLOW_COPY_AND_ASSIGN(TouchHudRenderer);
DISALLOW_COPY_AND_ASSIGN(TapRenderer);
};

} // namespace touch_hud
} // namespace tap_visualizer

#endif // ASH_COMPONENTS_TOUCH_HUD_TOUCH_HUD_RENDERER_H_
#endif // ASH_COMPONENTS_TAP_VISUALIZER_TAP_RENDERER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/components/touch_hud/touch_hud_application.h"
#include "ash/components/tap_visualizer/tap_visualizer_app.h"

#include <utility>

#include "ash/components/touch_hud/touch_hud_renderer.h"
#include "ash/components/tap_visualizer/tap_renderer.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
Expand All @@ -23,17 +23,17 @@
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"

namespace touch_hud {
namespace tap_visualizer {

TouchHudApplication::TouchHudApplication() = default;
TapVisualizerApp::TapVisualizerApp() = default;

TouchHudApplication::~TouchHudApplication() {
TapVisualizerApp::~TapVisualizerApp() {
display::Screen::GetScreen()->RemoveObserver(this);
views::MusClient::Get()->pointer_watcher_event_router()->RemovePointerWatcher(
this);
}

void TouchHudApplication::Start() {
void TapVisualizerApp::Start() {
// Watches moves so the user can drag around a touch point.
views::MusClient::Get()->pointer_watcher_event_router()->AddPointerWatcher(
this, true /* want_moves */);
Expand All @@ -44,7 +44,7 @@ void TouchHudApplication::Start() {
}
}

void TouchHudApplication::OnStart() {
void TapVisualizerApp::OnStart() {
const bool register_path_provider = false;
aura_init_ = views::AuraInit::Create(
context()->connector(), context()->identity(), "views_mus_resources.pak",
Expand All @@ -57,7 +57,7 @@ void TouchHudApplication::OnStart() {
Start();
}

void TouchHudApplication::OnPointerEventObserved(
void TapVisualizerApp::OnPointerEventObserved(
const ui::PointerEvent& event,
const gfx::Point& location_in_screen,
gfx::NativeView target) {
Expand All @@ -69,22 +69,21 @@ void TouchHudApplication::OnPointerEventObserved(
.id();
auto it = display_id_to_renderer_.find(display_id);
if (it != display_id_to_renderer_.end()) {
TouchHudRenderer* renderer = it->second.get();
TapRenderer* renderer = it->second.get();
renderer->HandleTouchEvent(event);
}
}

void TouchHudApplication::OnDisplayAdded(const display::Display& new_display) {
void TapVisualizerApp::OnDisplayAdded(const display::Display& new_display) {
CreateWidgetForDisplay(new_display.id());
}

void TouchHudApplication::OnDisplayRemoved(
const display::Display& old_display) {
void TapVisualizerApp::OnDisplayRemoved(const display::Display& old_display) {
// Deletes the renderer.
display_id_to_renderer_.erase(old_display.id());
}

void TouchHudApplication::CreateWidgetForDisplay(int64_t display_id) {
void TapVisualizerApp::CreateWidgetForDisplay(int64_t display_id) {
std::unique_ptr<views::Widget> widget = std::make_unique<views::Widget>();
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
Expand All @@ -99,12 +98,12 @@ void TouchHudApplication::CreateWidgetForDisplay(int64_t display_id) {
params.mus_properties[ui::mojom::WindowManager::kDisplayId_InitProperty] =
mojo::ConvertTo<std::vector<uint8_t>>(display_id);
params.show_state = ui::SHOW_STATE_FULLSCREEN;
params.name = "TouchHud";
params.name = "TapVisualizer";
widget->Init(params);
widget->Show();

display_id_to_renderer_[display_id] =
std::make_unique<TouchHudRenderer>(std::move(widget));
std::make_unique<TapRenderer>(std::move(widget));
}

} // namespace touch_hud
} // namespace tap_visualizer
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_COMPONENTS_TOUCH_HUD_TOUCH_HUD_APPLICATION_H_
#define ASH_COMPONENTS_TOUCH_HUD_TOUCH_HUD_APPLICATION_H_
#ifndef ASH_COMPONENTS_TAP_VISUALIZER_TAP_VISUALIZER_APP_H_
#define ASH_COMPONENTS_TAP_VISUALIZER_TAP_VISUALIZER_APP_H_

#include <stdint.h>

Expand All @@ -19,21 +19,21 @@ namespace views {
class AuraInit;
} // namespace views

namespace touch_hud {
namespace tap_visualizer {

class TouchHudRenderer;
class TapRenderer;

// Application that paints touch tap points as circles. Creates a fullscreen
// transparent widget on each display to draw the taps.
class TouchHudApplication : public service_manager::Service,
public views::PointerWatcher,
public display::DisplayObserver {
class TapVisualizerApp : public service_manager::Service,
public views::PointerWatcher,
public display::DisplayObserver {
public:
TouchHudApplication();
~TouchHudApplication() override;
TapVisualizerApp();
~TapVisualizerApp() override;

private:
friend class TouchHudApplicationTestApi;
friend class TapVisualizerAppTestApi;

// Starts showing touches on all displays.
void Start();
Expand All @@ -54,13 +54,13 @@ class TouchHudApplication : public service_manager::Service,
void CreateWidgetForDisplay(int64_t display_id);

// Maps display::Display::id() to the renderer for that display.
std::map<int64_t, std::unique_ptr<TouchHudRenderer>> display_id_to_renderer_;
std::map<int64_t, std::unique_ptr<TapRenderer>> display_id_to_renderer_;

std::unique_ptr<views::AuraInit> aura_init_;

DISALLOW_COPY_AND_ASSIGN(TouchHudApplication);
DISALLOW_COPY_AND_ASSIGN(TapVisualizerApp);
};

} // namespace touch_hud
} // namespace tap_visualizer

#endif // ASH_COMPONENTS_TOUCH_HUD_TOUCH_HUD_APPLICATION_H_
#endif // ASH_COMPONENTS_TAP_VISUALIZER_TAP_VISUALIZER_APP_H_
Loading

0 comments on commit a938409

Please sign in to comment.