From: Szymon Lukasz <[email protected]> These fields should be interpreted as the size of the terminal connected to a given chardev.
Signed-off-by: Szymon Lukasz <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]> [Filip: CharBackend -> CharFrontend] Signed-off-by: Filip Hejsek <[email protected]> --- chardev/char-fe.c | 13 +++++++++++++ include/chardev/char-fe.h | 10 ++++++++++ include/chardev/char.h | 1 + 3 files changed, 24 insertions(+) diff --git a/chardev/char-fe.c b/chardev/char-fe.c index 34b83fc1c4..a3bb1071b3 100644 --- a/chardev/char-fe.c +++ b/chardev/char-fe.c @@ -329,6 +329,19 @@ void qemu_chr_fe_set_echo(CharFrontend *c, bool echo) } } +void qemu_chr_fe_get_winsize(CharFrontend *c, uint16_t *cols, uint16_t *rows) +{ + Chardev *chr = c->chr; + + if (chr) { + *cols = chr->cols; + *rows = chr->rows; + } else { + *cols = 0; + *rows = 0; + } +} + void qemu_chr_fe_set_open(CharFrontend *c, bool is_open) { Chardev *chr = c->chr; diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h index 5f8a6df17d..53b8d2a1dc 100644 --- a/include/chardev/char-fe.h +++ b/include/chardev/char-fe.h @@ -157,6 +157,16 @@ int qemu_chr_fe_wait_connected(CharFrontend *c, Error **errp); */ void qemu_chr_fe_set_echo(CharFrontend *c, bool echo); +/** + * qemu_chr_fe_get_winsize: + * @cols: the address for storing columns + * @rows: the address for storing rows + * + * Get the size of the terminal connected to the chardev backend. + * Returns *cols = *rows = 0, if no associated Chardev. + */ +void qemu_chr_fe_get_winsize(CharFrontend *c, uint16_t *cols, uint16_t *rows); + /** * qemu_chr_fe_set_open: * @c: a CharFrontend diff --git a/include/chardev/char.h b/include/chardev/char.h index 192cad67d4..237238e5a0 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -65,6 +65,7 @@ struct Chardev { char *filename; int logfd; int be_open; + uint16_t cols, rows; /* used to coordinate the chardev-change special-case: */ bool handover_yank_instance; GSource *gsource; -- 2.52.0
