send actual dimensions of remote client at connection

This commit is contained in:
Maxime Coste 2012-10-25 12:51:01 +02:00
parent 0735c69a92
commit 1c3f6c314f
3 changed files with 17 additions and 3 deletions

View File

@ -567,7 +567,6 @@ void setup_server()
auto& buffer = *BufferManager::instance().begin(); auto& buffer = *BufferManager::instance().begin();
RemoteUI* ui = new RemoteUI{sock}; RemoteUI* ui = new RemoteUI{sock};
ui->set_dimensions(DisplayCoord(24, 80));
Client client{ui, *buffer->get_or_create_window()}; Client client{ui, *buffer->get_or_create_window()};
InputHandler* input_handler = client.input_handler.get(); InputHandler* input_handler = client.input_handler.get();
Context* context = client.context.get(); Context* context = client.context.get();

View File

@ -174,9 +174,16 @@ void RemoteUI::draw(const DisplayBuffer& display_buffer,
write(msg, status_line); write(msg, status_line);
} }
static const Key::Modifiers resize_modifier = (Key::Modifiers)0x80;
Key RemoteUI::get_key() Key RemoteUI::get_key()
{ {
Key key = read<Key>(m_socket); Key key = read<Key>(m_socket);
if (key.modifiers == resize_modifier)
{
m_dimensions = { (int)(key.key >> 16), (int)(key.key & 0xFFFF) };
return Key::Invalid;
}
return key; return key;
} }
@ -185,6 +192,15 @@ DisplayCoord RemoteUI::dimensions()
return m_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() void RemoteClient::process_next_message()
{ {
RemoteUIMsg msg = read<RemoteUIMsg>(m_socket); RemoteUIMsg msg = read<RemoteUIMsg>(m_socket);

View File

@ -21,7 +21,6 @@ public:
const String& status_line) override; const String& status_line) override;
Key get_key() override; Key get_key() override;
DisplayCoord dimensions() override; DisplayCoord dimensions() override;
void set_dimensions(const DisplayCoord dim) { m_dimensions = dim; }
private: private:
int m_socket; int m_socket;
@ -31,7 +30,7 @@ private:
class RemoteClient class RemoteClient
{ {
public: public:
RemoteClient(int socket, UserInterface* ui) : m_ui(ui), m_socket(socket) {} RemoteClient(int socket, UserInterface* ui);
void process_next_message(); void process_next_message();
void write_next_key(); void write_next_key();