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