From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 19/23] console: add qemu_console_is_*
Date: Wed, 20 Mar 2013 10:43:41 +0100 [thread overview]
Message-ID: <1363772625-9182-20-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1363772625-9182-1-git-send-email-kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/ui/console.h | 6 +++--
ui/console.c | 59 ++++++++++++++++++++++++++++----------------------
ui/curses.c | 7 +++---
ui/sdl.c | 24 ++++++++++----------
ui/vnc.c | 6 ++---
5 files changed, 56 insertions(+), 46 deletions(-)
diff --git a/include/ui/console.h b/include/ui/console.h
index 800f458..bcd0139 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -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);
diff --git a/ui/console.c b/ui/console.c
index 51f9fac..0f2fea5 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -509,7 +509,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;
}
@@ -537,7 +537,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;
}
@@ -573,8 +573,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;
@@ -605,15 +606,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)
@@ -663,7 +659,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;
@@ -1106,16 +1102,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 */
@@ -1332,7 +1328,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) {
@@ -1361,7 +1357,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);
@@ -1383,7 +1379,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) {
@@ -1400,7 +1396,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) {
@@ -1415,7 +1411,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) {
@@ -1430,7 +1426,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) {
@@ -1445,7 +1441,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) {
@@ -1460,7 +1456,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) {
@@ -1534,14 +1530,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)
diff --git a/ui/curses.c b/ui/curses.c
index ed9e65c..a85a7da 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -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 {
@@ -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;
}
}
@@ -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)
diff --git a/ui/sdl.c b/ui/sdl.c
index 97764a6..c9f2928 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -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))
@@ -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();
}
}
@@ -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();
}
}
@@ -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();
@@ -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)) {
@@ -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);
}
}
@@ -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) {
@@ -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);
}
}
@@ -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;
@@ -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;
}
@@ -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();
}
@@ -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) {
diff --git a/ui/vnc.c b/ui/vnc.c
index ad91a7b..b01180d 100644
--- a/ui/vnc.c
+++ b/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)
kbd_put_keycode(SCANCODE_EMUL0);
if (down)
@@ -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++) {
@@ -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';
}
--
1.7.9.7
next prev parent reply other threads:[~2013-03-20 9:44 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-20 9:43 [Qemu-devel] [PATCH v2 00/23] console: overhaul continued Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 01/23] exynos4210_fimd.c: fix display resize bug introduced after console revamp Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 02/23] hw/vmware_vga.c: fix screen " Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 03/23] pixman: add qemu_pixman_color() Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 04/23] pixman: render vgafont glyphs into pixman images Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 05/23] console: use pixman for fill+blit Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 06/23] console: use pixman for font rendering Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 07/23] console: switch color_table_rgb to pixman_color_t Gerd Hoffmann
[not found] ` <514A01CD.1020106@gmail.com>
2013-03-20 19:25 ` Igor Mitsyanko
2013-03-21 4:49 ` Søren Sandmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 08/23] console: add trace events Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 09/23] console: displaystate init revamp Gerd Hoffmann
[not found] ` <514A0478.3090908@gmail.com>
2013-03-20 19:27 ` Igor Mitsyanko
2013-03-21 7:42 ` Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 10/23] console: rename vga_hw_*, add QemuConsole param Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 11/23] console: give each QemuConsole its own DisplaySurface Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 12/23] console: simplify screendump Gerd Hoffmann
2013-03-20 9:43 ` Gerd Hoffmann
[not found] ` <514A08C4.9040103@gmail.com>
2013-03-20 19:28 ` [Qemu-devel] " Igor Mitsyanko
2013-03-20 9:43 ` [Qemu-devel] [PATCH 13/23] console: zap g_width + g_height Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 14/23] console: move gui_update+gui_setup_refresh from vl.c into console.c Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 15/23] console: make DisplayState private to console.c Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 16/23] console: add GraphicHwOps Gerd Hoffmann
2013-03-20 9:43 ` Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 17/23] console: gui timer fixes Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 18/23] xen: re-enable refresh interval reporting for xenfb Gerd Hoffmann
2013-03-20 9:43 ` Gerd Hoffmann
2013-03-20 9:43 ` Gerd Hoffmann [this message]
2013-03-20 9:43 ` [Qemu-devel] [PATCH 20/23] console: allow pinning displaychangelisteners to consoles Gerd Hoffmann
2013-03-20 9:43 ` [Qemu-devel] [PATCH 21/23] gtk: custom cursor support Gerd Hoffmann
2013-03-20 12:59 ` Anthony Liguori
2013-03-20 15:15 ` Gerd Hoffmann
2013-03-20 17:13 ` Anthony Liguori
2013-03-20 9:43 ` [Qemu-devel] [PATCH 22/23] gtk: show a window for each graphical QemuConsole Gerd Hoffmann
2013-03-20 13:04 ` Anthony Liguori
2013-03-20 15:22 ` Gerd Hoffmann
[not found] ` <514A0C75.4070802@gmail.com>
2013-03-20 19:29 ` Igor Mitsyanko
2013-03-20 20:06 ` Peter Maydell
2013-03-21 7:52 ` Gerd Hoffmann
2013-03-21 8:51 ` Gerd Hoffmann
2013-03-21 10:55 ` Peter Maydell
2013-03-21 14:43 ` Gerd Hoffmann
2013-03-21 18:25 ` Anthony Liguori
2013-03-22 11:19 ` Peter Maydell
2013-03-20 9:43 ` [Qemu-devel] [PATCH 23/23] qxl: register QemuConsole for secondary cards Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1363772625-9182-20-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.