mirror of https://github.com/xemu-project/xemu.git
console: QLIST-ify display change listeners.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
286d52ebfc
commit
87e487a14b
72
console.h
72
console.h
|
@ -164,7 +164,7 @@ struct DisplayChangeListener {
|
||||||
int w, int h, uint32_t c);
|
int w, int h, uint32_t c);
|
||||||
void (*dpy_text_cursor)(struct DisplayState *s, int x, int y);
|
void (*dpy_text_cursor)(struct DisplayState *s, int x, int y);
|
||||||
|
|
||||||
struct DisplayChangeListener *next;
|
QLIST_ENTRY(DisplayChangeListener) next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DisplayAllocator {
|
struct DisplayAllocator {
|
||||||
|
@ -179,7 +179,7 @@ struct DisplayState {
|
||||||
struct QEMUTimer *gui_timer;
|
struct QEMUTimer *gui_timer;
|
||||||
|
|
||||||
struct DisplayAllocator* allocator;
|
struct DisplayAllocator* allocator;
|
||||||
struct DisplayChangeListener* listeners;
|
QLIST_HEAD(, DisplayChangeListener) listeners;
|
||||||
|
|
||||||
void (*mouse_set)(int x, int y, int on);
|
void (*mouse_set)(int x, int y, int on);
|
||||||
void (*cursor_define)(QEMUCursor *cursor);
|
void (*cursor_define)(QEMUCursor *cursor);
|
||||||
|
@ -231,72 +231,76 @@ static inline int is_buffer_shared(DisplaySurface *surface)
|
||||||
|
|
||||||
static inline void register_displaychangelistener(DisplayState *ds, DisplayChangeListener *dcl)
|
static inline void register_displaychangelistener(DisplayState *ds, DisplayChangeListener *dcl)
|
||||||
{
|
{
|
||||||
dcl->next = ds->listeners;
|
QLIST_INSERT_HEAD(&ds->listeners, dcl, next);
|
||||||
ds->listeners = dcl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
|
static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
struct DisplayChangeListener *dcl = s->listeners;
|
struct DisplayChangeListener *dcl;
|
||||||
while (dcl != NULL) {
|
QLIST_FOREACH(dcl, &s->listeners, next) {
|
||||||
dcl->dpy_update(s, x, y, w, h);
|
dcl->dpy_update(s, x, y, w, h);
|
||||||
dcl = dcl->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dpy_resize(DisplayState *s)
|
static inline void dpy_resize(DisplayState *s)
|
||||||
{
|
{
|
||||||
struct DisplayChangeListener *dcl = s->listeners;
|
struct DisplayChangeListener *dcl;
|
||||||
while (dcl != NULL) {
|
QLIST_FOREACH(dcl, &s->listeners, next) {
|
||||||
dcl->dpy_resize(s);
|
dcl->dpy_resize(s);
|
||||||
dcl = dcl->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dpy_setdata(DisplayState *s)
|
static inline void dpy_setdata(DisplayState *s)
|
||||||
{
|
{
|
||||||
struct DisplayChangeListener *dcl = s->listeners;
|
struct DisplayChangeListener *dcl;
|
||||||
while (dcl != NULL) {
|
QLIST_FOREACH(dcl, &s->listeners, next) {
|
||||||
if (dcl->dpy_setdata) dcl->dpy_setdata(s);
|
if (dcl->dpy_setdata) {
|
||||||
dcl = dcl->next;
|
dcl->dpy_setdata(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dpy_refresh(DisplayState *s)
|
static inline void dpy_refresh(DisplayState *s)
|
||||||
{
|
{
|
||||||
struct DisplayChangeListener *dcl = s->listeners;
|
struct DisplayChangeListener *dcl;
|
||||||
while (dcl != NULL) {
|
QLIST_FOREACH(dcl, &s->listeners, next) {
|
||||||
if (dcl->dpy_refresh) dcl->dpy_refresh(s);
|
if (dcl->dpy_refresh) {
|
||||||
dcl = dcl->next;
|
dcl->dpy_refresh(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dpy_copy(struct DisplayState *s, int src_x, int src_y,
|
static inline void dpy_copy(struct DisplayState *s, int src_x, int src_y,
|
||||||
int dst_x, int dst_y, int w, int h) {
|
int dst_x, int dst_y, int w, int h)
|
||||||
struct DisplayChangeListener *dcl = s->listeners;
|
{
|
||||||
while (dcl != NULL) {
|
struct DisplayChangeListener *dcl;
|
||||||
if (dcl->dpy_copy)
|
QLIST_FOREACH(dcl, &s->listeners, next) {
|
||||||
|
if (dcl->dpy_copy) {
|
||||||
dcl->dpy_copy(s, src_x, src_y, dst_x, dst_y, w, h);
|
dcl->dpy_copy(s, src_x, src_y, dst_x, dst_y, w, h);
|
||||||
else /* TODO */
|
} else { /* TODO */
|
||||||
dcl->dpy_update(s, dst_x, dst_y, w, h);
|
dcl->dpy_update(s, dst_x, dst_y, w, h);
|
||||||
dcl = dcl->next;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dpy_fill(struct DisplayState *s, int x, int y,
|
static inline void dpy_fill(struct DisplayState *s, int x, int y,
|
||||||
int w, int h, uint32_t c) {
|
int w, int h, uint32_t c)
|
||||||
struct DisplayChangeListener *dcl = s->listeners;
|
{
|
||||||
while (dcl != NULL) {
|
struct DisplayChangeListener *dcl;
|
||||||
if (dcl->dpy_fill) dcl->dpy_fill(s, x, y, w, h, c);
|
QLIST_FOREACH(dcl, &s->listeners, next) {
|
||||||
dcl = dcl->next;
|
if (dcl->dpy_fill) {
|
||||||
|
dcl->dpy_fill(s, x, y, w, h, c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dpy_cursor(struct DisplayState *s, int x, int y) {
|
static inline void dpy_cursor(struct DisplayState *s, int x, int y)
|
||||||
struct DisplayChangeListener *dcl = s->listeners;
|
{
|
||||||
while (dcl != NULL) {
|
struct DisplayChangeListener *dcl;
|
||||||
if (dcl->dpy_text_cursor) dcl->dpy_text_cursor(s, x, y);
|
QLIST_FOREACH(dcl, &s->listeners, next) {
|
||||||
dcl = dcl->next;
|
if (dcl->dpy_text_cursor) {
|
||||||
|
dcl->dpy_text_cursor(s, x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -717,7 +717,7 @@ static void xenfb_update(void *opaque)
|
||||||
if (xenfb_queue_full(xenfb))
|
if (xenfb_queue_full(xenfb))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (l = xenfb->c.ds->listeners; l != NULL; l = l->next) {
|
QLIST_FOREACH(l, &xenfb->c.ds->listeners, next) {
|
||||||
if (l->idle)
|
if (l->idle)
|
||||||
continue;
|
continue;
|
||||||
idle = 0;
|
idle = 0;
|
||||||
|
|
9
vl.c
9
vl.c
|
@ -1359,15 +1359,14 @@ static void gui_update(void *opaque)
|
||||||
{
|
{
|
||||||
uint64_t interval = GUI_REFRESH_INTERVAL;
|
uint64_t interval = GUI_REFRESH_INTERVAL;
|
||||||
DisplayState *ds = opaque;
|
DisplayState *ds = opaque;
|
||||||
DisplayChangeListener *dcl = ds->listeners;
|
DisplayChangeListener *dcl;
|
||||||
|
|
||||||
dpy_refresh(ds);
|
dpy_refresh(ds);
|
||||||
|
|
||||||
while (dcl != NULL) {
|
QLIST_FOREACH(dcl, &ds->listeners, next) {
|
||||||
if (dcl->gui_timer_interval &&
|
if (dcl->gui_timer_interval &&
|
||||||
dcl->gui_timer_interval < interval)
|
dcl->gui_timer_interval < interval)
|
||||||
interval = dcl->gui_timer_interval;
|
interval = dcl->gui_timer_interval;
|
||||||
dcl = dcl->next;
|
|
||||||
}
|
}
|
||||||
qemu_mod_timer(ds->gui_timer, interval + qemu_get_clock_ms(rt_clock));
|
qemu_mod_timer(ds->gui_timer, interval + qemu_get_clock_ms(rt_clock));
|
||||||
}
|
}
|
||||||
|
@ -3846,14 +3845,12 @@ int main(int argc, char **argv, char **envp)
|
||||||
|
|
||||||
/* display setup */
|
/* display setup */
|
||||||
dpy_resize(ds);
|
dpy_resize(ds);
|
||||||
dcl = ds->listeners;
|
QLIST_FOREACH(dcl, &ds->listeners, next) {
|
||||||
while (dcl != NULL) {
|
|
||||||
if (dcl->dpy_refresh != NULL) {
|
if (dcl->dpy_refresh != NULL) {
|
||||||
ds->gui_timer = qemu_new_timer_ms(rt_clock, gui_update, ds);
|
ds->gui_timer = qemu_new_timer_ms(rt_clock, gui_update, ds);
|
||||||
qemu_mod_timer(ds->gui_timer, qemu_get_clock_ms(rt_clock));
|
qemu_mod_timer(ds->gui_timer, qemu_get_clock_ms(rt_clock));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dcl = dcl->next;
|
|
||||||
}
|
}
|
||||||
text_consoles_set_display(ds);
|
text_consoles_set_display(ds);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue