]> Git Repo - qemu.git/blobdiff - console.c
Make sure to link librt if we need to.
[qemu.git] / console.c
index 880ac831a5940ac76b2b6749ba8b9419ff10ecba..4e088d7a6f4e114f11d2d5843339808a201074e3 100644 (file)
--- a/console.c
+++ b/console.c
@@ -28,6 +28,7 @@
 //#define DEBUG_CONSOLE
 #define DEFAULT_BACKSCROLL 512
 #define MAX_CONSOLES 12
+#define DEFAULT_MONITOR_SIZE "800x600"
 
 #define QEMU_RGBA(r, g, b, a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
 #define QEMU_RGB(r, g, b) QEMU_RGBA(r, g, b, 0xff)
@@ -167,10 +168,15 @@ void vga_hw_invalidate(void)
 
 void vga_hw_screen_dump(const char *filename)
 {
-    /* There is currently no was of specifying which screen we want to dump,
-       so always dump the dirst one.  */
+    TextConsole *previous_active_console;
+
+    previous_active_console = active_console;
+    active_console = consoles[0];
+    /* There is currently no way of specifying which screen we want to dump,
+       so always dump the first one.  */
     if (consoles[0]->hw_screen_dump)
         consoles[0]->hw_screen_dump(consoles[0]->hw, filename);
+    active_console = previous_active_console;
 }
 
 void vga_hw_text_update(console_ch_t *chardata)
