Skip to content

Commit

Permalink
Merge tag 'display-pull-request' of https://gitlab.com/marcandre.lure…
Browse files Browse the repository at this point in the history
…au/qemu into staging

ui: dbus & misc fixes

v2:
- fix crash spotted by avocado VNC test

# -----BEGIN PGP SIGNATURE-----
#
# iQJQBAABCAA6FiEEh6m9kz+HxgbSdvYt2ujhCXWWnOUFAmQPgRIcHG1hcmNhbmRy
# ZS5sdXJlYXVAcmVkaGF0LmNvbQAKCRDa6OEJdZac5QDFEACef6cbSlTtQji1hV+x
# FM2ESPn0tgg9YVmtjsC1zqcdOEKsbs+2SQxBSs6tvQGwX5CgtnmyEsH5/Y4+TU64
# r6dvGAhokEkhiyHwnC+DFw0ajYAaDK96RfJ02tPQ58lrBTyioKZH9K/3mB6pMFEG
# aroE1Z3SQqqMnP+zsQ64nYuJrTXnv9iFejIxnuou+LyXdxmwLWAl5e47eZYaTmrh
# RrJYbCyHbiL5bx6mOmAL1XlO9jJD4o0FrqRWFn4zz1T+w4FvUC/uX52XwRn1G/Hk
# oHNnJBt95czCQ3S43xX0VTVrT9vLAptQzQc45KfegRL3XqPLgTgn4eocBQCYLmHZ
# jKnUsE9VjBNCbkIzgfN9RP/zEklD/3lAHzrW5US7q7oTTYksyxN+pmvfrYbUvKWP
# Oq/EQtpv66R06hjpxD76ime4+Y8WN7I3F/fJS8jl2QDy5I/2IzFSIOD9Rt5PGbky
# xsIdr7QPzlN4ZKpnsRCNeEPwcR/kiv4grIF7jBAxxz3k5UENtIVSJkHBEEQjMy8O
# +ZCvnHsbjPGxFtnlNTvtGsR2hiKYRCJSG/C4YQryTDWoScomlF6UWxzbapjs9CRW
# /GR+98Z2QfwOtRRRteRRt9UFdC/T0DquxnRyJxa5N4VxMiWzmhtCOzmn4oc1THbG
# 5UqDhRNSWEJn9iIvKca5ahSWLw==
# =Rjcs
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 13 Mar 2023 20:01:22 GMT
# gpg:                using RSA key 87A9BD933F87C606D276F62DDAE8E10975969CE5
# gpg:                issuer "marcandre.lureau@redhat.com"
# gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>" [full]
# gpg:                 aka "Marc-André Lureau <marcandre.lureau@gmail.com>" [full]
# Primary key fingerprint: 87A9 BD93 3F87 C606 D276  F62D DAE8 E109 7596 9CE5

* tag 'display-pull-request' of https://gitlab.com/marcandre.lureau/qemu:
  ui/dbus: restrict opengl to gbm-enabled config
  ui/dbus: do not require opengl & gbm
  ui: introduce egl_init()
  ui/sdl: try to instantiate the matching opengl renderer
  ui/sdl: add QEMU_ENABLE_SDL_LOGGING setting/environment
  ui/egl: print EGL error, helping debugging
  ui/shader: fix #version directive must occur on first line
  ui/sdl: get the GL context from the window
  ui: set cursor position upon listener registration
  ui: set cursor upon listener registration
  ui: keep current cursor with QemuConsole
  ui: rename cursor_{get->ref}, return it
  ui: rename cursor_{put->unref}
  meson: ensure dbus-display generated code is built before other units
  ui/dbus: set mouse is-absolute during console creation
  audio/dbus: there are no sender for p2p mode
  ui/dbus: unregister clipboard on connection close
  ui/dbus: initialize cursor_fb

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Mar 14, 2023
2 parents caaf72f + 4814d3c commit 7c3cc42
Show file tree
Hide file tree
Showing 26 changed files with 210 additions and 80 deletions.
2 changes: 1 addition & 1 deletion audio/audio_int.h
Expand Up @@ -143,7 +143,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;
Expand Down
7 changes: 5 additions & 2 deletions audio/dbusaudio.c
Expand Up @@ -43,6 +43,7 @@

