Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
void graphic_hw_invalidate(QemuConsole *con);
void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata);
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);
void text_consoles_set_display(DisplayState *ds);
void console_select(unsigned int index);
void console_color_init(DisplayState *ds);
- if (s != active_console) {
+ if (!qemu_console_is_visible(s)) {
- if (s != active_console) {
+ if (!qemu_console_is_visible(s)) {
TextCell *c;
int x, y, y1;
TextCell *c;
int x, y, y1;
- if (s != active_console)
+ if (!qemu_console_is_visible(s)) {
if (s->ds->have_text) {
s->text_x[0] = 0;
if (s->ds->have_text) {
s->text_x[0] = 0;
-static void console_scroll(int ydelta)
+static void console_scroll(QemuConsole *s, int ydelta)
- 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)
if (ydelta > 0) {
for(i = 0; i < ydelta; i++) {
if (s->y_displayed == s->y_base)
c->t_attrib = s->t_attrib_default;
c++;
}
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;
if (s->ds->have_text) {
s->text_x[0] = 0;
s->text_y[0] = 0;
switch(keysym) {
case QEMU_KEY_CTRL_UP:
switch(keysym) {
case QEMU_KEY_CTRL_UP:
break;
case QEMU_KEY_CTRL_DOWN:
break;
case QEMU_KEY_CTRL_DOWN:
break;
case QEMU_KEY_CTRL_PAGEUP:
break;
case QEMU_KEY_CTRL_PAGEUP:
+ console_scroll(s, -10);
break;
case QEMU_KEY_CTRL_PAGEDOWN:
break;
case QEMU_KEY_CTRL_PAGEDOWN:
break;
default:
/* convert the QEMU keysym to VT100 key string */
break;
default:
/* convert the QEMU keysym to VT100 key string */
w = MIN(w, width - x);
h = MIN(h, height - y);
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) {
return;
}
QLIST_FOREACH(dcl, &s->listeners, next) {
DisplaySurface *old_surface = con->surface;
con->surface = surface;
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);
dpy_gfx_switch_surface(s, surface);
}
qemu_free_displaysurface(old_surface);
DisplayState *s = con->ds;
struct DisplayChangeListener *dcl;
DisplayState *s = con->ds;
struct DisplayChangeListener *dcl;
- if (con != active_console) {
+ if (!qemu_console_is_visible(con)) {
return;
}
QLIST_FOREACH(dcl, &s->listeners, next) {
return;
}
QLIST_FOREACH(dcl, &s->listeners, next) {
DisplayState *s = con->ds;
struct DisplayChangeListener *dcl;
DisplayState *s = con->ds;
struct DisplayChangeListener *dcl;
- if (con != active_console) {
+ if (!qemu_console_is_visible(con)) {
return;
}
QLIST_FOREACH(dcl, &s->listeners, next) {
return;
}
QLIST_FOREACH(dcl, &s->listeners, next) {
DisplayState *s = con->ds;
struct DisplayChangeListener *dcl;
DisplayState *s = con->ds;
struct DisplayChangeListener *dcl;
- if (con != active_console) {
+ if (!qemu_console_is_visible(con)) {
return;
}
QLIST_FOREACH(dcl, &s->listeners, next) {
return;
}
QLIST_FOREACH(dcl, &s->listeners, next) {
DisplayState *s = con->ds;
struct DisplayChangeListener *dcl;
DisplayState *s = con->ds;
struct DisplayChangeListener *dcl;
- if (con != active_console) {
+ if (!qemu_console_is_visible(con)) {
return;
}
QLIST_FOREACH(dcl, &s->listeners, next) {
return;
}
QLIST_FOREACH(dcl, &s->listeners, next) {
DisplayState *s = con->ds;
struct DisplayChangeListener *dcl;
DisplayState *s = con->ds;
struct DisplayChangeListener *dcl;
- if (con != active_console) {
+ if (!qemu_console_is_visible(con)) {
return;
}
QLIST_FOREACH(dcl, &s->listeners, next) {
return;
}
QLIST_FOREACH(dcl, &s->listeners, next) {
DisplayState *s = con->ds;
struct DisplayChangeListener *dcl;
DisplayState *s = con->ds;
struct DisplayChangeListener *dcl;
- if (con != active_console) {
+ if (!qemu_console_is_visible(con)) {
return;
}
QLIST_FOREACH(dcl, &s->listeners, next) {
return;
}
QLIST_FOREACH(dcl, &s->listeners, next) {
-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)
static void curses_calc_pad(void)
{
static void curses_calc_pad(void)
{
- if (is_fixedsize_console()) {
+ if (qemu_console_is_fixedsize(NULL)) {
width = gwidth;
height = gheight;
} else {
width = gwidth;
height = gheight;
} else {
curs_set(1);
/* it seems that curs_set(1) must always be called before
* curs_set(2) for the latter to have effect */
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)) {
if (keycode == -1)
continue;
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)
/* since terminals don't know about key press and release
* events, we need to emit both for each key received */
if (keycode & SHIFT)
if (!cursor_hide)
return;
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))
SDL_ShowCursor(1);
if (guest_cursor &&
(gui_grab || kbd_mouse_is_absolute() || absolute_enabled))
if (kbd_mouse_is_absolute()) {
if (!absolute_enabled) {
absolute_enabled = 1;
if (kbd_mouse_is_absolute()) {
if (!absolute_enabled) {
absolute_enabled = 1;
- if (is_graphic_console()) {
+ if (qemu_console_is_graphic(NULL)) {
absolute_mouse_grab();
}
}
absolute_mouse_grab();
}
}
} else {
do_sdl_resize(width, height, 0);
}
} else {
do_sdl_resize(width, height, 0);
}
- if (!gui_saved_grab || !is_graphic_console()) {
+ if (!gui_saved_grab || !qemu_console_is_graphic(NULL)) {
if (gui_fullscreen) {
break;
}
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();
/* release grab if going to a text console */
if (gui_grab) {
sdl_grab_end();
- } else if (!is_graphic_console()) {
+ } else if (!qemu_console_is_graphic(NULL)) {
int keysym = 0;
if (ev->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
int keysym = 0;
if (ev->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
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);
}
}
if (gui_keysym == 0) {
/* exit/enter grab if pressing Ctrl-Alt */
if (!gui_grab) {
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) {
sdl_grab_start();
}
} else if (!gui_fullscreen) {
- if (is_graphic_console() && !gui_keysym) {
+ if (qemu_console_is_graphic(NULL) && !gui_keysym) {
sdl_process_key(&ev->key);
}
}
sdl_process_key(&ev->key);
}
}
- 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;
(kbd_mouse_is_absolute() || absolute_enabled)) {
max_x = real_screen->w - 1;
max_y = real_screen->h - 1;
SDL_MouseButtonEvent *bev;
int dz;
SDL_MouseButtonEvent *bev;
int dz;
- if (!is_graphic_console()) {
+ if (!qemu_console_is_graphic(NULL)) {
- 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();
}
(kbd_mouse_is_absolute() || absolute_enabled)) {
absolute_mouse_grab();
}
}
graphic_hw_update(NULL);
}
graphic_hw_update(NULL);
- SDL_EnableUNICODE(!is_graphic_console());
+ SDL_EnableUNICODE(!qemu_console_is_graphic(NULL));
while (SDL_PollEvent(ev)) {
switch (ev->type) {
while (SDL_PollEvent(ev)) {
switch (ev->type) {
- if (is_graphic_console()) {
+ if (qemu_console_is_graphic(NULL)) {
if (keycode & SCANCODE_GREY)
kbd_put_keycode(SCANCODE_EMUL0);
if (down)
if (keycode & SCANCODE_GREY)
kbd_put_keycode(SCANCODE_EMUL0);
if (down)
- if (!is_graphic_console()) {
+ if (!qemu_console_is_graphic(NULL)) {
return;
}
for (i = 0; i < ARRAY_SIZE(keycodes); i++) {
return;
}
for (i = 0; i < ARRAY_SIZE(keycodes); i++) {
int keycode;
int lsym = 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';
}
lsym = lsym - 'A' + 'a';
}