Skip to contentSkip to conversation

ui: dbus & misc fixes

PATCH Superseded [email protected] 1 participant 12 messages Jan 30, 2023 Arm/Amlogic Meson SoC support

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover ui: dbus & misc fixes

From: Marc-André Lureau <[email protected]>

Hi,

Here is a collection of fixes for UI related-stuff. Mostly it's improving/fixing -display dbus.

Thanks for the reviews!

Marc-André Lureau (11):
ui/dbus: unregister clipboard on connection close audio/dbus: there are no sender for p2p mode
ui/dbus: set mouse is-absolute during console creation ui/dbus: update the display when switching surface
meson: ensure dbus-display generated code is built before other units
ui: rename cursor_{put->unref}
ui: rename cursor_{get->ref}, return it
ui: keep current cursor with QemuConsole
ui: set cursor upon listener registration
ui: set cursor position upon listener registration
ui/sdl: get the GL context from the window

 audio/audio_int.h       |  2 +-
 include/ui/console.h    |  5 +++--
 ui/vnc.h                |  1 -
 audio/dbusaudio.c       |  6 ++++--
 hw/display/qxl-render.c |  4 ++--
 hw/display/qxl.c        |  2 +-
 hw/display/vmware_vga.c |  4 ++--
 ui/console.c            | 18 ++++++++++++++++++
 ui/cursor.c             |  5 +++--
 ui/dbus-clipboard.c     | 18 +++++++-----------
 ui/dbus-console.c       | 13 ++++++++++---
 ui/dbus-listener.c      |  7 ++++---
 ui/dbus.c               |  2 +-
 ui/sdl2.c               |  2 +-
 ui/spice-display.c      |  8 ++++----
 ui/vnc.c                |  8 ++------
 ui/meson.build          |  6 ++++--
 17 files changed, 67 insertions(+), 44 deletions(-)
Signature · 1 line
2.39.1
#1 lore raw

PATCH 1/11 ui/dbus: unregister clipboard on connection close

From: Marc-André Lureau <[email protected]>

Fixes unregistration with p2p connections, since they don't have an associated name owner.

---
 ui/dbus-clipboard.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
ui/dbus-clipboard.c +7 -11
index 5843d26cd2..d78f9db18f 100644
@@ -203,15 +203,6 @@ dbus_clipboard_unregister_proxy(DBusDisplay *dpy)
     g_clear_object(&dpy->clipboard_proxy);
 }
 
-static void
-dbus_on_clipboard_proxy_name_owner_changed(
-    DBusDisplay *dpy,
-    GObject *object,
-    GParamSpec *pspec)
-{
-    dbus_clipboard_unregister_proxy(dpy);
-}
-
 static gboolean
 dbus_clipboard_register(
     DBusDisplay *dpy,
@@ -219,6 +210,7 @@ dbus_clipboard_register(
 {
     g_autoptr(GError) err = NULL;
     const char *name = NULL;
+    GDBusConnection *connection = g_dbus_method_invocation_get_connection(invocation);
 
     if (dpy->clipboard_proxy) {
         g_dbus_method_invocation_return_error(
@@ -231,7 +223,7 @@ dbus_clipboard_register(
 
     dpy->clipboard_proxy =
         qemu_dbus_display1_clipboard_proxy_new_sync(
-            g_dbus_method_invocation_get_connection(invocation),
+            connection,
             G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
             g_dbus_method_invocation_get_sender(invocation),
             "/org/qemu/Display1/Clipboard",
@@ -251,7 +243,11 @@ dbus_clipboard_register(
 
     g_object_connect(dpy->clipboard_proxy,
                      "swapped-signal::notify::g-name-owner",
-                     dbus_on_clipboard_proxy_name_owner_changed, dpy,
+                     dbus_clipboard_unregister_proxy, dpy,
+                     NULL);
+    g_object_connect(connection,
+                     "swapped-signal::closed",
+                     dbus_clipboard_unregister_proxy, dpy,
                      NULL);
     qemu_clipboard_reset_serial();
 
Signature · 1 line
2.39.1
#2 lore raw

PATCH 2/11 audio/dbus: there are no sender for p2p mode

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

---
 audio/audio_int.h | 2 +-
 audio/dbusaudio.c | 6 ++++--
 ui/dbus.c         | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)
audio/audio_int.h +1 -1
index e87ce014a0..38864bfbbd 100644
@@ -145,7 +145,7 @@ struct audio_driver {
     void *(*init) (Audiodev *);
     void (*fini) (void *);
 #ifdef CONFIG_GIO
-    void (*set_dbus_server) (AudioState *s, GDBusObjectManagerServer *manager);
+    void (*set_dbus_server) (AudioState *s, GDBusObjectManagerServer *manager, bool p2p);
 #endif
     struct audio_pcm_ops *pcm_ops;
     int can_be_default;
audio/dbusaudio.c +4 -2
index 722df0355e..9032dda49c 100644
@@ -43,6 +43,7 @@
 
 typedef struct DBusAudio {
     GDBusObjectManagerServer *server;
+    bool p2p;
     GDBusObjectSkeleton *audio;
     QemuDBusDisplay1Audio *iface;
     GHashTable *out_listeners;
@@ -448,7 +449,7 @@ dbus_audio_register_listener(AudioState *s,
                              bool out)
 {
     DBusAudio *da = s->drv_opaque;
-    const char *sender = g_dbus_method_invocation_get_sender(invocation);
+    const char *sender = da->p2p ? "p2p" : g_dbus_method_invocation_get_sender(invocation);
     g_autoptr(GDBusConnection) listener_conn = NULL;
     g_autoptr(GError) err = NULL;
     g_autoptr(GSocket) socket = NULL;
@@ -591,7 +592,7 @@ dbus_audio_register_in_listener(AudioState *s,
 }
 
 static void
-dbus_audio_set_server(AudioState *s, GDBusObjectManagerServer *server)
+dbus_audio_set_server(AudioState *s, GDBusObjectManagerServer *server, bool p2p)
 {
     DBusAudio *da = s->drv_opaque;
 
@@ -599,6 +600,7 @@ dbus_audio_set_server(AudioState *s, GDBusObjectManagerServer *server)
     g_assert(!da->server);
 
     da->server = g_object_ref(server);
+    da->p2p = p2p;
 
     da->audio = g_dbus_object_skeleton_new(DBUS_DISPLAY1_AUDIO_PATH);
     da->iface = qemu_dbus_display1_audio_skeleton_new();
ui/dbus.c +1 -1
index 32d88dc94a..0a9e2f4611 100644
@@ -219,7 +219,7 @@ dbus_display_complete(UserCreatable *uc, Error **errp)
                        dd->audiodev);
             return;
         }
-        audio_state->drv->set_dbus_server(audio_state, dd->server);
+        audio_state->drv->set_dbus_server(audio_state, dd->server, dd->p2p);
     }
 
     consoles = g_array_new(FALSE, FALSE, sizeof(guint32));
Signature · 1 line
2.39.1
#3 lore raw

PATCH 3/11 ui/dbus: set mouse is-absolute during console creation

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

---
 ui/dbus-console.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
ui/dbus-console.c +10 -3
index 898a4ac8a5..241797b7e9 100644
@@ -410,15 +410,21 @@ dbus_mouse_release(DBusDisplayConsole *ddc,
     return DBUS_METHOD_INVOCATION_HANDLED;
 }
 
+static void
+dbus_mouse_update_is_absolute(DBusDisplayConsole *ddc)
+{
+    g_object_set(ddc->iface_mouse,
+                 "is-absolute", qemu_input_is_absolute(),
+                 NULL);
+}
+
 static void
 dbus_mouse_mode_change(Notifier *notify, void *data)
 {
     DBusDisplayConsole *ddc =
         container_of(notify, DBusDisplayConsole, mouse_mode_notifier);
 
-    g_object_set(ddc->iface_mouse,
-                 "is-absolute", qemu_input_is_absolute(),
-                 NULL);
+    dbus_mouse_update_is_absolute(ddc);
 }
 
 int dbus_display_console_get_index(DBusDisplayConsole *ddc)
@@ -491,6 +497,7 @@ dbus_display_console_new(DBusDisplay *display, QemuConsole *con)
     register_displaychangelistener(&ddc->dcl);
     ddc->mouse_mode_notifier.notify = dbus_mouse_mode_change;
     qemu_add_mouse_mode_change_notifier(&ddc->mouse_mode_notifier);
+    dbus_mouse_update_is_absolute(ddc);
 
     return ddc;
 }
Signature · 1 line
2.39.1
#4 lore raw

PATCH 4/11 ui/dbus: update the display when switching surface

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

This seems to be the expected behaviour.

---
 ui/dbus-listener.c | 2 ++
 1 file changed, 2 insertions(+)
ui/dbus-listener.c +2 -0
index f9fc8eda51..620d9450cc 100644
@@ -321,6 +321,8 @@ static void dbus_gfx_switch(DisplayChangeListener *dcl,
         /* why not call disable instead? */
         return;
     }
+
+    dbus_gfx_update(dcl, 0, 0, surface_width(ddl->ds), surface_height(ddl->ds));
 }
 
 static void dbus_mouse_set(DisplayChangeListener *dcl,
Signature · 1 line
2.39.1
#5 lore raw

PATCH 5/11 meson: ensure dbus-display generated code is built before other units

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

It's simply by luck that dbus-display header is built first before the other units using it.

With sourceset, I can't find an easier way out than declaring an extra dependency for dbus-display1 generate code.

---
 ui/meson.build | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
ui/meson.build +4 -2
index 612ea2325b..0b2d0d21d1 100644
@@ -83,7 +83,9 @@ if dbus_display
                                           '--interface-prefix', 'org.qemu.',
                                           '--c-namespace', 'QemuDBus',
                                           '--generate-c-code', '@BASENAME@'])
-  dbus_ss.add(when: [gio, pixman, opengl, gbm],
+  dbus_display1_lib = static_library('dbus-display1', dbus_display1, dependencies: gio)
+  dbus_display1_dep = declare_dependency(link_with: dbus_display1_lib, include_directories: include_directories('.'))
+  dbus_ss.add(when: [gio, pixman, opengl, gbm, dbus_display1_dep],
               if_true: [files(
                 'dbus-chardev.c',
                 'dbus-clipboard.c',
@@ -91,7 +93,7 @@ if dbus_display
                 'dbus-error.c',
                 'dbus-listener.c',
                 'dbus.c',
-              ), dbus_display1])
+              )])
   ui_modules += {'dbus' : dbus_ss}
 endif
 
Signature · 1 line
2.39.1
#6 lore raw

PATCH 6/11 ui: rename cursor_{put->unref}

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

The naming is more conventional in QEMU.

---
 include/ui/console.h    | 2 +-
 hw/display/qxl-render.c | 4 ++--
 hw/display/qxl.c        | 2 +-
 hw/display/vmware_vga.c | 4 ++--
 ui/cursor.c             | 2 +-
 ui/dbus-listener.c      | 2 +-
 ui/spice-display.c      | 4 ++--
 ui/vnc.c                | 2 +-
 8 files changed, 11 insertions(+), 11 deletions(-)
include/ui/console.h +1 -1
index 8e6cf782a1..ec28402a4f 100644
@@ -153,7 +153,7 @@ typedef struct QEMUCursor {
 
 QEMUCursor *cursor_alloc(int width, int height);
 void cursor_get(QEMUCursor *c);
-void cursor_put(QEMUCursor *c);
+void cursor_unref(QEMUCursor *c);
 QEMUCursor *cursor_builtin_hidden(void);
 QEMUCursor *cursor_builtin_left_ptr(void);
 void cursor_print_ascii_art(QEMUCursor *c, const char *prefix);
hw/display/qxl-render.c +2 -2
index fcfd40c3ac..ec99ec887a 100644
@@ -290,7 +290,7 @@ static QEMUCursor *qxl_cursor(PCIQXLDevice *qxl, QXLCursor *cursor,
     return c;
 
 fail:
-    cursor_put(c);
+    cursor_unref(c);
     return NULL;
 }
 
@@ -336,7 +336,7 @@ int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)
         }
         qemu_mutex_lock(&qxl->ssd.lock);
         if (qxl->ssd.cursor) {
-            cursor_put(qxl->ssd.cursor);
+            cursor_unref(qxl->ssd.cursor);
         }
         qxl->ssd.cursor = c;
         qxl->ssd.mouse_x = cmd->u.set.position.x;
hw/display/qxl.c +1 -1
index ec712d3ca2..80ce1e9a93 100644
@@ -299,7 +299,7 @@ void qxl_spice_reset_cursor(PCIQXLDevice *qxl)
     qxl->guest_cursor = 0;
     qemu_mutex_unlock(&qxl->track_lock);
     if (qxl->ssd.cursor) {
-        cursor_put(qxl->ssd.cursor);
+        cursor_unref(qxl->ssd.cursor);
     }
     qxl->ssd.cursor = cursor_builtin_hidden();
 }
hw/display/vmware_vga.c +2 -2
index 59ae7f74b8..09591fbd39 100644
@@ -550,12 +550,12 @@ static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
     default:
         fprintf(stderr, "%s: unhandled bpp %d, using fallback cursor\n",
                 __func__, c->bpp);
-        cursor_put(qc);
+        cursor_unref(qc);
         qc = cursor_builtin_left_ptr();
     }
 
     dpy_cursor_define(s->vga.con, qc);
