From 385ac97f8fad0e6980c5dfea71132d5ecfb16608 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Jan 2023 15:24:40 +0400 Subject: ui: keep current cursor with QemuConsole MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Keeping the current cursor around is useful, not only for VNC, but for other displays. Let's move it down, see the following patches for other usages. Signed-off-by: Marc-André Lureau Reviewed-by: Daniel P. Berrangé --- ui/console.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ui/console.c') diff --git a/ui/console.c b/ui/console.c index 98b701f5a3..0dccbdd4be 100644 --- a/ui/console.c +++ b/ui/console.c @@ -94,6 +94,7 @@ struct QemuConsole { uint32_t head; QemuUIInfo ui_info; QEMUTimer *ui_timer; + QEMUCursor *cursor; const GraphicHwOps *hw_ops; void *hw; @@ -1923,6 +1924,8 @@ void dpy_cursor_define(QemuConsole *con, QEMUCursor *cursor) DisplayState *s = con->ds; DisplayChangeListener *dcl; + cursor_unref(con->cursor); + con->cursor = cursor_ref(cursor); if (!qemu_console_is_visible(con)) { return; } @@ -2288,6 +2291,11 @@ QemuConsole *qemu_console_lookup_unused(void) return NULL; } +QEMUCursor *qemu_console_get_cursor(QemuConsole *con) +{ + return con->cursor; +} + bool qemu_console_is_visible(QemuConsole *con) { return (con == active_console) || (con->dcls > 0); -- cgit 1.4.1 From de00b60db42dd88ce9aa7c77f5125a8a56308706 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Jan 2023 15:34:45 +0400 Subject: ui: set cursor upon listener registration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau Reviewed-by: Daniel P. Berrangé --- ui/console.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ui/console.c') diff --git a/ui/console.c b/ui/console.c index 0dccbdd4be..35f8274aab 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1662,6 +1662,9 @@ void register_displaychangelistener(DisplayChangeListener *dcl) con = active_console; } displaychangelistener_display_console(dcl, con, dcl->con ? &error_fatal : NULL); + if (con && con->cursor && dcl->ops->dpy_cursor_define) { + dcl->ops->dpy_cursor_define(dcl, con->cursor); + } text_console_update_cursor(NULL); } -- cgit 1.4.1 From 6effaa16ac9846e7d6197ee54a0551fba61aecd7 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Jan 2023 15:40:58 +0400 Subject: ui: set cursor position upon listener registration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau Reviewed-by: Daniel P. Berrangé --- ui/console.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ui/console.c') diff --git a/ui/console.c b/ui/console.c index 35f8274aab..f3783021e5 100644 --- a/ui/console.c +++ b/ui/console.c @@ -95,6 +95,7 @@ struct QemuConsole { QemuUIInfo ui_info; QEMUTimer *ui_timer; QEMUCursor *cursor; + int cursor_x, cursor_y, cursor_on; const GraphicHwOps *hw_ops; void *hw; @@ -1665,6 +1666,9 @@ void register_displaychangelistener(DisplayChangeListener *dcl) if (con && con->cursor && dcl->ops->dpy_cursor_define) { dcl->ops->dpy_cursor_define(dcl, con->cursor); } + if (con && dcl->ops->dpy_mouse_set) { + dcl->ops->dpy_mouse_set(dcl, con->cursor_x, con->cursor_y, con->cursor_on); + } text_console_update_cursor(NULL); } @@ -1909,6 +1913,9 @@ void dpy_mouse_set(QemuConsole *con, int x, int y, int on) DisplayState *s = con->ds; DisplayChangeListener *dcl; + con->cursor_x = x; + con->cursor_y = y; + con->cursor_on = on; if (!qemu_console_is_visible(con)) { return; } -- cgit 1.4.1