diff --git a/src/remote.cc b/src/remote.cc index 427f52b2..9de0a13a 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -518,7 +518,7 @@ RemoteClient::RemoteClient(StringView session, std::unique_ptr&& msg.write(env_vars); } - m_ui->set_input_callback([this](EventMode){ write_next_key(); }); + m_ui->set_input_callback([this](EventMode){ send_available_keys(); }); MsgReader reader; m_socket_watcher.reset(new FDWatcher{sock, [this, reader](FDWatcher& watcher, EventMode) mutable { @@ -589,12 +589,13 @@ RemoteClient::RemoteClient(StringView session, std::unique_ptr&& }}); } -void RemoteClient::write_next_key() +void RemoteClient::send_available_keys() { - MsgWriter msg(m_socket_watcher->fd(), MessageType::Key); - // do that before checking dimensions as get_key may - // handle a resize event. - msg.write(m_ui->get_key()); + while (m_ui->is_key_available()) + { + MsgWriter msg(m_socket_watcher->fd(), MessageType::Key); + msg.write(m_ui->get_key()); + } } void send_command(StringView session, StringView command) diff --git a/src/remote.hh b/src/remote.hh index 5740def9..5537e3fd 100644 --- a/src/remote.hh +++ b/src/remote.hh @@ -37,7 +37,7 @@ public: const EnvVarMap& env_vars, StringView init_command); private: - void write_next_key(); + void send_available_keys(); std::unique_ptr m_ui; std::unique_ptr m_socket_watcher;