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

Unified Diff: native_client_sdk/src/libraries/ppapi_simple/ps_instance.cc

Issue 66343004: [NaCl SDK] ppapi_simple: Allow initial terminal size to to be set on startup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | « native_client_sdk/src/libraries/ppapi_simple/ps_instance.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/libraries/ppapi_simple/ps_instance.cc
diff --git a/native_client_sdk/src/libraries/ppapi_simple/ps_instance.cc b/native_client_sdk/src/libraries/ppapi_simple/ps_instance.cc
index 3f59e08b48ac2a12b0b96e8e8bad81c6f0385856..d2d824b004e0d0b0bb92b0ff145f6d59db7ddae1 100644
--- a/native_client_sdk/src/libraries/ppapi_simple/ps_instance.cc
+++ b/native_client_sdk/src/libraries/ppapi_simple/ps_instance.cc
@@ -238,6 +238,11 @@ bool PSInstance::ProcessProperties() {
if (tty_resize)
RegisterMessageHandler(tty_resize, MessageHandlerResizeStatic, this);
+ const char* tty_rows = getenv("PS_TTY_ROWS");
+ const char* tty_cols = getenv("PS_TTY_COLS");
+ if (tty_rows && tty_cols)
+ HandleResize(atoi(tty_cols), atoi(tty_rows));
binji 2013/11/09 00:55:08 better error messaging here? What if only one is s
Sam Clegg 2013/11/09 01:12:58 Done.
+
tioc_nacl_output handler;
handler.handler = TtyOutputHandlerStatic;
handler.user_data = this;
@@ -372,16 +377,22 @@ void PSInstance::MessageHandlerInput(const pp::Var& message) {
}
}
+void PSInstance::HandleResize(int width, int height){
+ struct winsize size;
+ memset(&size, 0, sizeof(size));
+ size.ws_col = width;
+ size.ws_row = height;
+ ioctl(tty_fd_, TIOCSWINSZ, reinterpret_cast<char*>(&size));
+}
+
void PSInstance::MessageHandlerResize(const pp::Var& message) {
assert(message.is_array());
pp::VarArray array(message);
assert(array.GetLength() == 2);
- struct winsize size;
- memset(&size, 0, sizeof(size));
- size.ws_col = array.Get(0).AsInt();
- size.ws_row = array.Get(1).AsInt();
- ioctl(tty_fd_, TIOCSWINSZ, reinterpret_cast<char*>(&size));
+ int width = array.Get(0).AsInt();
+ int height = array.Get(1).AsInt();
+ HandleResize(width, height);
}
ssize_t PSInstance::TtyOutputHandlerStatic(const char* buf,
« no previous file with comments | « native_client_sdk/src/libraries/ppapi_simple/ps_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698