@@ -184,7 +190,7 @@ static unsigned int vga_get_color(DisplayState *ds, unsigned int rgba)
 {
     unsigned int r, g, b, color;
 
-    switch(ds->depth) {
+    switch(ds_get_bits_per_pixel(ds)) {
 #if 0
     case 8:
         r = (rgba >> 16) & 0xff;
@@ -221,9 +227,9 @@ static void vga_fill_rect (DisplayState *ds,
     uint8_t *d, *d1;
     int x, y, bpp;
 
-    bpp = (ds->depth + 7) >> 3;
-    d1 = ds->data +
-        ds->linesize * posy + bpp * posx;
+    bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3;
+    d1 = ds_get_data(ds) +
+        ds_get_linesize(ds) * posy + bpp * posx;
     for (y = 0; y < height; y++) {
         d = d1;
         switch(bpp) {
@@ -246,7 +252,7 @@ static void vga_fill_rect (DisplayState *ds,
             }
             break;
         }
-        d1 += ds->linesize;
+        d1 += ds_get_linesize(ds);
     }
 }
 
@@ -257,27 +263,27 @@ static void vga_bitblt(DisplayState *ds, int xs, int ys, int xd, int yd, int w,
     uint8_t *d;
     int wb, y, bpp;
 
-    bpp = (ds->depth + 7) >> 3;
+    bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3;
     wb = w * bpp;
     if (yd <= ys) {
-        s = ds->data +
-            ds->linesize * ys + bpp * xs;
-        d = ds->data +
-            ds->linesize * yd + bpp * xd;
+        s = ds_get_data(ds) +
+            ds_get_linesize(ds) * ys + bpp * xs;
+        d = ds_get_data(ds) +
+            ds_get_linesize(ds) * yd + bpp * xd;
         for (y = 0; y < h; y++) {
             memmove(d, s, wb);
-            d += ds->linesize;
-            s += ds->linesize;
+            d += ds_get_linesize(ds);
+            s += ds_get_linesize(ds);
         }
     } else {
-        s = ds->data +
-            ds->linesize * (ys + h - 1) + bpp * xs;
-        d = ds->data +
-            ds->linesize * (yd + h - 1) + bpp * xd;
+        s = ds_get_data(ds) +
+            ds_get_linesize(ds) * (ys + h - 1) + bpp * xs;
+        d = ds_get_data(ds) +
+            ds_get_linesize(ds) * (yd + h - 1) + bpp * xd;
        for (y = 0; y < h; y++) {
             memmove(d, s, wb);
-            d -= ds->linesize;
-            s -= ds->linesize;
+            d -= ds_get_linesize(ds);
+            s -= ds_get_linesize(ds);
         }
     }
 }
@@ -367,7 +373,7 @@ static const uint32_t color_table_rgb[2][8] = {
 
 static inline unsigned int col_expand(DisplayState *ds, unsigned int col)
 {
-    switch(ds->depth) {
+    switch(ds_get_bits_per_pixel(ds)) {
     case 8:
         col |= col << 8;
         col |= col << 16;
@@ -437,13 +443,13 @@ static void vga_putcharxy(DisplayState *ds, int x, int y, int ch,
         bgcol = color_table[t_attrib->bold][t_attrib->bgcol];
     }
 
-    bpp = (ds->depth + 7) >> 3;
-    d = ds->data +
-        ds->linesize * y * FONT_HEIGHT + bpp * x * FONT_WIDTH;
-    linesize = ds->linesize;
+    bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3;
+    d = ds_get_data(ds) +
+        ds_get_linesize(ds) * y * FONT_HEIGHT + bpp * x * FONT_WIDTH;
+    linesize = ds_get_linesize(ds);
     font_ptr = vgafont16 + FONT_HEIGHT * ch;
     xorcol = bgcol ^ fgcol;
-    switch(ds->depth) {
+    switch(ds_get_bits_per_pixel(ds)) {
     case 8:
         for(i = 0; i < FONT_HEIGHT; i++) {
             font_data = *font_ptr++;
@@ -537,7 +543,7 @@ static void update_xy(TextConsole *s, int x, int y)
     int y1, y2;
 
     if (s == active_console) {
-        if (!s->ds->depth) {
+        if (!ds_get_bits_per_pixel(s->ds)) {
             text_update_xy(s, x, y);
             return;
         }
@@ -564,7 +570,7 @@ static void console_show_cursor(TextConsole *s, int show)
     if (s == active_console) {
         int x = s->x;
 
-        if (!s->ds->depth) {
+        if (!ds_get_bits_per_pixel(s->ds)) {
             s->cursor_invalidate = 1;
             return;
         }
@@ -598,7 +604,7 @@ static void console_refresh(TextConsole *s)
 
     if (s != active_console)
         return;
-    if (!s->ds->depth) {
+    if (!ds_get_bits_per_pixel(s->ds)) {
         s->text_x[0] = 0;
         s->text_y[0] = 0;
         s->text_x[1] = s->width - 1;
@@ -607,7 +613,7 @@ static void console_refresh(TextConsole *s)
         return;
     }
 
-    vga_fill_rect(s->ds, 0, 0, s->ds->width, s->ds->height,
+    vga_fill_rect(s->ds, 0, 0, ds_get_width(s->ds), ds_get_height(s->ds),
                   color_table[0][COLOR_BLACK]);
     y1 = s->y_displayed;
     for(y = 0; y < s->height; y++) {
@@ -620,7 +626,7 @@ static void console_refresh(TextConsole *s)
         if (++y1 == s->total_height)
             y1 = 0;
     }
-    dpy_update(s->ds, 0, 0, s->ds->width, s->ds->height);
+    dpy_update(s->ds, 0, 0, ds_get_width(s->ds), ds_get_height(s->ds));
     console_show_cursor(s, 1);
 }
 
@@ -683,7 +689,7 @@ static void console_put_lf(TextConsole *s)
             c++;
         }
         if (s == active_console && s->y_displayed == s->y_base) {
-            if (!s->ds->depth) {
+            if (!ds_get_bits_per_pixel(s->ds)) {
                 s->text_x[0] = 0;
                 s->text_y[0] = 0;
                 s->text_x[1] = s->width - 1;
@@ -1041,6 +1047,9 @@ void console_select(unsigned int index)
     s = consoles[index];
     if (s) {
         active_console = s;
+        if (s->console_type != TEXT_CONSOLE && s->g_width && s->g_height
+            && (s->g_width != ds_get_width(s->ds) || s->g_height != ds_get_height(s->ds)))
+            dpy_resize(s->ds, s->g_width, s->g_height);
         vga_hw_invalidate();
     }
 }
@@ -1149,16 +1158,13 @@ static void text_console_invalidate(void *opaque)
 {
     TextConsole *s = (TextConsole *) opaque;
 
-    if (s->console_type != GRAPHIC_CONSOLE) {
-        if (s->g_width != s->ds->width ||
-            s->g_height != s->ds->height) {
-            if (s->console_type == TEXT_CONSOLE_FIXED_SIZE)
-                dpy_resize(s->ds, s->g_width, s->g_height);
-            else {
-                s->g_width = s->ds->width;
-                s->g_height = s->ds->height;
-                text_console_resize(s);
-            }
+    if (s->g_width != ds_get_width(s->ds) || s->g_height != ds_get_height(s->ds)) {
+        if (s->console_type == TEXT_CONSOLE_FIXED_SIZE)
+            dpy_resize(s->ds, s->g_width, s->g_height);
+        else {
+            s->g_width = ds_get_width(s->ds);
+            s->g_height = ds_get_height(s->ds);
+            text_console_resize(s);
         }
     }
     console_refresh(s);
@@ -1246,6 +1252,11 @@ int is_graphic_console(void)
     return active_console && active_console->console_type == GRAPHIC_CONSOLE;
 }
 
+int is_fixedsize_console(void)
+{
+    return active_console && active_console->console_type != TEXT_CONSOLE;
+}
+
 void console_color_init(DisplayState *ds)
 {
     int i, j;
@@ -1291,8 +1302,8 @@ CharDriverState *text_console_init(DisplayState *ds, const char *p)
     s->total_height = DEFAULT_BACKSCROLL;
     s->x = 0;
     s->y = 0;
-    width = s->ds->width;
-    height = s->ds->height;
+    width = ds_get_width(s->ds);
+    height = ds_get_height(s->ds);
     if (p != 0) {
         width = strtoul(p, (char **)&p, 10);
         if (*p == 'C') {
@@ -1332,3 +1343,29 @@ CharDriverState *text_console_init(DisplayState *ds, const char *p)
 
     return chr;
 }
+
+void qemu_console_resize(QEMUConsole *console, int width, int height)
+{
+    if (console->g_width != width || console->g_height != height
+        || !ds_get_data(console->ds)) {
+        console->g_width = width;
+        console->g_height = height;
+        if (active_console == console) {
+            dpy_resize(console->ds, width, height);
+        }
+    }
+}
+
+void qemu_console_copy(QEMUConsole *console, int src_x, int src_y,
+                int dst_x, int dst_y, int w, int h)
+{
+    if (active_console == console) {
+        if (console->ds->dpy_copy)
+            console->ds->dpy_copy(console->ds,
+                            src_x, src_y, dst_x, dst_y, w, h);
+        else {
+            /* TODO */
+            console->ds->dpy_update(console->ds, dst_x, dst_y, w, h);
+        }
+    }
+}
This page took 0.034588 seconds and 4 git commands to generate.