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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mash/touch_hud/touch_hud_application.h"
6
7 #include "ash/public/interfaces/container.mojom.h"
8 #include "base/macros.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "mojo/public/cpp/bindings/binding.h"
11 #include "services/catalog/public/interfaces/catalog.mojom.h"
12 #include "services/shell/public/cpp/application_runner.h"
13 #include "services/shell/public/cpp/connector.h"
14 #include "services/ui/common/gpu_service.h"
15 #include "services/ui/public/cpp/property_type_converters.h"
16 #include "ui/views/background.h"
17 #include "ui/views/controls/touch/touch_hud_drawer.h"
18 #include "ui/views/mus/aura_init.h"
19 #include "ui/views/mus/native_widget_mus.h"
20 #include "ui/views/mus/window_manager_connection.h"
21 #include "ui/views/touch_event_watcher.h"
22 #include "ui/views/widget/widget.h"
23 #include "ui/views/widget/widget_delegate.h"
24
25 namespace mash {
26 namespace touch_hud {
27
28 class TouchHudUI : public views::WidgetDelegateView,
29 public views::TouchEventWatcher {
30 public:
31 TouchHudUI(views::WindowManagerConnection* window_manager_connection,
32 views::Widget* window)
33 : window_manager_connection_(window_manager_connection),
34 window_(window),
35 touch_hud_drawer_(new views::TouchHudDrawer) {
36 window_manager_connection_->AddTouchEventWatcher(this);
37 }
38 ~TouchHudUI() override {
39 window_manager_connection_->RemoveTouchEventWatcher(this);
40 }
41
42 private:
43 // Overridden from views::WidgetDelegate:
44 views::View* GetContentsView() override { return this; }
45 base::string16 GetWindowTitle() const override {
46 // TODO(beng): use resources.
47 return base::ASCIIToUTF16("TouchHud");
48 }
49
50 // Overridden from views::TouchEventWatcher:
51 void OnTouchEventObserved(const ui::LocatedEvent& event,
52 const gfx::Point& location_in_screen,
53 views::Widget* target) override {
54 touch_hud_drawer_->HandleTouchEvent(&event, window_);
55 }
56
57 views::WindowManagerConnection* window_manager_connection_;
58 views::Widget* window_;
59 views::TouchHudDrawer* touch_hud_drawer_;
60
61 DISALLOW_COPY_AND_ASSIGN(TouchHudUI);
62 };
63
64 TouchHudApplication::TouchHudApplication() {}
65 TouchHudApplication::~TouchHudApplication() {}
66
67 void TouchHudApplication::Initialize(shell::Connector* connector,
68 const shell::Identity& identity,
69 uint32_t id) {
70 connector_ = connector;
71 ui::GpuService::Initialize(connector_);
72 tracing_.Initialize(connector, identity.name());
73
74 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak"));
75
76 window_manager_connection_ =
77 views::WindowManagerConnection::Create(connector, identity);
78 }
79
80 bool TouchHudApplication::AcceptConnection(shell::Connection* connection) {
81 connection->AddInterface<mojom::Launchable>(this);
82 return true;
83 }
84
85 void TouchHudApplication::Launch(uint32_t what, mojom::LaunchMode how) {
86 shell::mojom::ShellPtr shell;
87 connector_->ConnectToInterface("mojo:shell", &shell);
88
89 if (!window_) {
90 window_ = new views::Widget;
91 views::Widget::InitParams params(
92 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
93 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
94 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO;
95 params.accept_events = false;
96 params.delegate = new TouchHudUI(views::WindowManagerConnection::Get(),
97 window_);
98
99 std::map<std::string, std::vector<uint8_t>> properties;
100 properties[ash::mojom::kWindowContainer_Property] =
101 mojo::ConvertTo<std::vector<uint8_t>>(
102 static_cast<int32_t>(ash::mojom::Container::OVERLAY));
103 ui::Window* window =
104 views::WindowManagerConnection::Get()->NewWindow(properties);
105 params.native_widget = new views::NativeWidgetMus(
106 window_, connector_, window, ui::mojom::SurfaceType::DEFAULT,
107 params.accept_events);
108 window_->Init(params);
109 window_->Show();
110 } else {
111 window_->Close();
112 window_ = nullptr;
113 }
114 }
115
116 void TouchHudApplication::Create(shell::Connection* connection,
117 mojom::LaunchableRequest request) {
118 bindings_.AddBinding(this, std::move(request));
119 }
120
121 } // namespace touch
122 } // namespace mash
OLDNEW
« 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