more generic i8259 support
[qemu] / console.c
index b688e93..b99a3bf 100644 (file)
--- a/console.c
+++ b/console.c
@@ -570,8 +570,11 @@ void console_select(unsigned int index)
         active_console = s;
         if (s->text_console) {
             if (s->g_width != s->ds->width ||
-                s->g_height != s->ds->height)
+                s->g_height != s->ds->height) {
+               s->g_width = s->ds->width;
+               s->g_height = s->ds->height;
                 text_console_resize(s);
+           }
             console_refresh(s);
         }
     }
@@ -599,6 +602,21 @@ static void console_chr_add_read_handler(CharDriverState *chr,
     s->fd_opaque = opaque;
 }
 
+static void console_send_event(CharDriverState *chr, int event)
+{
+    TextConsole *s = chr->opaque;
+    int i;
+
+    if (event == CHR_EVENT_FOCUS) {
+        for(i = 0; i < nb_consoles; i++) {
+            if (consoles[i] == s) {
+                console_select(i);
+                break;
+            }
+        }
+    }
+}
+
 /* called when an ascii key is pressed */
 void kbd_put_keysym(int keysym)
 {
@@ -689,6 +707,8 @@ CharDriverState *text_console_init(DisplayState *ds)
     chr->opaque = s;
     chr->chr_write = console_puts;
     chr->chr_add_read_handler = console_chr_add_read_handler;
+    chr->chr_send_event = console_send_event;
+
     if (!color_inited) {
         color_inited = 1;
         for(i = 0; i < 8; i++) {