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 /include/ui | |
parent | 225dc991b03f0f034aa348f5cf499de9d0979107 (diff) | |
download | qemu-7c20b4a374d0016e3fce005690fb428354a56621.zip qemu-7c20b4a374d0016e3fce005690fb428354a56621.tar.gz qemu-7c20b4a374d0016e3fce005690fb428354a56621.tar.bz2 |
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 'include/ui')
-rw-r--r-- | include/ui/console.h | 207 | ||||
-rw-r--r-- | include/ui/spice-display.h | 1 |
2 files changed, 54 insertions, 154 deletions
diff --git a/include/ui/console.h b/include/ui/console.h index a37cf65..bf54f1e 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -147,24 +147,46 @@ void cursor_set_mono(QEMUCursor *c, void cursor_get_mono_image(QEMUCursor *c, int foreground, uint8_t *mask); void cursor_get_mono_mask(QEMUCursor *c, int transparent, uint8_t *mask); -struct DisplayChangeListener { - int idle; - uint64_t gui_timer_interval; - - void (*dpy_refresh)(struct DisplayState *s); - - void (*dpy_gfx_update)(struct DisplayState *s, int x, int y, int w, int h); - void (*dpy_gfx_resize)(struct DisplayState *s); - void (*dpy_gfx_setdata)(struct DisplayState *s); - void (*dpy_gfx_copy)(struct DisplayState *s, int src_x, int src_y, +typedef struct DisplayChangeListenerOps { + const char *dpy_name; + + void (*dpy_refresh)(DisplayChangeListener *dcl, + struct DisplayState *s); + + void (*dpy_gfx_update)(DisplayChangeListener *dcl, + struct DisplayState *s, + int x, int y, int w, int h); + void (*dpy_gfx_resize)(DisplayChangeListener *dcl, + struct DisplayState *s); + void (*dpy_gfx_setdata)(DisplayChangeListener *dcl, + struct DisplayState *s); + void (*dpy_gfx_copy)(DisplayChangeListener *dcl, + struct DisplayState *s, int src_x, int src_y, int dst_x, int dst_y, int w, int h); - void (*dpy_text_cursor)(struct DisplayState *s, int x, int y); - void (*dpy_text_resize)(struct DisplayState *s, int w, int h); - void (*dpy_text_update)(struct DisplayState *s, int x, int y, int w, int h); + void (*dpy_text_cursor)(DisplayChangeListener *dcl, + struct DisplayState *s, + int x, int y); + void (*dpy_text_resize)(DisplayChangeListener *dcl, + struct DisplayState *s, + int w, int h); + void (*dpy_text_update)(DisplayChangeListener *dcl, + struct DisplayState *s, + int x, int y, int w, int h); + + void (*dpy_mouse_set)(DisplayChangeListener *dcl, + struct DisplayState *s, + int x, int y, int on); + void (*dpy_cursor_define)(DisplayChangeListener *dcl, + struct DisplayState *s, + QEMUCursor *cursor); +} DisplayChangeListenerOps; - void (*dpy_mouse_set)(struct DisplayState *s, int x, int y, int on); - void (*dpy_cursor_define)(struct DisplayState *s, QEMUCursor *cursor); +struct DisplayChangeListener { + int idle; + uint64_t gui_timer_interval; + const DisplayChangeListenerOps *ops; + DisplayState *ds; QLIST_ENTRY(DisplayChangeListener) next; }; @@ -210,145 +232,22 @@ static inline int is_buffer_shared(DisplaySurface *surface) void gui_setup_refresh(DisplayState *ds); -static inline void register_displaychangelistener(DisplayState *ds, DisplayChangeListener *dcl) -{ - QLIST_INSERT_HEAD(&ds->listeners, dcl, next); - gui_setup_refresh(ds); - if (dcl->dpy_gfx_resize) { - dcl->dpy_gfx_resize(ds); - } -} - -static inline void unregister_displaychangelistener(DisplayState *ds, - DisplayChangeListener *dcl) -{ - QLIST_REMOVE(dcl, next); - gui_setup_refresh(ds); -} - -static inline void dpy_gfx_update(DisplayState *s, int x, int y, int w, int h) -{ - struct DisplayChangeListener *dcl; - int width = pixman_image_get_width(s->surface->image); - int height = pixman_image_get_height(s->surface->image); - - x = MAX(x, 0); - y = MAX(y, 0); - x = MIN(x, width); - y = MIN(y, height); - w = MIN(w, width - x); - h = MIN(h, height - y); - - QLIST_FOREACH(dcl, &s->listeners, next) { - if (dcl->dpy_gfx_update) { - dcl->dpy_gfx_update(s, x, y, w, h); - } - } -} - -static inline void dpy_gfx_resize(DisplayState *s) -{ - struct DisplayChangeListener *dcl; - QLIST_FOREACH(dcl, &s->listeners, next) { - if (dcl->dpy_gfx_resize) { - dcl->dpy_gfx_resize(s); - } - } -} - -static inline void dpy_gfx_setdata(DisplayState *s) -{ - struct DisplayChangeListener *dcl; - QLIST_FOREACH(dcl, &s->listeners, next) { - if (dcl->dpy_gfx_setdata) { - dcl->dpy_gfx_setdata(s); - } - } -} - -static inline void dpy_refresh(DisplayState *s) -{ - struct DisplayChangeListener *dcl; - QLIST_FOREACH(dcl, &s->listeners, next) { - if (dcl->dpy_refresh) { - dcl->dpy_refresh(s); - } - } -} - -static inline void dpy_gfx_copy(struct DisplayState *s, int src_x, int src_y, - int dst_x, int dst_y, int w, int h) -{ - struct DisplayChangeListener *dcl; - QLIST_FOREACH(dcl, &s->listeners, next) { - if (dcl->dpy_gfx_copy) { - dcl->dpy_gfx_copy(s, src_x, src_y, dst_x, dst_y, w, h); - } else { /* TODO */ - dcl->dpy_gfx_update(s, dst_x, dst_y, w, h); - } - } -} - -static inline void dpy_text_cursor(struct DisplayState *s, int x, int y) -{ - struct DisplayChangeListener *dcl; - QLIST_FOREACH(dcl, &s->listeners, next) { - if (dcl->dpy_text_cursor) { - dcl->dpy_text_cursor(s, x, y); - } - } -} - -static inline void dpy_text_update(DisplayState *s, int x, int y, int w, int h) -{ - struct DisplayChangeListener *dcl; - QLIST_FOREACH(dcl, &s->listeners, next) { - if (dcl->dpy_text_update) { - dcl->dpy_text_update(s, x, y, w, h); - } - } -} - -static inline void dpy_text_resize(DisplayState *s, int w, int h) -{ - struct DisplayChangeListener *dcl; - QLIST_FOREACH(dcl, &s->listeners, next) { - if (dcl->dpy_text_resize) { - dcl->dpy_text_resize(s, w, h); - } - } -} - -static inline void dpy_mouse_set(struct DisplayState *s, int x, int y, int on) -{ - struct DisplayChangeListener *dcl; - QLIST_FOREACH(dcl, &s->listeners, next) { - if (dcl->dpy_mouse_set) { - dcl->dpy_mouse_set(s, x, y, on); - } - } -} - -static inline void dpy_cursor_define(struct DisplayState *s, QEMUCursor *cursor) -{ - struct DisplayChangeListener *dcl; - QLIST_FOREACH(dcl, &s->listeners, next) { - if (dcl->dpy_cursor_define) { - dcl->dpy_cursor_define(s, cursor); - } - } -} - -static inline bool dpy_cursor_define_supported(struct DisplayState *s) -{ - struct DisplayChangeListener *dcl; - QLIST_FOREACH(dcl, &s->listeners, next) { - if (dcl->dpy_cursor_define) { - return true; - } - } - return false; -} +void register_displaychangelistener(DisplayState *ds, + DisplayChangeListener *dcl); +void unregister_displaychangelistener(DisplayChangeListener *dcl); + +void dpy_gfx_update(DisplayState *s, int x, int y, int w, int h); +void dpy_gfx_resize(DisplayState *s); +void dpy_gfx_setdata(DisplayState *s); +void dpy_refresh(DisplayState *s); +void dpy_gfx_copy(struct DisplayState *s, int src_x, int src_y, + int dst_x, int dst_y, int w, int h); +void dpy_text_cursor(struct DisplayState *s, int x, int y); +void dpy_text_update(DisplayState *s, int x, int y, int w, int h); +void dpy_text_resize(DisplayState *s, int w, int h); +void dpy_mouse_set(struct DisplayState *s, int x, int y, int on); +void dpy_cursor_define(struct DisplayState *s, QEMUCursor *cursor); +bool dpy_cursor_define_supported(struct DisplayState *s); static inline int ds_get_linesize(DisplayState *ds) { diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index 46f9530..f2752aa 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -72,6 +72,7 @@ typedef struct SimpleSpiceUpdate SimpleSpiceUpdate; struct SimpleSpiceDisplay { DisplayState *ds; + DisplayChangeListener dcl; void *buf; int bufsize; QXLWorker *worker; |