OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "apps/moterm/moterm_view.h" | 5 #include "apps/moterm/moterm_view.h" |
6 | 6 |
7 #ifndef GL_GLEXT_PROTOTYPES | 7 #ifndef GL_GLEXT_PROTOTYPES |
8 #define GL_GLEXT_PROTOTYPES | 8 #define GL_GLEXT_PROTOTYPES |
9 #endif | 9 #endif |
10 | 10 |
11 #include <GLES2/gl2.h> | 11 #include <GLES2/gl2.h> |
12 #include <GLES2/gl2ext.h> | 12 #include <GLES2/gl2ext.h> |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
15 #include <string> | 15 #include <string> |
| 16 #include <utility> |
16 | 17 |
17 #include "apps/moterm/key_util.h" | 18 #include "apps/moterm/key_util.h" |
18 #include "base/bind.h" | 19 #include "base/bind.h" |
19 #include "base/logging.h" | 20 #include "base/logging.h" |
20 #include "mojo/public/cpp/application/connect.h" | 21 #include "mojo/public/cpp/application/connect.h" |
21 #include "mojo/public/cpp/bindings/interface_request.h" | 22 #include "mojo/public/cpp/bindings/interface_request.h" |
22 #include "mojo/services/files/interfaces/file.mojom.h" | 23 #include "mojo/services/files/interfaces/file.mojom.h" |
23 #include "mojo/services/files/interfaces/types.mojom.h" | 24 #include "mojo/services/files/interfaces/types.mojom.h" |
24 #include "mojo/services/terminal/interfaces/terminal_client.mojom.h" | 25 #include "mojo/services/terminal/interfaces/terminal_client.mojom.h" |
25 #include "mojo/skia/ganesh_texture_surface.h" | 26 #include "mojo/skia/ganesh_texture_surface.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 return; | 156 return; |
156 } | 157 } |
157 } | 158 } |
158 | 159 |
159 driver_ = MotermDriver::Create(this, terminal_file.Pass()); | 160 driver_ = MotermDriver::Create(this, terminal_file.Pass()); |
160 DCHECK(on_closed_callback_.is_null()); | 161 DCHECK(on_closed_callback_.is_null()); |
161 on_closed_callback_ = [callback] { callback.Run(mojo::files::Error::OK); }; | 162 on_closed_callback_ = [callback] { callback.Run(mojo::files::Error::OK); }; |
162 } | 163 } |
163 | 164 |
164 void MotermView::ConnectToClient( | 165 void MotermView::ConnectToClient( |
165 mojo::terminal::TerminalClientPtr terminal_client, | 166 mojo::InterfaceHandle<mojo::terminal::TerminalClient> terminal_client, |
166 bool force, | 167 bool force, |
167 const ConnectToClientCallback& callback) { | 168 const ConnectToClientCallback& callback) { |
168 if (driver_) { | 169 if (driver_) { |
169 // We already have a connection. | 170 // We already have a connection. |
170 if (force) { | 171 if (force) { |
171 OnClosed(); | 172 OnClosed(); |
172 } else { | 173 } else { |
173 // TODO(vtl): Is this error code right? | 174 // TODO(vtl): Is this error code right? |
174 callback.Run(mojo::files::Error::UNAVAILABLE); | 175 callback.Run(mojo::files::Error::UNAVAILABLE); |
175 return; | 176 return; |
176 } | 177 } |
177 } | 178 } |
178 | 179 |
179 mojo::files::FilePtr file; | 180 mojo::InterfaceHandle<mojo::files::File> file; |
180 driver_ = MotermDriver::Create(this, GetProxy(&file)); | 181 driver_ = MotermDriver::Create(this, GetProxy(&file)); |
181 terminal_client->ConnectToTerminal(file.Pass()); | 182 mojo::terminal::TerminalClientPtr::Create(std::move(terminal_client)) |
| 183 ->ConnectToTerminal(std::move(file)); |
182 DCHECK(on_closed_callback_.is_null()); | 184 DCHECK(on_closed_callback_.is_null()); |
183 on_closed_callback_ = [callback] { callback.Run(mojo::files::Error::OK); }; | 185 on_closed_callback_ = [callback] { callback.Run(mojo::files::Error::OK); }; |
184 } | 186 } |
185 | 187 |
186 void MotermView::GetSize(const GetSizeCallback& callback) { | 188 void MotermView::GetSize(const GetSizeCallback& callback) { |
187 MotermModel::Size size = model_.GetSize(); | 189 MotermModel::Size size = model_.GetSize(); |
188 callback.Run(mojo::files::Error::OK, size.rows, size.columns); | 190 callback.Run(mojo::files::Error::OK, size.rows, size.columns); |
189 } | 191 } |
190 | 192 |
191 void MotermView::SetSize(uint32_t rows, | 193 void MotermView::SetSize(uint32_t rows, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 318 |
317 void MotermView::OnKeyPressed(mojo::EventPtr key_event) { | 319 void MotermView::OnKeyPressed(mojo::EventPtr key_event) { |
318 std::string input_sequence = | 320 std::string input_sequence = |
319 GetInputSequenceForKeyPressedEvent(*key_event, keypad_application_mode_); | 321 GetInputSequenceForKeyPressedEvent(*key_event, keypad_application_mode_); |
320 if (input_sequence.empty()) | 322 if (input_sequence.empty()) |
321 return; | 323 return; |
322 | 324 |
323 if (driver_) | 325 if (driver_) |
324 driver_->SendData(input_sequence.data(), input_sequence.size()); | 326 driver_->SendData(input_sequence.data(), input_sequence.size()); |
325 } | 327 } |
OLD | NEW |