send actual dimensions of remote client at connection
This commit is contained in:
parent
0735c69a92
commit
1c3f6c314f
|
@ -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();
|
||||
|
|
|
@ -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<Key>(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<RemoteUIMsg>(m_socket);
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user