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

Side by Side Diff: apps/moterm/moterm_view.cc

Issue 1322103006: Moterm: Plumb responses back to the terminal File. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 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
« apps/moterm/moterm_model.h ('K') | « apps/moterm/moterm_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 MotermView::MotermView( 50 MotermView::MotermView(
51 mojo::Shell* shell, 51 mojo::Shell* shell,
52 mojo::View* view, 52 mojo::View* view,
53 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider_request) 53 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider_request)
54 : view_(view), 54 : view_(view),
55 gl_helper_(this, 55 gl_helper_(this,
56 shell, 56 shell,
57 kTextureFormat, 57 kTextureFormat,
58 false, 58 false,
59 RectToSize(view->bounds())), 59 RectToSize(view->bounds())),
60 model_(MotermModel::Size(240, 160), MotermModel::Size(24, 80)), 60 model_(MotermModel::Size(240, 160), MotermModel::Size(24, 80), this),
61 frame_pending_(false), 61 frame_pending_(false),
62 force_next_draw_(false), 62 force_next_draw_(false),
63 ascent_(0), 63 ascent_(0),
64 line_height_(0), 64 line_height_(0),
65 advance_width_(0) { 65 advance_width_(0) {
66 // TODO(vtl): |service_provider_impl_|'s ctor doesn't like an invalid request, 66 // TODO(vtl): |service_provider_impl_|'s ctor doesn't like an invalid request,
67 // so we have to conditionally, explicitly bind. 67 // so we have to conditionally, explicitly bind.
68 if (service_provider_request.is_pending()) { 68 if (service_provider_request.is_pending()) {
69 service_provider_impl_.Bind(service_provider_request.Pass()); 69 service_provider_impl_.Bind(service_provider_request.Pass());
70 service_provider_impl_.AddService<mojo::terminal::Terminal>(this); 70 service_provider_impl_.AddService<mojo::terminal::Terminal>(this);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 void MotermView::OnContextLost() { 128 void MotermView::OnContextLost() {
129 // TODO(vtl): We'll need to force a draw when we regain a context. 129 // TODO(vtl): We'll need to force a draw when we regain a context.
130 } 130 }
131 131
132 void MotermView::OnFrameDisplayed(uint32_t frame_id) { 132 void MotermView::OnFrameDisplayed(uint32_t frame_id) {
133 DCHECK(frame_pending_); 133 DCHECK(frame_pending_);
134 frame_pending_ = false; 134 frame_pending_ = false;
135 Draw(false); 135 Draw(false);
136 } 136 }
137 137
138 void MotermView::OnResponse(const void* buf, size_t size) {
139 if (driver_)
140 driver_->SendData(buf, size);
141 }
142
138 void MotermView::OnDataReceived(const void* bytes, size_t num_bytes) { 143 void MotermView::OnDataReceived(const void* bytes, size_t num_bytes) {
139 model_.ProcessInput(bytes, num_bytes, &model_state_changes_); 144 model_.ProcessInput(bytes, num_bytes, &model_state_changes_);
140 Draw(false); 145 Draw(false);
141 } 146 }
142 147
143 void MotermView::OnClosed() { 148 void MotermView::OnClosed() {
144 DCHECK(driver_); 149 DCHECK(driver_);
145 driver_->Detach(); 150 driver_->Detach();
146 driver_.reset(); 151 driver_.reset();
147 152
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 } 338 }
334 339
335 void MotermView::OnKeyPressed(const mojo::EventPtr& key_event) { 340 void MotermView::OnKeyPressed(const mojo::EventPtr& key_event) {
336 std::string input_sequence = GetInputSequenceForKeyPressedEvent(*key_event); 341 std::string input_sequence = GetInputSequenceForKeyPressedEvent(*key_event);
337 if (input_sequence.empty()) 342 if (input_sequence.empty())
338 return; 343 return;
339 344
340 if (driver_) 345 if (driver_)
341 driver_->SendData(input_sequence.data(), input_sequence.size()); 346 driver_->SendData(input_sequence.data(), input_sequence.size());
342 } 347 }
OLDNEW
« apps/moterm/moterm_model.h ('K') | « apps/moterm/moterm_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698