Commit bf2fde70 authored by Gerd Hoffmann's avatar Gerd Hoffmann
Browse files

console: move set_mouse + cursor_define callbacks



When adding DisplayChangeListeners the set_mouse and cursor_define
callbacks have been left in DisplayState for some reason.  Fix it.

Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent 35c9e0a5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1242,7 +1242,7 @@ static void text_console_update(void *opaque, console_ch_t *chardata)
        s->text_y[1] = 0;
    }
    if (s->cursor_invalidate) {
        dpy_cursor(s->ds, s->x, s->y);
        dpy_text_cursor(s->ds, s->x, s->y);
        s->cursor_invalidate = 0;
    }
}
+35 −4
Original line number Diff line number Diff line
@@ -164,6 +164,9 @@ struct DisplayChangeListener {
                     int w, int h, uint32_t c);
    void (*dpy_text_cursor)(struct DisplayState *s, int x, int y);

    void (*dpy_mouse_set)(struct DisplayState *s, int x, int y, int on);
    void (*dpy_cursor_define)(struct DisplayState *s, QEMUCursor *cursor);

    QLIST_ENTRY(DisplayChangeListener) next;
};

@@ -181,9 +184,6 @@ struct DisplayState {
    struct DisplayAllocator* allocator;
    QLIST_HEAD(, DisplayChangeListener) listeners;

    void (*mouse_set)(int x, int y, int on);
    void (*cursor_define)(QEMUCursor *cursor);

    struct DisplayState *next;
};

@@ -304,7 +304,7 @@ static inline void dpy_fill(struct DisplayState *s, int x, int y,
    }
}

static inline void dpy_cursor(struct DisplayState *s, int x, int y)
static inline void dpy_text_cursor(struct DisplayState *s, int x, int y)
{
    struct DisplayChangeListener *dcl;
    QLIST_FOREACH(dcl, &s->listeners, next) {
@@ -314,6 +314,37 @@ static inline void dpy_cursor(struct DisplayState *s, int x, int y)
    }
}

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;
}

static inline int ds_get_linesize(DisplayState *ds)
{
    return ds->surface->linesize;
+1 −1
Original line number Diff line number Diff line
@@ -210,7 +210,7 @@ static void jazz_led_text_update(void *opaque, console_ch_t *chardata)
    LedState *s = opaque;
    char buf[2];

    dpy_cursor(s->ds, -1, -1);
    dpy_text_cursor(s->ds, -1, -1);
    qemu_console_resize(s->ds, 2, 1);

    /* TODO: draw the segments */
+1 −1
Original line number Diff line number Diff line
@@ -234,7 +234,7 @@ int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)
        return 1;
    }

    if (!qxl->ssd.ds->mouse_set || !qxl->ssd.ds->cursor_define) {
    if (!dpy_cursor_define_supported(qxl->ssd.ds)) {
        return 0;
    }

+5 −5
Original line number Diff line number Diff line
@@ -2070,11 +2070,11 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)
            s->cr[VGA_CRTC_CURSOR_END] != s->cursor_end || full_update) {
            cursor_visible = !(s->cr[VGA_CRTC_CURSOR_START] & 0x20);
            if (cursor_visible && cursor_offset < size && cursor_offset >= 0)
                dpy_cursor(s->ds,
                dpy_text_cursor(s->ds,
                                TEXTMODE_X(cursor_offset),
                                TEXTMODE_Y(cursor_offset));
            else
                dpy_cursor(s->ds, -1, -1);
                dpy_text_cursor(s->ds, -1, -1);
            s->cursor_offset = cursor_offset;
            s->cursor_start = s->cr[VGA_CRTC_CURSOR_START];
            s->cursor_end = s->cr[VGA_CRTC_CURSOR_END];
@@ -2135,7 +2135,7 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)
    /* Display a message */
    s->last_width = 60;
    s->last_height = height = 3;
    dpy_cursor(s->ds, -1, -1);
    dpy_text_cursor(s->ds, -1, -1);
    s->ds->surface->width = s->last_width;
    s->ds->surface->height = height;
    dpy_resize(s->ds);
Loading