From 1c3f6c314f51ab6a24d3935db1d6b269a48fc433 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 25 Oct 2012 12:51:01 +0200 Subject: [PATCH] send actual dimensions of remote client at connection --- src/main.cc | 1 - src/remote.cc | 16 ++++++++++++++++ src/remote.hh | 3 +-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main.cc b/src/main.cc index 9c7e3c65..c6479077 100644 --- a/src/main.cc +++ b/src/main.cc @@ -567,7 +567,6 @@ void setup_server() auto& buffer = *BufferManager::instance().begin(); RemoteUI* ui = new RemoteUI{sock}; - ui->set_dimensions(DisplayCoord(24, 80)); Client client{ui, *buffer->get_or_create_window()}; InputHandler* input_handler = client.input_handler.get(); Context* context = client.context.get(); diff --git a/src/remote.cc b/src/remote.cc index 4dadeeba..51f1d98d 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -174,9 +174,16 @@ void RemoteUI::draw(const DisplayBuffer& display_buffer, write(msg, status_line); } +static const Key::Modifiers resize_modifier = (Key::Modifiers)0x80; + Key RemoteUI::get_key() { Key key = read(m_socket); + if (key.modifiers == resize_modifier) + { + m_dimensions = { (int)(key.key >> 16), (int)(key.key & 0xFFFF) }; + return Key::Invalid; + } return key; } @@ -185,6 +192,15 @@ DisplayCoord RemoteUI::dimensions() return m_dimensions; } +RemoteClient::RemoteClient(int socket, UserInterface* ui) + : m_socket(socket), m_ui(ui) +{ + DisplayCoord size = ui->dimensions(); + Key key{ resize_modifier, (Codepoint)(((int)size.line << 16) | (int)size.column) }; + Message msg(socket); + write(msg, key); +} + void RemoteClient::process_next_message() { RemoteUIMsg msg = read(m_socket); diff --git a/src/remote.hh b/src/remote.hh index 0717e7ed..a20d09ff 100644 --- a/src/remote.hh +++ b/src/remote.hh @@ -21,7 +21,6 @@ public: const String& status_line) override; Key get_key() override; DisplayCoord dimensions() override; - void set_dimensions(const DisplayCoord dim) { m_dimensions = dim; } private: int m_socket; @@ -31,7 +30,7 @@ private: class RemoteClient { public: - RemoteClient(int socket, UserInterface* ui) : m_ui(ui), m_socket(socket) {} + RemoteClient(int socket, UserInterface* ui); void process_next_message(); void write_next_key();