]> git.proxmox.com Git - spiceterm.git/blobdiff - spiceterm.c
test if keysym is zero
[spiceterm.git] / spiceterm.c
index f6de5d5c4a25b3e0c7d3dd70dc632191a13abe3d..83eb4c8249366cc6ac467ab5b9ff188fbba63020 100644 (file)
@@ -203,18 +203,48 @@ spiceterm_refresh(spiceTerm *vt)
     spiceterm_show_cursor(vt, 1);
 }
 
+static void
+spiceterm_clear_screen(spiceTerm *vt)
+{
+    int x, y;
+
+    for (y = 0; y <= vt->height; y++) {
+        int y1 = (vt->y_base + y) % vt->total_height;
+        TextCell *c = &vt->cells[y1 * vt->width];
+        for (x = 0; x < vt->width; x++) {
+            c->ch = ' ';
+            c->attrib = vt->default_attrib;
+            c->attrib.fgcol = vt->cur_attrib.fgcol;
+            c->attrib.bgcol = vt->cur_attrib.bgcol;
+           
+            c++;
+        }
+    }
+
+    spice_screen_clear(vt->screen, 0, 0, vt->screen->primary_width, 
+                       vt->screen->primary_height);
+}
+
 void
 spiceterm_unselect_all(spiceTerm *vt)
 {
-    int i;
+    int x, y, y1;
 
-    for (i = 0; i < vt->width*vt->total_height; i++) {
-        if (vt->cells[i].attrib.selected) {
-            vt->cells[i].attrib.selected = 0;
+    y1 = vt->y_displ;
+    for(y = 0; y < vt->total_height; y++) {
+        TextCell *c = vt->cells + y1 * vt->width;
+        for(x = 0; x < vt->width; x++) {
+           if (c->attrib.selected) {
+               c->attrib.selected = 0;
+               if (y < vt->height) {
+                   draw_char_at(vt, x, y, c->ch, c->attrib);
+               }
+           }
+           c++;
         }
+        if (++y1 == vt->total_height)
+            y1 = 0;
     }
-
-    spiceterm_refresh(vt);
 }
 
 static void
@@ -914,11 +944,7 @@ spiceterm_putchar(spiceTerm *vt, gunichar2 ch)
                 break;
             case 2:
                 /* clear entire screen */
-                for (y = 0; y <= vt->height; y++) {
-                    for (x = 0; x < vt->width; x++) {
-                        spiceterm_clear_xy(vt, x, y);
-                    }
-                }
+                spiceterm_clear_screen(vt);
                 break;
             }
             break;
@@ -1328,17 +1354,7 @@ spiceterm_respond_unichar2(spiceTerm *vt, gunichar2 uc)
 }
 
 static void
-my_kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
-{
-    // spiceTerm *vt = SPICE_CONTAINEROF(sin, spiceTerm, keyboard_sin);
-
-    /* we no not need this */
-
-    return;
-}
-
-static void
-spiceterm_push_keyval(spiceTerm *vt, uint32_t keySym, uint32_t flags)
+spiceterm_push_keysym(spiceTerm *vt, uint32_t keySym, uint32_t flags)
 {
     static int control = 0;
     static int shift = 0;
@@ -1348,7 +1364,7 @@ spiceterm_push_keyval(spiceTerm *vt, uint32_t keySym, uint32_t flags)
 
     DPRINTF(1, "flags=%d keySym=%08x", flags, keySym);
 
-    if (flags & VD_AGENT_KEYVAL_FLAG_DOWN) {
+    if (flags & SPICE_KEYBOARD_FLAG_DOWN) {
         if (keySym == GDK_KEY_Shift_L || keySym == GDK_KEY_Shift_R) {
             shift = 1;
         } if (keySym == GDK_KEY_Control_L || keySym == GDK_KEY_Control_R) {
@@ -1458,7 +1474,7 @@ spiceterm_push_keyval(spiceTerm *vt, uint32_t keySym, uint32_t flags)
 
 ret:
 
-    if (!(flags & VD_AGENT_KEYVAL_FLAG_DOWN)) { // UP
+    if (flags & SPICE_KEYBOARD_FLAG_UP) {
         if (keySym == GDK_KEY_Shift_L || keySym == GDK_KEY_Shift_R) {
             shift = 0;
         } else if (keySym == GDK_KEY_Control_L || keySym == GDK_KEY_Control_R) {
@@ -1475,6 +1491,31 @@ my_kbd_get_leds(SpiceKbdInstance *sin)
     return 0;
 }
 
+static void
+my_kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
+{
+    // spiceTerm *vt = SPICE_CONTAINEROF(sin, spiceTerm, keyboard_sin);
+
+    /* we no not need this */
+
+    return;
+}
+
+static void
+my_kbd_push_x11_keysym(SpiceKbdInstance *sin, uint32_t keysym, uint32_t flags,
+                       uint8_t code_len, uint8_t *code)
+{
+    spiceTerm *vt = SPICE_CONTAINEROF(sin, spiceTerm, keyboard_sin);
+
+    DPRINTF(1, "flags=%d keySym=%08x code_len=%d", flags, keysym, code_len);
+
+    if (keysym) {
+        spiceterm_push_keysym(vt, keysym, flags);
+    }
+
+    return;
+}
+
 static SpiceKbdInterface my_keyboard_sif = {
     .base.type          = SPICE_INTERFACE_KEYBOARD,
     .base.description   = "spiceterm keyboard device",
@@ -1482,6 +1523,7 @@ static SpiceKbdInterface my_keyboard_sif = {
     .base.minor_version = SPICE_INTERFACE_KEYBOARD_MINOR,
     .push_scan_freg     = my_kbd_push_key,
     .get_leds           = my_kbd_get_leds,
+    .push_x11_keysym    = my_kbd_push_x11_keysym,
 };
 
 
@@ -1693,7 +1735,6 @@ static void vdagent_send_capabilities(spiceTerm *vt, uint32_t request)
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_CLIPBOARD_SELECTION);
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_SPARSE_MONITORS_CONFIG);
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_GUEST_LINEEND_LF);
-    VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_KEYVAL);
 
     int msg_size =  sizeof(VDIChunkHeader) + sizeof(VDAgentMessage) + size;
     g_assert((vdagent_write_buffer_pos + msg_size) < VDAGENT_WBUF_SIZE);
@@ -1856,11 +1897,6 @@ vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
     DPRINTF(1, "%d %d %d %d", len, hdr->port, msg->protocol, msg->type);
 
     switch (msg->type) {
-    case VD_AGENT_KEYVAL: {
-        VDAgentKeyval *info = (VDAgentKeyval *)&msg[1];
-        spiceterm_push_keyval(vt, info->keyval, info->flags);
-        break;
-    } 
     case VD_AGENT_MOUSE_STATE: { 
         VDAgentMouseState *info = (VDAgentMouseState *)&msg[1];
         spiceterm_motion_event(vt, info->x, info->y, info->buttons);