-    cursor_put(qc);
+    cursor_unref(qc);
 }
 #endif
 
ui/cursor.c +1 -1
index 835f0802f9..31b09bf058 100644
@@ -111,7 +111,7 @@ void cursor_get(QEMUCursor *c)
     c->refcount++;
 }
 
-void cursor_put(QEMUCursor *c)
+void cursor_unref(QEMUCursor *c)
 {
     if (c == NULL)
         return;
ui/dbus-listener.c +1 -1
index 620d9450cc..cc1054caff 100644
@@ -346,7 +346,7 @@ static void dbus_cursor_define(DisplayChangeListener *dcl,
         c->data,
         c->width * c->height * 4,
         TRUE,
-        (GDestroyNotify)cursor_put,
+        (GDestroyNotify)cursor_unref,
         c);
 
     qemu_dbus_display1_listener_call_cursor_define(
ui/spice-display.c +2 -2
index 0616a6982f..161868735b 100644
@@ -463,7 +463,7 @@ void qemu_spice_cursor_refresh_bh(void *opaque)
         qemu_mutex_unlock(&ssd->lock);
         dpy_cursor_define(ssd->dcl.con, c);
         qemu_mutex_lock(&ssd->lock);
-        cursor_put(c);
+        cursor_unref(c);
     }
 
     if (ssd->mouse_x != -1 && ssd->mouse_y != -1) {
@@ -765,7 +765,7 @@ static void display_mouse_define(DisplayChangeListener *dcl,
 
     qemu_mutex_lock(&ssd->lock);
     cursor_get(c);
-    cursor_put(ssd->cursor);
+    cursor_unref(ssd->cursor);
     ssd->cursor = c;
     ssd->hot_x = c->hot_x;
     ssd->hot_y = c->hot_y;
ui/vnc.c +1 -1
index d9eacad759..0bdcc3dfce 100644
@@ -1029,7 +1029,7 @@ static void vnc_dpy_cursor_define(DisplayChangeListener *dcl,
     VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
     VncState *vs;
 
-    cursor_put(vd->cursor);
+    cursor_unref(vd->cursor);
     g_free(vd->cursor_mask);
 
     vd->cursor = c;
Signature · 1 line
2.39.1
#7 lore raw

PATCH 7/11 ui: rename cursor_{get->ref}, return it

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

The naming is more conventional in QEMU code, and allows to simplify some code.

---
 include/ui/console.h | 2 +-
 ui/cursor.c          | 3 ++-
 ui/dbus-listener.c   | 3 +--
 ui/spice-display.c   | 4 ++--
 ui/vnc.c             | 3 +--
 5 files changed, 7 insertions(+), 8 deletions(-)
include/ui/console.h +1 -1
index ec28402a4f..3afb5c73a8 100644
@@ -152,7 +152,7 @@ typedef struct QEMUCursor {
 } QEMUCursor;
 
 QEMUCursor *cursor_alloc(int width, int height);
-void cursor_get(QEMUCursor *c);
+QEMUCursor *cursor_ref(QEMUCursor *c);
 void cursor_unref(QEMUCursor *c);
 QEMUCursor *cursor_builtin_hidden(void);
 QEMUCursor *cursor_builtin_left_ptr(void);
ui/cursor.c +2 -1
index 31b09bf058..6fe67990e2 100644
@@ -106,9 +106,10 @@ QEMUCursor *cursor_alloc(int width, int height)
     return c;
 }
 
-void cursor_get(QEMUCursor *c)
+QEMUCursor *cursor_ref(QEMUCursor *c)
 {
     c->refcount++;
+    return c;
 }
 
 void cursor_unref(QEMUCursor *c)
ui/dbus-listener.c +1 -2
index cc1054caff..f195d8df57 100644
@@ -340,14 +340,13 @@ static void dbus_cursor_define(DisplayChangeListener *dcl,
     DBusDisplayListener *ddl = container_of(dcl, DBusDisplayListener, dcl);
     GVariant *v_data = NULL;
 
-    cursor_get(c);
     v_data = g_variant_new_from_data(
         G_VARIANT_TYPE("ay"),
         c->data,
         c->width * c->height * 4,
         TRUE,
         (GDestroyNotify)cursor_unref,
-        c);
+        cursor_ref(c));
 
     qemu_dbus_display1_listener_call_cursor_define(
         ddl->proxy,
ui/spice-display.c +2 -2
index 161868735b..918cadecf1 100644
@@ -459,7 +459,7 @@ void qemu_spice_cursor_refresh_bh(void *opaque)
     if (ssd->cursor) {
         QEMUCursor *c = ssd->cursor;
         assert(ssd->dcl.con);
-        cursor_get(c);
+        cursor_ref(c);
         qemu_mutex_unlock(&ssd->lock);
         dpy_cursor_define(ssd->dcl.con, c);
         qemu_mutex_lock(&ssd->lock);
@@ -764,7 +764,7 @@ static void display_mouse_define(DisplayChangeListener *dcl,
     SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);
 
     qemu_mutex_lock(&ssd->lock);
-    cursor_get(c);
+    cursor_ref(c);
     cursor_unref(ssd->cursor);
     ssd->cursor = c;
     ssd->hot_x = c->hot_x;
ui/vnc.c +1 -2
index 0bdcc3dfce..8aec5d751e 100644
@@ -1032,8 +1032,7 @@ static void vnc_dpy_cursor_define(DisplayChangeListener *dcl,
     cursor_unref(vd->cursor);
     g_free(vd->cursor_mask);
 
-    vd->cursor = c;
-    cursor_get(vd->cursor);
+    vd->cursor = cursor_ref(vd->cursor);
     vd->cursor_msize = cursor_get_mono_bpl(c) * c->height;
     vd->cursor_mask = g_malloc0(vd->cursor_msize);
     cursor_get_mono_mask(c, 0, vd->cursor_mask);
Signature · 1 line
2.39.1
#8 lore raw

PATCH 8/11 ui: keep current cursor with QemuConsole

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

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.

---
 include/ui/console.h | 1 +
 ui/vnc.h             | 1 -
 ui/console.c         | 8 ++++++++
 ui/vnc.c             | 7 ++-----
 4 files changed, 11 insertions(+), 6 deletions(-)
include/ui/console.h +1 -0
index 3afb5c73a8..e87284da22 100644
@@ -460,6 +460,7 @@ QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head);
 QemuConsole *qemu_console_lookup_by_device_name(const char *device_id,
                                                 uint32_t head, Error **errp);
 QemuConsole *qemu_console_lookup_unused(void);
+QEMUCursor *qemu_console_get_cursor(QemuConsole *con);
 bool qemu_console_is_visible(QemuConsole *con);
 bool qemu_console_is_graphic(QemuConsole *con);
 bool qemu_console_is_fixedsize(QemuConsole *con);
ui/vnc.h +0 -1
index a60fb13115..757fa83044 100644
@@ -159,7 +159,6 @@ struct VncDisplay
     QKbdState *kbd;
     QemuMutex mutex;
 
-    QEMUCursor *cursor;
     int cursor_msize;
     uint8_t *cursor_mask;
 
ui/console.c +8 -0
index ab43561fe1..4e88941165 100644
@@ -93,6 +93,7 @@ struct QemuConsole {
     uint32_t head;
     QemuUIInfo ui_info;
     QEMUTimer *ui_timer;
+    QEMUCursor *cursor;
     const GraphicHwOps *hw_ops;
     void *hw;
 
@@ -1922,6 +1923,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;
     }
@@ -2287,6 +2290,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);
ui/vnc.c +2 -5
index 8aec5d751e..bbd8b6baae 100644
@@ -988,10 +988,10 @@ static void vnc_mouse_set(DisplayChangeListener *dcl,
 
 static int vnc_cursor_define(VncState *vs)
 {
-    QEMUCursor *c = vs->vd->cursor;
+    QEMUCursor *c = qemu_console_get_cursor(vs->vd->dcl.con);
     int isize;
 
-    if (!vs->vd->cursor) {
+    if (!c) {
         return -1;
     }
 
@@ -1029,10 +1029,7 @@ static void vnc_dpy_cursor_define(DisplayChangeListener *dcl,
     VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
     VncState *vs;
 
-    cursor_unref(vd->cursor);
     g_free(vd->cursor_mask);
-
-    vd->cursor = cursor_ref(vd->cursor);
     vd->cursor_msize = cursor_get_mono_bpl(c) * c->height;
     vd->cursor_mask = g_malloc0(vd->cursor_msize);
     cursor_get_mono_mask(c, 0, vd->cursor_mask);
Signature · 1 line
2.39.1
#9 lore raw

PATCH 9/11 ui: set cursor upon listener registration

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

---
 ui/console.c | 3 +++
 1 file changed, 3 insertions(+)
ui/console.c +3 -0
index 4e88941165..3fc8bf2fbc 100644
@@ -1661,6 +1661,9 @@ void register_displaychangelistener(DisplayChangeListener *dcl)
         con = active_console;
     }
     displaychangelistener_display_console(dcl, con, dcl->con ? &error_fatal : NULL);
+    if (con->cursor && dcl->ops->dpy_cursor_define) {
+        dcl->ops->dpy_cursor_define(dcl, con->cursor);
+    }
     text_console_update_cursor(NULL);
 }
 
Signature · 1 line
2.39.1
#10 lore raw

PATCH 10/11 ui: set cursor position upon listener registration

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

---
 ui/console.c | 7 +++++++
 1 file changed, 7 insertions(+)
ui/console.c +7 -0
index 3fc8bf2fbc..6f87158c2d 100644
@@ -94,6 +94,7 @@ struct QemuConsole {
     QemuUIInfo ui_info;
     QEMUTimer *ui_timer;
     QEMUCursor *cursor;
+    int cursor_x, cursor_y, cursor_on;
     const GraphicHwOps *hw_ops;
     void *hw;
 
@@ -1664,6 +1665,9 @@ void register_displaychangelistener(DisplayChangeListener *dcl)
     if (con->cursor && dcl->ops->dpy_cursor_define) {
         dcl->ops->dpy_cursor_define(dcl, con->cursor);
     }
+    if (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);
 }
 
@@ -1908,6 +1912,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;
     }
Signature · 1 line
2.39.1
#11 lore raw

PATCH 11/11 ui/sdl: get the GL context from the window

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

There is no guarantee to have a current GL context here. The current code seems to rely on the renderer using a GL backend, and to set a current GL context. But this is not always the case, for example if the renderer backend is DirectX.

This change is enough to fix using virgl with sdl2 on win32, on my setup.

---
 ui/sdl2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ui/sdl2.c +1 -1
index 8cb77416af..f259e4c4d1 100644
@@ -101,7 +101,7 @@ void sdl2_window_create(struct sdl2_console *scon)
                                          flags);
     scon->real_renderer = SDL_CreateRenderer(scon->real_window, -1, 0);
     if (scon->opengl) {
-        scon->winctx = SDL_GL_GetCurrentContext();
+        scon->winctx = SDL_GL_CreateContext(scon->real_window);
     }
     sdl_update_caption(scon);
 }
Signature · 1 line
2.39.1