diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2012-11-13 14:51:41 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2013-03-18 10:21:58 +0100 |
commit | 7c20b4a374d0016e3fce005690fb428354a56621 (patch) | |
tree | e2cd1af910a6e226a1cc8d4d3f6d933a02e58c58 /ui/vnc.c | |
parent | 225dc991b03f0f034aa348f5cf499de9d0979107 (diff) |
console: fix displaychangelisteners interface
Split callbacks into separate Ops struct. Pass DisplayChangeListener
pointer as first argument to all callbacks. Uninline a bunch of
display functions and move them from console.h to console.c
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui/vnc.c')
-rw-r--r-- | ui/vnc.c | 44 |
1 files changed, 30 insertions, 14 deletions
@@ -430,7 +430,9 @@ static void framebuffer_update_request(VncState *vs, int incremental, static void vnc_refresh(void *opaque); static int vnc_refresh_server_surface(VncDisplay *vd); -static void vnc_dpy_update(DisplayState *ds, int x, int y, int w, int h) +static void vnc_dpy_update(DisplayChangeListener *dcl, + DisplayState *ds, + int x, int y, int w, int h) { int i; VncDisplay *vd = ds->opaque; @@ -573,7 +575,8 @@ void *vnc_server_fb_ptr(VncDisplay *vd, int x, int y) return ptr; } -static void vnc_dpy_resize(DisplayState *ds) +static void vnc_dpy_resize(DisplayChangeListener *dcl, + DisplayState *ds) { VncDisplay *vd = ds->opaque; VncState *vs; @@ -735,7 +738,10 @@ static void vnc_copy(VncState *vs, int src_x, int src_y, int dst_x, int dst_y, i vnc_flush(vs); } -static void vnc_dpy_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int dst_y, int w, int h) +static void vnc_dpy_copy(DisplayChangeListener *dcl, + DisplayState *ds, + int src_x, int src_y, + int dst_x, int dst_y, int w, int h) { VncDisplay *vd = ds->opaque; VncState *vs, *vn; @@ -806,7 +812,9 @@ static void vnc_dpy_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int } } -static void vnc_mouse_set(DisplayState *ds, int x, int y, int visible) +static void vnc_mouse_set(DisplayChangeListener *dcl, + DisplayState *ds, + int x, int y, int visible) { /* can we ask the client(s) to move the pointer ??? */ } @@ -832,7 +840,9 @@ static int vnc_cursor_define(VncState *vs) return -1; } -static void vnc_dpy_cursor_define(DisplayState *ds, QEMUCursor *c) +static void vnc_dpy_cursor_define(DisplayChangeListener *dcl, + DisplayState *ds, + QEMUCursor *c) { VncDisplay *vd = vnc_display; VncState *vs; @@ -1972,14 +1982,15 @@ static void pixel_format_message (VncState *vs) { vs->write_pixels = vnc_write_pixels_copy; } -static void vnc_dpy_setdata(DisplayState *ds) +static void vnc_dpy_setdata(DisplayChangeListener *dcl, + DisplayState *ds) { VncDisplay *vd = ds->opaque; qemu_pixman_image_unref(vd->guest.fb); vd->guest.fb = pixman_image_ref(ds->surface->image); vd->guest.format = ds->surface->format; - vnc_dpy_update(ds, 0, 0, ds_get_width(ds), ds_get_height(ds)); + vnc_dpy_update(dcl, ds, 0, 0, ds_get_width(ds), ds_get_height(ds)); } static void vnc_colordepth(VncState *vs) @@ -2686,7 +2697,7 @@ static void vnc_init_timer(VncDisplay *vd) vd->timer_interval = VNC_REFRESH_INTERVAL_BASE; if (vd->timer == NULL && !QTAILQ_EMPTY(&vd->clients)) { vd->timer = qemu_new_timer_ms(rt_clock, vnc_refresh, vd); - vnc_dpy_resize(vd->ds); + vnc_dpy_resize(dcl, vd->ds); vnc_refresh(vd); } } @@ -2822,6 +2833,16 @@ static void vnc_listen_websocket_read(void *opaque) } #endif /* CONFIG_VNC_WS */ +static const DisplayChangeListenerOps dcl_ops = { + .dpy_name = "vnc", + .dpy_gfx_copy = vnc_dpy_copy, + .dpy_gfx_update = vnc_dpy_update, + .dpy_gfx_resize = vnc_dpy_resize, + .dpy_gfx_setdata = vnc_dpy_setdata, + .dpy_mouse_set = vnc_mouse_set, + .dpy_cursor_define = vnc_dpy_cursor_define, +}; + void vnc_display_init(DisplayState *ds) { VncDisplay *vs = g_malloc0(sizeof(*vs)); @@ -2852,12 +2873,7 @@ void vnc_display_init(DisplayState *ds) qemu_mutex_init(&vs->mutex); vnc_start_worker_thread(); - dcl->dpy_gfx_copy = vnc_dpy_copy; - dcl->dpy_gfx_update = vnc_dpy_update; - dcl->dpy_gfx_resize = vnc_dpy_resize; - dcl->dpy_gfx_setdata = vnc_dpy_setdata; - dcl->dpy_mouse_set = vnc_mouse_set; - dcl->dpy_cursor_define = vnc_dpy_cursor_define; + dcl->ops = &dcl_ops; register_displaychangelistener(ds, dcl); } |