Переглянути джерело

ui: keep current cursor with QemuConsole

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 <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Marc-André Lureau 2 роки тому
батько
коміт
385ac97f8f
4 змінених файлів з 11 додано та 6 видалено
  1. 1 0
      include/ui/console.h
  2. 8 0
      ui/console.c
  3. 2 5
      ui/vnc.c
  4. 0 1
      ui/vnc.h

+ 1 - 0
include/ui/console.h

@@ -459,6 +459,7 @@ QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head);
 QemuConsole *qemu_console_lookup_by_device_name(const char *device_id,
 QemuConsole *qemu_console_lookup_by_device_name(const char *device_id,
                                                 uint32_t head, Error **errp);
                                                 uint32_t head, Error **errp);
 QemuConsole *qemu_console_lookup_unused(void);
 QemuConsole *qemu_console_lookup_unused(void);
+QEMUCursor *qemu_console_get_cursor(QemuConsole *con);
 bool qemu_console_is_visible(QemuConsole *con);
 bool qemu_console_is_visible(QemuConsole *con);
 bool qemu_console_is_graphic(QemuConsole *con);
 bool qemu_console_is_graphic(QemuConsole *con);
 bool qemu_console_is_fixedsize(QemuConsole *con);
 bool qemu_console_is_fixedsize(QemuConsole *con);

+ 8 - 0
ui/console.c

@@ -94,6 +94,7 @@ struct QemuConsole {
     uint32_t head;
     uint32_t head;
     QemuUIInfo ui_info;
     QemuUIInfo ui_info;
     QEMUTimer *ui_timer;
     QEMUTimer *ui_timer;
+    QEMUCursor *cursor;
     const GraphicHwOps *hw_ops;
     const GraphicHwOps *hw_ops;
     void *hw;
     void *hw;
 
 
@@ -1923,6 +1924,8 @@ void dpy_cursor_define(QemuConsole *con, QEMUCursor *cursor)
     DisplayState *s = con->ds;
     DisplayState *s = con->ds;
     DisplayChangeListener *dcl;
     DisplayChangeListener *dcl;
 
 
+    cursor_unref(con->cursor);
+    con->cursor = cursor_ref(cursor);
     if (!qemu_console_is_visible(con)) {
     if (!qemu_console_is_visible(con)) {
         return;
         return;
     }
     }
@@ -2288,6 +2291,11 @@ QemuConsole *qemu_console_lookup_unused(void)
     return NULL;
     return NULL;
 }
 }
 
 
+QEMUCursor *qemu_console_get_cursor(QemuConsole *con)
+{
+    return con->cursor;
+}
+
 bool qemu_console_is_visible(QemuConsole *con)
 bool qemu_console_is_visible(QemuConsole *con)
 {
 {
     return (con == active_console) || (con->dcls > 0);
     return (con == active_console) || (con->dcls > 0);

+ 2 - 5
ui/vnc.c

@@ -988,10 +988,10 @@ static void vnc_mouse_set(DisplayChangeListener *dcl,
 
 
 static int vnc_cursor_define(VncState *vs)
 static int vnc_cursor_define(VncState *vs)
 {
 {
-    QEMUCursor *c = vs->vd->cursor;
+    QEMUCursor *c = qemu_console_get_cursor(vs->vd->dcl.con);
     int isize;
     int isize;
 
 
-    if (!vs->vd->cursor) {
+    if (!c) {
         return -1;
         return -1;
     }
     }
 
 
@@ -1029,10 +1029,7 @@ static void vnc_dpy_cursor_define(DisplayChangeListener *dcl,
     VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
     VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
     VncState *vs;
     VncState *vs;
 
 
-    cursor_unref(vd->cursor);
     g_free(vd->cursor_mask);
     g_free(vd->cursor_mask);
-
-    vd->cursor = cursor_ref(vd->cursor);
     vd->cursor_msize = cursor_get_mono_bpl(c) * c->height;
     vd->cursor_msize = cursor_get_mono_bpl(c) * c->height;
     vd->cursor_mask = g_malloc0(vd->cursor_msize);
     vd->cursor_mask = g_malloc0(vd->cursor_msize);
     cursor_get_mono_mask(c, 0, vd->cursor_mask);
     cursor_get_mono_mask(c, 0, vd->cursor_mask);

+ 0 - 1
ui/vnc.h

@@ -159,7 +159,6 @@ struct VncDisplay
     QKbdState *kbd;
     QKbdState *kbd;
     QemuMutex mutex;
     QemuMutex mutex;
 
 
-    QEMUCursor *cursor;
     int cursor_msize;
     int cursor_msize;
     uint8_t *cursor_mask;
     uint8_t *cursor_mask;