Loading include/ui/console.h +4 −2 Original line number Diff line number Diff line Loading @@ -282,8 +282,10 @@ void graphic_hw_update(QemuConsole *con); void graphic_hw_invalidate(QemuConsole *con); void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata); int is_graphic_console(void); int is_fixedsize_console(void); bool qemu_console_is_visible(QemuConsole *con); bool qemu_console_is_graphic(QemuConsole *con); bool qemu_console_is_fixedsize(QemuConsole *con); void text_consoles_set_display(DisplayState *ds); void console_select(unsigned int index); void console_color_init(DisplayState *ds); Loading ui/console.c +33 −26 Original line number Diff line number Diff line Loading @@ -515,7 +515,7 @@ static void update_xy(QemuConsole *s, int x, int y) TextCell *c; int y1, y2; if (s != active_console) { if (!qemu_console_is_visible(s)) { return; } Loading Loading @@ -543,7 +543,7 @@ static void console_show_cursor(QemuConsole *s, int show) int y, y1; int x = s->x; if (s != active_console) { if (!qemu_console_is_visible(s)) { return; } Loading Loading @@ -579,8 +579,9 @@ static void console_refresh(QemuConsole *s) TextCell *c; int x, y, y1; if (s != active_console) if (!qemu_console_is_visible(s)) { return; } if (s->ds->have_text) { s->text_x[0] = 0; Loading Loading @@ -611,15 +612,10 @@ static void console_refresh(QemuConsole *s) } } static void console_scroll(int ydelta) static void console_scroll(QemuConsole *s, int ydelta) { QemuConsole *s; int i, y1; s = active_console; if (!s || (s->console_type == GRAPHIC_CONSOLE)) return; if (ydelta > 0) { for(i = 0; i < ydelta; i++) { if (s->y_displayed == s->y_base) Loading Loading @@ -669,7 +665,7 @@ static void console_put_lf(QemuConsole *s) c->t_attrib = s->t_attrib_default; c++; } if (s == active_console && s->y_displayed == s->y_base) { if (qemu_console_is_visible(s) && s->y_displayed == s->y_base) { if (s->ds->have_text) { s->text_x[0] = 0; s->text_y[0] = 0; Loading Loading @@ -1112,16 +1108,16 @@ void kbd_put_keysym(int keysym) switch(keysym) { case QEMU_KEY_CTRL_UP: console_scroll(-1); console_scroll(s, -1); break; case QEMU_KEY_CTRL_DOWN: console_scroll(1); console_scroll(s, 1); break; case QEMU_KEY_CTRL_PAGEUP: console_scroll(-10); console_scroll(s, -10); break; case QEMU_KEY_CTRL_PAGEDOWN: console_scroll(10); console_scroll(s, 10); break; default: /* convert the QEMU keysym to VT100 key string */ Loading Loading @@ -1338,7 +1334,7 @@ void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h) w = MIN(w, width - x); h = MIN(h, height - y); if (con != active_console) { if (!qemu_console_is_visible(con)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { Loading Loading @@ -1367,7 +1363,7 @@ void dpy_gfx_replace_surface(QemuConsole *con, DisplaySurface *old_surface = con->surface; con->surface = surface; if (con == active_console) { if (qemu_console_is_visible(con)) { dpy_gfx_switch_surface(s, surface); } qemu_free_displaysurface(old_surface); Loading @@ -1389,7 +1385,7 @@ void dpy_gfx_copy(QemuConsole *con, int src_x, int src_y, DisplayState *s = con->ds; struct DisplayChangeListener *dcl; if (con != active_console) { if (!qemu_console_is_visible(con)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { Loading @@ -1406,7 +1402,7 @@ void dpy_text_cursor(QemuConsole *con, int x, int y) DisplayState *s = con->ds; struct DisplayChangeListener *dcl; if (con != active_console) { if (!qemu_console_is_visible(con)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { Loading @@ -1421,7 +1417,7 @@ void dpy_text_update(QemuConsole *con, int x, int y, int w, int h) DisplayState *s = con->ds; struct DisplayChangeListener *dcl; if (con != active_console) { if (!qemu_console_is_visible(con)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { Loading @@ -1436,7 +1432,7 @@ void dpy_text_resize(QemuConsole *con, int w, int h) DisplayState *s = con->ds; struct DisplayChangeListener *dcl; if (con != active_console) { if (!qemu_console_is_visible(con)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { Loading @@ -1451,7 +1447,7 @@ void dpy_mouse_set(QemuConsole *con, int x, int y, int on) DisplayState *s = con->ds; struct DisplayChangeListener *dcl; if (con != active_console) { if (!qemu_console_is_visible(con)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { Loading @@ -1466,7 +1462,7 @@ void dpy_cursor_define(QemuConsole *con, QEMUCursor *cursor) DisplayState *s = con->ds; struct DisplayChangeListener *dcl; if (con != active_console) { if (!qemu_console_is_visible(con)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { Loading Loading @@ -1540,14 +1536,25 @@ QemuConsole *graphic_console_init(const GraphicHwOps *hw_ops, return s; } int is_graphic_console(void) bool qemu_console_is_visible(QemuConsole *con) { return active_console && active_console->console_type == GRAPHIC_CONSOLE; return con == active_console; } int is_fixedsize_console(void) bool qemu_console_is_graphic(QemuConsole *con) { return active_console && active_console->console_type != TEXT_CONSOLE; if (con == NULL) { con = active_console; } return con && (con->console_type == GRAPHIC_CONSOLE); } bool qemu_console_is_fixedsize(QemuConsole *con) { if (con == NULL) { con = active_console; } return con && (con->console_type != TEXT_CONSOLE); } static void text_console_set_echo(CharDriverState *chr, bool echo) Loading ui/curses.c +4 −3 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ static void curses_update(DisplayChangeListener *dcl, static void curses_calc_pad(void) { if (is_fixedsize_console()) { if (qemu_console_is_fixedsize(NULL)) { width = gwidth; height = gheight; } else { Loading Loading @@ -143,8 +143,9 @@ static void curses_cursor_position(DisplayChangeListener *dcl, curs_set(1); /* it seems that curs_set(1) must always be called before * curs_set(2) for the latter to have effect */ if (!is_graphic_console()) if (!qemu_console_is_graphic(NULL)) { curs_set(2); } return; } } Loading Loading @@ -252,7 +253,7 @@ static void curses_refresh(DisplayChangeListener *dcl) if (keycode == -1) continue; if (is_graphic_console()) { if (qemu_console_is_graphic(NULL)) { /* since terminals don't know about key press and release * events, we need to emit both for each key received */ if (keycode & SHIFT) Loading ui/sdl.c +12 −12 Original line number Diff line number Diff line Loading @@ -358,7 +358,7 @@ static void sdl_show_cursor(void) if (!cursor_hide) return; if (!kbd_mouse_is_absolute() || !is_graphic_console()) { if (!kbd_mouse_is_absolute() || !qemu_console_is_graphic(NULL)) { SDL_ShowCursor(1); if (guest_cursor && (gui_grab || kbd_mouse_is_absolute() || absolute_enabled)) Loading Loading @@ -413,7 +413,7 @@ static void sdl_mouse_mode_change(Notifier *notify, void *data) if (kbd_mouse_is_absolute()) { if (!absolute_enabled) { absolute_enabled = 1; if (is_graphic_console()) { if (qemu_console_is_graphic(NULL)) { absolute_mouse_grab(); } } Loading Loading @@ -488,7 +488,7 @@ static void toggle_full_screen(void) } else { do_sdl_resize(width, height, 0); } if (!gui_saved_grab || !is_graphic_console()) { if (!gui_saved_grab || !qemu_console_is_graphic(NULL)) { sdl_grab_end(); } } Loading Loading @@ -535,7 +535,7 @@ static void handle_keydown(SDL_Event *ev) if (gui_fullscreen) { break; } if (!is_graphic_console()) { if (!qemu_console_is_graphic(NULL)) { /* release grab if going to a text console */ if (gui_grab) { sdl_grab_end(); Loading Loading @@ -563,7 +563,7 @@ static void handle_keydown(SDL_Event *ev) default: break; } } else if (!is_graphic_console()) { } else if (!qemu_console_is_graphic(NULL)) { int keysym = 0; if (ev->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) { Loading Loading @@ -637,7 +637,7 @@ static void handle_keydown(SDL_Event *ev) kbd_put_keysym(ev->key.keysym.unicode); } } if (is_graphic_console() && !gui_keysym) { if (qemu_console_is_graphic(NULL) && !gui_keysym) { sdl_process_key(&ev->key); } } Loading @@ -656,7 +656,7 @@ static void handle_keyup(SDL_Event *ev) if (gui_keysym == 0) { /* exit/enter grab if pressing Ctrl-Alt */ if (!gui_grab) { if (is_graphic_console()) { if (qemu_console_is_graphic(NULL)) { sdl_grab_start(); } } else if (!gui_fullscreen) { Loading @@ -669,7 +669,7 @@ static void handle_keyup(SDL_Event *ev) } gui_keysym = 0; } if (is_graphic_console() && !gui_keysym) { if (qemu_console_is_graphic(NULL) && !gui_keysym) { sdl_process_key(&ev->key); } } Loading @@ -678,7 +678,7 @@ static void handle_mousemotion(SDL_Event *ev) { int max_x, max_y; if (is_graphic_console() && if (qemu_console_is_graphic(NULL) && (kbd_mouse_is_absolute() || absolute_enabled)) { max_x = real_screen->w - 1; max_y = real_screen->h - 1; Loading @@ -704,7 +704,7 @@ static void handle_mousebutton(SDL_Event *ev) SDL_MouseButtonEvent *bev; int dz; if (!is_graphic_console()) { if (!qemu_console_is_graphic(NULL)) { return; } Loading Loading @@ -744,7 +744,7 @@ static void handle_activation(SDL_Event *ev) sdl_grab_end(); } #endif if (!gui_grab && ev->active.gain && is_graphic_console() && if (!gui_grab && ev->active.gain && qemu_console_is_graphic(NULL) && (kbd_mouse_is_absolute() || absolute_enabled)) { absolute_mouse_grab(); } Loading @@ -771,7 +771,7 @@ static void sdl_refresh(DisplayChangeListener *dcl) } graphic_hw_update(NULL); SDL_EnableUNICODE(!is_graphic_console()); SDL_EnableUNICODE(!qemu_console_is_graphic(NULL)); while (SDL_PollEvent(ev)) { switch (ev->type) { Loading ui/vnc.c +3 −3 Original line number Diff line number Diff line Loading @@ -1609,7 +1609,7 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym) } } if (is_graphic_console()) { if (qemu_console_is_graphic(NULL)) { if (keycode & SCANCODE_GREY) kbd_put_keycode(SCANCODE_EMUL0); if (down) Loading Loading @@ -1728,7 +1728,7 @@ static void vnc_release_modifiers(VncState *vs) }; int i, keycode; if (!is_graphic_console()) { if (!qemu_console_is_graphic(NULL)) { return; } for (i = 0; i < ARRAY_SIZE(keycodes); i++) { Loading @@ -1748,7 +1748,7 @@ static void key_event(VncState *vs, int down, uint32_t sym) int keycode; int lsym = sym; if (lsym >= 'A' && lsym <= 'Z' && is_graphic_console()) { if (lsym >= 'A' && lsym <= 'Z' && qemu_console_is_graphic(NULL)) { lsym = lsym - 'A' + 'a'; } Loading Loading
include/ui/console.h +4 −2 Original line number Diff line number Diff line Loading @@ -282,8 +282,10 @@ void graphic_hw_update(QemuConsole *con); void graphic_hw_invalidate(QemuConsole *con); void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata); int is_graphic_console(void); int is_fixedsize_console(void); bool qemu_console_is_visible(QemuConsole *con); bool qemu_console_is_graphic(QemuConsole *con); bool qemu_console_is_fixedsize(QemuConsole *con); void text_consoles_set_display(DisplayState *ds); void console_select(unsigned int index); void console_color_init(DisplayState *ds); Loading
ui/console.c +33 −26 Original line number Diff line number Diff line Loading @@ -515,7 +515,7 @@ static void update_xy(QemuConsole *s, int x, int y) TextCell *c; int y1, y2; if (s != active_console) { if (!qemu_console_is_visible(s)) { return; } Loading Loading @@ -543,7 +543,7 @@ static void console_show_cursor(QemuConsole *s, int show) int y, y1; int x = s->x; if (s != active_console) { if (!qemu_console_is_visible(s)) { return; } Loading Loading @@ -579,8 +579,9 @@ static void console_refresh(QemuConsole *s) TextCell *c; int x, y, y1; if (s != active_console) if (!qemu_console_is_visible(s)) { return; } if (s->ds->have_text) { s->text_x[0] = 0; Loading Loading @@ -611,15 +612,10 @@ static void console_refresh(QemuConsole *s) } } static void console_scroll(int ydelta) static void console_scroll(QemuConsole *s, int ydelta) { QemuConsole *s; int i, y1; s = active_console; if (!s || (s->console_type == GRAPHIC_CONSOLE)) return; if (ydelta > 0) { for(i = 0; i < ydelta; i++) { if (s->y_displayed == s->y_base) Loading Loading @@ -669,7 +665,7 @@ static void console_put_lf(QemuConsole *s) c->t_attrib = s->t_attrib_default; c++; } if (s == active_console && s->y_displayed == s->y_base) { if (qemu_console_is_visible(s) && s->y_displayed == s->y_base) { if (s->ds->have_text) { s->text_x[0] = 0; s->text_y[0] = 0; Loading Loading @@ -1112,16 +1108,16 @@ void kbd_put_keysym(int keysym) switch(keysym) { case QEMU_KEY_CTRL_UP: console_scroll(-1); console_scroll(s, -1); break; case QEMU_KEY_CTRL_DOWN: console_scroll(1); console_scroll(s, 1); break; case QEMU_KEY_CTRL_PAGEUP: console_scroll(-10); console_scroll(s, -10); break; case QEMU_KEY_CTRL_PAGEDOWN: console_scroll(10); console_scroll(s, 10); break; default: /* convert the QEMU keysym to VT100 key string */ Loading Loading @@ -1338,7 +1334,7 @@ void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h) w = MIN(w, width - x); h = MIN(h, height - y); if (con != active_console) { if (!qemu_console_is_visible(con)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { Loading Loading @@ -1367,7 +1363,7 @@ void dpy_gfx_replace_surface(QemuConsole *con, DisplaySurface *old_surface = con->surface; con->surface = surface; if (con == active_console) { if (qemu_console_is_visible(con)) { dpy_gfx_switch_surface(s, surface); } qemu_free_displaysurface(old_surface); Loading @@ -1389,7 +1385,7 @@ void dpy_gfx_copy(QemuConsole *con, int src_x, int src_y, DisplayState *s = con->ds; struct DisplayChangeListener *dcl; if (con != active_console) { if (!qemu_console_is_visible(con)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { Loading @@ -1406,7 +1402,7 @@ void dpy_text_cursor(QemuConsole *con, int x, int y) DisplayState *s = con->ds; struct DisplayChangeListener *dcl; if (con != active_console) { if (!qemu_console_is_visible(con)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { Loading @@ -1421,7 +1417,7 @@ void dpy_text_update(QemuConsole *con, int x, int y, int w, int h) DisplayState *s = con->ds; struct DisplayChangeListener *dcl; if (con != active_console) { if (!qemu_console_is_visible(con)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { Loading @@ -1436,7 +1432,7 @@ void dpy_text_resize(QemuConsole *con, int w, int h) DisplayState *s = con->ds; struct DisplayChangeListener *dcl; if (con != active_console) { if (!qemu_console_is_visible(con)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { Loading @@ -1451,7 +1447,7 @@ void dpy_mouse_set(QemuConsole *con, int x, int y, int on) DisplayState *s = con->ds; struct DisplayChangeListener *dcl; if (con != active_console) { if (!qemu_console_is_visible(con)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { Loading @@ -1466,7 +1462,7 @@ void dpy_cursor_define(QemuConsole *con, QEMUCursor *cursor) DisplayState *s = con->ds; struct DisplayChangeListener *dcl; if (con != active_console) { if (!qemu_console_is_visible(con)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { Loading Loading @@ -1540,14 +1536,25 @@ QemuConsole *graphic_console_init(const GraphicHwOps *hw_ops, return s; } int is_graphic_console(void) bool qemu_console_is_visible(QemuConsole *con) { return active_console && active_console->console_type == GRAPHIC_CONSOLE; return con == active_console; } int is_fixedsize_console(void) bool qemu_console_is_graphic(QemuConsole *con) { return active_console && active_console->console_type != TEXT_CONSOLE; if (con == NULL) { con = active_console; } return con && (con->console_type == GRAPHIC_CONSOLE); } bool qemu_console_is_fixedsize(QemuConsole *con) { if (con == NULL) { con = active_console; } return con && (con->console_type != TEXT_CONSOLE); } static void text_console_set_echo(CharDriverState *chr, bool echo) Loading
ui/curses.c +4 −3 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ static void curses_update(DisplayChangeListener *dcl, static void curses_calc_pad(void) { if (is_fixedsize_console()) { if (qemu_console_is_fixedsize(NULL)) { width = gwidth; height = gheight; } else { Loading Loading @@ -143,8 +143,9 @@ static void curses_cursor_position(DisplayChangeListener *dcl, curs_set(1); /* it seems that curs_set(1) must always be called before * curs_set(2) for the latter to have effect */ if (!is_graphic_console()) if (!qemu_console_is_graphic(NULL)) { curs_set(2); } return; } } Loading Loading @@ -252,7 +253,7 @@ static void curses_refresh(DisplayChangeListener *dcl) if (keycode == -1) continue; if (is_graphic_console()) { if (qemu_console_is_graphic(NULL)) { /* since terminals don't know about key press and release * events, we need to emit both for each key received */ if (keycode & SHIFT) Loading
ui/sdl.c +12 −12 Original line number Diff line number Diff line Loading @@ -358,7 +358,7 @@ static void sdl_show_cursor(void) if (!cursor_hide) return; if (!kbd_mouse_is_absolute() || !is_graphic_console()) { if (!kbd_mouse_is_absolute() || !qemu_console_is_graphic(NULL)) { SDL_ShowCursor(1); if (guest_cursor && (gui_grab || kbd_mouse_is_absolute() || absolute_enabled)) Loading Loading @@ -413,7 +413,7 @@ static void sdl_mouse_mode_change(Notifier *notify, void *data) if (kbd_mouse_is_absolute()) { if (!absolute_enabled) { absolute_enabled = 1; if (is_graphic_console()) { if (qemu_console_is_graphic(NULL)) { absolute_mouse_grab(); } } Loading Loading @@ -488,7 +488,7 @@ static void toggle_full_screen(void) } else { do_sdl_resize(width, height, 0); } if (!gui_saved_grab || !is_graphic_console()) { if (!gui_saved_grab || !qemu_console_is_graphic(NULL)) { sdl_grab_end(); } } Loading Loading @@ -535,7 +535,7 @@ static void handle_keydown(SDL_Event *ev) if (gui_fullscreen) { break; } if (!is_graphic_console()) { if (!qemu_console_is_graphic(NULL)) { /* release grab if going to a text console */ if (gui_grab) { sdl_grab_end(); Loading Loading @@ -563,7 +563,7 @@ static void handle_keydown(SDL_Event *ev) default: break; } } else if (!is_graphic_console()) { } else if (!qemu_console_is_graphic(NULL)) { int keysym = 0; if (ev->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) { Loading Loading @@ -637,7 +637,7 @@ static void handle_keydown(SDL_Event *ev) kbd_put_keysym(ev->key.keysym.unicode); } } if (is_graphic_console() && !gui_keysym) { if (qemu_console_is_graphic(NULL) && !gui_keysym) { sdl_process_key(&ev->key); } } Loading @@ -656,7 +656,7 @@ static void handle_keyup(SDL_Event *ev) if (gui_keysym == 0) { /* exit/enter grab if pressing Ctrl-Alt */ if (!gui_grab) { if (is_graphic_console()) { if (qemu_console_is_graphic(NULL)) { sdl_grab_start(); } } else if (!gui_fullscreen) { Loading @@ -669,7 +669,7 @@ static void handle_keyup(SDL_Event *ev) } gui_keysym = 0; } if (is_graphic_console() && !gui_keysym) { if (qemu_console_is_graphic(NULL) && !gui_keysym) { sdl_process_key(&ev->key); } } Loading @@ -678,7 +678,7 @@ static void handle_mousemotion(SDL_Event *ev) { int max_x, max_y; if (is_graphic_console() && if (qemu_console_is_graphic(NULL) && (kbd_mouse_is_absolute() || absolute_enabled)) { max_x = real_screen->w - 1; max_y = real_screen->h - 1; Loading @@ -704,7 +704,7 @@ static void handle_mousebutton(SDL_Event *ev) SDL_MouseButtonEvent *bev; int dz; if (!is_graphic_console()) { if (!qemu_console_is_graphic(NULL)) { return; } Loading Loading @@ -744,7 +744,7 @@ static void handle_activation(SDL_Event *ev) sdl_grab_end(); } #endif if (!gui_grab && ev->active.gain && is_graphic_console() && if (!gui_grab && ev->active.gain && qemu_console_is_graphic(NULL) && (kbd_mouse_is_absolute() || absolute_enabled)) { absolute_mouse_grab(); } Loading @@ -771,7 +771,7 @@ static void sdl_refresh(DisplayChangeListener *dcl) } graphic_hw_update(NULL); SDL_EnableUNICODE(!is_graphic_console()); SDL_EnableUNICODE(!qemu_console_is_graphic(NULL)); while (SDL_PollEvent(ev)) { switch (ev->type) { Loading
ui/vnc.c +3 −3 Original line number Diff line number Diff line Loading @@ -1609,7 +1609,7 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym) } } if (is_graphic_console()) { if (qemu_console_is_graphic(NULL)) { if (keycode & SCANCODE_GREY) kbd_put_keycode(SCANCODE_EMUL0); if (down) Loading Loading @@ -1728,7 +1728,7 @@ static void vnc_release_modifiers(VncState *vs) }; int i, keycode; if (!is_graphic_console()) { if (!qemu_console_is_graphic(NULL)) { return; } for (i = 0; i < ARRAY_SIZE(keycodes); i++) { Loading @@ -1748,7 +1748,7 @@ static void key_event(VncState *vs, int down, uint32_t sym) int keycode; int lsym = sym; if (lsym >= 'A' && lsym <= 'Z' && is_graphic_console()) { if (lsym >= 'A' && lsym <= 'Z' && qemu_console_is_graphic(NULL)) { lsym = lsym - 'A' + 'a'; } Loading