Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(656)

Unified Diff: mash/touch_hud/touch_hud_application.cc

Issue 2092343002: Touch HUD app for mustash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change window manager connection unittest to original Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mash/touch_hud/touch_hud_application.h ('k') | services/ui/public/cpp/lib/window.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mash/touch_hud/touch_hud_application.cc
diff --git a/mash/touch_hud/touch_hud_application.cc b/mash/touch_hud/touch_hud_application.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d0d496240b636ca4e35d3933b2501ebf4e95f3e4
--- /dev/null
+++ b/mash/touch_hud/touch_hud_application.cc
@@ -0,0 +1,122 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mash/touch_hud/touch_hud_application.h"
+
+#include "ash/public/interfaces/container.mojom.h"
+#include "base/macros.h"
+#include "base/strings/utf_string_conversions.h"
+#include "mojo/public/cpp/bindings/binding.h"
+#include "services/catalog/public/interfaces/catalog.mojom.h"
+#include "services/shell/public/cpp/application_runner.h"
+#include "services/shell/public/cpp/connector.h"
+#include "services/ui/common/gpu_service.h"
+#include "services/ui/public/cpp/property_type_converters.h"
+#include "ui/views/background.h"
+#include "ui/views/controls/touch/touch_hud_drawer.h"
+#include "ui/views/mus/aura_init.h"
+#include "ui/views/mus/native_widget_mus.h"
+#include "ui/views/mus/window_manager_connection.h"
+#include "ui/views/touch_event_watcher.h"
+#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_delegate.h"
+
+namespace mash {
+namespace touch_hud {
+
+class TouchHudUI : public views::WidgetDelegateView,
+ public views::TouchEventWatcher {
+ public:
+ TouchHudUI(views::WindowManagerConnection* window_manager_connection,
+ views::Widget* window)
+ : window_manager_connection_(window_manager_connection),
+ window_(window),
+ touch_hud_drawer_(new views::TouchHudDrawer) {
+ window_manager_connection_->AddTouchEventWatcher(this);
+ }
+ ~TouchHudUI() override {
+ window_manager_connection_->RemoveTouchEventWatcher(this);
+ }
+
+ private:
+ // Overridden from views::WidgetDelegate:
+ views::View* GetContentsView() override { return this; }
+ base::string16 GetWindowTitle() const override {
+ // TODO(beng): use resources.
+ return base::ASCIIToUTF16("TouchHud");
+ }
+
+ // Overridden from views::TouchEventWatcher:
+ void OnTouchEventObserved(const ui::LocatedEvent& event,
+ const gfx::Point& location_in_screen,
+ views::Widget* target) override {
+ touch_hud_drawer_->HandleTouchEvent(&event, window_);
+ }
+
+ views::WindowManagerConnection* window_manager_connection_;
+ views::Widget* window_;
+ views::TouchHudDrawer* touch_hud_drawer_;
+
+ DISALLOW_COPY_AND_ASSIGN(TouchHudUI);
+};
+
+TouchHudApplication::TouchHudApplication() {}
+TouchHudApplication::~TouchHudApplication() {}
+
+void TouchHudApplication::Initialize(shell::Connector* connector,
+ const shell::Identity& identity,
+ uint32_t id) {
+ connector_ = connector;
+ ui::GpuService::Initialize(connector_);
+ tracing_.Initialize(connector, identity.name());
+
+ aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak"));
+
+ window_manager_connection_ =
+ views::WindowManagerConnection::Create(connector, identity);
+}
+
+bool TouchHudApplication::AcceptConnection(shell::Connection* connection) {
+ connection->AddInterface<mojom::Launchable>(this);
+ return true;
+}
+
+void TouchHudApplication::Launch(uint32_t what, mojom::LaunchMode how) {
+ shell::mojom::ShellPtr shell;
+ connector_->ConnectToInterface("mojo:shell", &shell);
+
+ if (!window_) {
+ window_ = new views::Widget;
+ views::Widget::InitParams params(
+ views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
+ params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
+ params.activatable = views::Widget::InitParams::ACTIVATABLE_NO;
+ params.accept_events = false;
+ params.delegate = new TouchHudUI(views::WindowManagerConnection::Get(),
+ window_);
+
+ std::map<std::string, std::vector<uint8_t>> properties;
+ properties[ash::mojom::kWindowContainer_Property] =
+ mojo::ConvertTo<std::vector<uint8_t>>(
+ static_cast<int32_t>(ash::mojom::Container::OVERLAY));
+ ui::Window* window =
+ views::WindowManagerConnection::Get()->NewWindow(properties);
+ params.native_widget = new views::NativeWidgetMus(
+ window_, connector_, window, ui::mojom::SurfaceType::DEFAULT,
+ params.accept_events);
+ window_->Init(params);
+ window_->Show();
+ } else {
+ window_->Close();
+ window_ = nullptr;
+ }
+}
+
+void TouchHudApplication::Create(shell::Connection* connection,
+ mojom::LaunchableRequest request) {
+ bindings_.AddBinding(this, std::move(request));
+}
+
+} // namespace touch
+} // namespace mash
« no previous file with comments | « mash/touch_hud/touch_hud_application.h ('k') | services/ui/public/cpp/lib/window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698