Handle all available keys when a RemoteClient input is available

We were just treating the next key. Which led to <esc> byte
remaining after suspend, that led that <esc> being interpretted
as <alt> when the following key got available.

Fixes #739
This commit is contained in:
Maxime Coste 2016-10-06 23:47:44 +01:00
parent 006be63a32
commit f904402486
2 changed files with 8 additions and 7 deletions

View File

@ -518,7 +518,7 @@ RemoteClient::RemoteClient(StringView session, std::unique_ptr<UserInterface>&&
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<UserInterface>&&
}});
}
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)

View File

@ -37,7 +37,7 @@ public:
const EnvVarMap& env_vars, StringView init_command);
private:
void write_next_key();
void send_available_keys();
std::unique_ptr<UserInterface> m_ui;
std::unique_ptr<FDWatcher> m_socket_watcher;