qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH]some vnc enhancement
@ 2006-07-25  6:52 Yang, Xiaowei
  2006-07-25 12:23 ` [Qemu-devel] " Anthony Liguori
  0 siblings, 1 reply; 2+ messages in thread
From: Yang, Xiaowei @ 2006-07-25  6:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: anthony

[-- Attachment #1: Type: text/plain, Size: 381 bytes --]

Qemu 0.8 uses a written-from-scratch VNC implementation, which lacks of
some original features. One thing is that it doesn't recognize
ctrl+alt+1/2/3 to switch among screens. Another issue is VNC client may
reset color depth after connection, so if we don't re-calculate
color_table, monitor/console's background is abnormal. I made a patch to
add them. 

Thanks,
Xiaowei

[-- Attachment #2: vnc-qemu.patch --]
[-- Type: application/octet-stream, Size: 5095 bytes --]

diff -ur qemu-0.8.2/console.c qemu-0.8.2~/console.c
--- qemu-0.8.2/console.c	2006-07-23 01:23:34.000000000 +0800
+++ qemu-0.8.2~/console.c	2006-07-25 14:32:05.000000000 +0800
@@ -1032,11 +1032,21 @@
     return !active_console->text_console;
 }
 
+void set_color_table(DisplayState *ds) 
+{
+    int i, j;
+        for(j = 0; j < 2; j++) {
+            for(i = 0; i < 8; i++) {
+                color_table[j][i] = col_expand(ds, 
+                        vga_get_color(ds, color_table_rgb[j][i]));
+            }
+        }
+}
+
 CharDriverState *text_console_init(DisplayState *ds)
 {
     CharDriverState *chr;
     TextConsole *s;
-    int i,j;
     static int color_inited;
 
     chr = qemu_mallocz(sizeof(CharDriverState));
@@ -1058,12 +1068,7 @@
     
     if (!color_inited) {
         color_inited = 1;
-        for(j = 0; j < 2; j++) {
-            for(i = 0; i < 8; i++) {
-                color_table[j][i] = col_expand(s->ds, 
-                        vga_get_color(s->ds, color_table_rgb[j][i]));
-            }
-        }
+        set_color_table(ds);
     }
     s->y_displayed = 0;
     s->y_base = 0;
Only in qemu-0.8.2~: console.c.orig
Only in qemu-0.8.2~: cscope.out
diff -ur qemu-0.8.2/vl.h qemu-0.8.2~/vl.h
--- qemu-0.8.2/vl.h	2006-07-23 01:23:34.000000000 +0800
+++ qemu-0.8.2~/vl.h	2006-07-25 14:32:05.000000000 +0800
@@ -300,6 +300,7 @@
 int is_graphic_console(void);
 CharDriverState *text_console_init(DisplayState *ds);
 void console_select(unsigned int index);
+void set_color_table(DisplayState *ds);
 
 /* serial ports */
 
Only in qemu-0.8.2~: vl.h.orig
diff -ur qemu-0.8.2/vnc.c qemu-0.8.2~/vnc.c
--- qemu-0.8.2/vnc.c	2006-07-23 01:23:34.000000000 +0800
+++ qemu-0.8.2~/vnc.c	2006-07-25 14:37:07.000000000 +0800
@@ -31,6 +31,10 @@
 #include "vnc_keysym.h"
 #include "keymaps.c"
 
+#define XK_MISCELLANY
+#define XK_LATIN1
+#include <X11/keysymdef.h>
+
 typedef struct Buffer
 {
     size_t capacity;
@@ -71,6 +75,7 @@
     Buffer output;
     Buffer input;
     kbd_layout_t *kbd_layout;
+    int ctl_keys;               /* Ctrl+Alt starts calibration */
     /* current output mode information */
     VncWritePixels *write_pixels;
     VncSendHextileTile *send_hextile_tile;
@@ -175,10 +180,14 @@
 	exit(1);
     }
 
-    ds->depth = vs->depth * 8;
+    if (ds->depth != vs->depth * 8) {
+        ds->depth = vs->depth * 8;
+        set_color_table(ds);
+    }
     ds->width = w;
     ds->height = h;
     ds->linesize = w * vs->depth;
+
     if (vs->csock != -1 && vs->has_resize) {
 	vnc_write_u8(vs, 0);  /* msg id */
 	vnc_write_u8(vs, 0);
@@ -701,16 +710,71 @@
 
 static void do_key_event(VncState *vs, int down, uint32_t sym)
 {
-    int keycode;
+    sym &= 0xFFFF;
 
-    keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF);
+    if(is_graphic_console()) {
+        int keycode;
+        keycode = keysym2scancode(vs->kbd_layout, sym);
+ 
+        if (keycode & 0x80)
+            kbd_put_keycode(0xe0);
+        if (down)
+            kbd_put_keycode(keycode & 0x7f);
+        else
+            kbd_put_keycode(keycode | 0x80);
+    } else if(down) {
+        int qemu_keysym = 0;
+        if (sym <= 128) /* normal ascii */
+            qemu_keysym = sym;
+        else {
+            switch(sym) {
+            case XK_Up: qemu_keysym = QEMU_KEY_UP; break;
+            case XK_Down: qemu_keysym = QEMU_KEY_DOWN; break;
+            case XK_Left: qemu_keysym = QEMU_KEY_LEFT; break;
+            case XK_Right: qemu_keysym = QEMU_KEY_RIGHT; break;
+            case XK_Home: qemu_keysym = QEMU_KEY_HOME; break;
+            case XK_End: qemu_keysym = QEMU_KEY_END; break;
+            case XK_Page_Up: qemu_keysym = QEMU_KEY_PAGEUP; break;
+            case XK_Page_Down: qemu_keysym = QEMU_KEY_PAGEDOWN; break;
+            case XK_BackSpace: qemu_keysym = QEMU_KEY_BACKSPACE; break;
+            case XK_Delete: qemu_keysym = QEMU_KEY_DELETE; break;
+            case XK_Return:
+            case XK_Linefeed: qemu_keysym = sym; break;
+            default: break;
+            }
+        }
+        if (qemu_keysym != 0)
+            kbd_put_keysym(qemu_keysym);
+    }
 
-    if (keycode & 0x80)
-	kbd_put_keycode(0xe0);
-    if (down)
-	kbd_put_keycode(keycode & 0x7f);
-    else
-	kbd_put_keycode(keycode | 0x80);
+    if(down) {
+        if(sym == XK_Control_L)
+            vs->ctl_keys |= 1;
+        else if(sym == XK_Alt_L)
+            vs->ctl_keys |= 2;
+    } else {
+        switch(sym) {
+        case XK_Control_L:
+            vs->ctl_keys &= ~1;
+            break;
+
+        case XK_Alt_L:
+            vs->ctl_keys &= ~2;
+            break;
+
+        case XK_1 ... XK_9:
+            if((vs->ctl_keys & 3) != 3)
+                break;
+
+            console_select(sym - XK_1);
+            if (is_graphic_console()) {
+                /* tell the vga console to redisplay itself */
+                vga_hw_invalidate();
+                vnc_dpy_update(vs->ds, 0, 0, vs->ds->width, vs->ds->height);
+            }
+            break;
+        }
+    }
 }
 
 static void key_event(VncState *vs, int down, uint32_t sym)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-07-25 12:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-25  6:52 [Qemu-devel] [PATCH]some vnc enhancement Yang, Xiaowei
2006-07-25 12:23 ` [Qemu-devel] " Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).