typedef struct DBusAudio {
GDBusObjectManagerServer *server;
bool p2p;
GDBusObjectSkeleton *audio;
QemuDBusDisplay1Audio *iface;
GHashTable *out_listeners;
Expand Down Expand Up @@ -448,7 +449,8 @@ 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;
Expand Down Expand Up @@ -591,14 +593,15 @@ 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;

g_assert(da);
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();
Expand Down
4 changes: 2 additions & 2 deletions hw/display/qxl-render.c
Expand Up @@ -290,7 +290,7 @@ static QEMUCursor *qxl_cursor(PCIQXLDevice *qxl, QXLCursor *cursor,
return c;

fail:
cursor_put(c);
cursor_unref(c);
return NULL;
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion hw/display/qxl.c
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions hw/display/vmware_vga.c
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions include/ui/console.h
Expand Up @@ -151,8 +151,8 @@ typedef struct QEMUCursor {
} QEMUCursor;

QEMUCursor *cursor_alloc(int width, int height);
void cursor_get(QEMUCursor *c);
void cursor_put(QEMUCursor *c);
QEMUCursor *cursor_ref(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);
Expand Down Expand Up @@ -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,
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);
Expand Down
4 changes: 4 additions & 0 deletions include/ui/egl-helpers.h
Expand Up @@ -22,6 +22,8 @@ typedef struct egl_fb {
QemuDmaBuf *dmabuf;
} egl_fb;

#define EGL_FB_INIT { 0, }

void egl_fb_destroy(egl_fb *fb);
void egl_fb_setup_default(egl_fb *fb, int width, int height);
void egl_fb_setup_for_tex(egl_fb *fb, int width, int height,
Expand Down Expand Up @@ -63,4 +65,6 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode);
EGLContext qemu_egl_init_ctx(void);
bool qemu_egl_has_dmabuf(void);

bool egl_init(const char *rendernode, DisplayGLMode mode, Error **errp);

#endif /* EGL_HELPERS_H */
4 changes: 2 additions & 2 deletions meson.build
Expand Up @@ -1746,8 +1746,8 @@ dbus_display = get_option('dbus_display') \
error_message: '-display dbus requires glib>=2.64') \
.require(gdbus_codegen.found(),
error_message: gdbus_codegen_error.format('-display dbus')) \
.require(opengl.found() and gbm.found(),
error_message: '-display dbus requires epoxy/egl and gbm') \
.require(targetos != 'windows',
error_message: '-display dbus is not available on Windows') \
.allowed()

have_virtfs = get_option('virtfs') \
Expand Down
2 changes: 1 addition & 1 deletion tests/qtest/meson.build
Expand Up @@ -101,7 +101,7 @@ qtests_i386 = \
'numa-test'
]

if dbus_display
if dbus_display and targetos != 'windows'
qtests_i386 += ['dbus-display-test']
endif

Expand Down
18 changes: 18 additions & 0 deletions ui/console.c
Expand Up @@ -94,6 +94,8 @@ struct QemuConsole {
uint32_t head;
QemuUIInfo ui_info;
QEMUTimer *ui_timer;
QEMUCursor *cursor;
int cursor_x, cursor_y, cursor_on;
const GraphicHwOps *hw_ops;
void *hw;

Expand Down Expand Up @@ -1661,6 +1663,12 @@ 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);
}
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);
}

Expand Down Expand Up @@ -1905,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;
}
Expand All @@ -1923,6 +1934,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;
}
Expand Down Expand Up @@ -2288,6 +2301,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);
Expand Down
5 changes: 3 additions & 2 deletions ui/cursor.c
Expand Up @@ -106,12 +106,13 @@ 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_put(QEMUCursor *c)
void cursor_unref(QEMUCursor *c)
{
if (c == NULL)
return;
Expand Down
18 changes: 7 additions & 11 deletions ui/dbus-clipboard.c
Expand Up @@ -204,22 +204,14 @@ 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,
GDBusMethodInvocation *invocation)
{
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(
Expand All @@ -232,7 +224,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",
Expand All @@ -252,7 +244,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();

Expand Down
13 changes: 10 additions & 3 deletions ui/dbus-console.c
Expand Up @@ -411,15 +411,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)
Expand Down Expand Up @@ -492,6 +498,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;
}

0 comments on commit 7c3cc42

Please sign in to comment.