mirror of
git://git.proxmox.com/git/spiceterm.git
synced 2025-08-22 02:07:24 +00:00
use new VD_AGENT_KEYVAL protocol extension
This commit is contained in:
parent
186d67d601
commit
f3112e0013
3
Makefile
3
Makefile
@ -4,6 +4,9 @@ PROGRAMS=spiceterm
|
|||||||
HEADERS=translations.h event_loop.h glyphs.h spiceterm.h
|
HEADERS=translations.h event_loop.h glyphs.h spiceterm.h
|
||||||
SOURCES=screen.c event_loop.c spiceterm.c
|
SOURCES=screen.c event_loop.c spiceterm.c
|
||||||
|
|
||||||
|
#export G_MESSAGES_DEBUG=all
|
||||||
|
#export SPICE_DEBUG=1
|
||||||
|
|
||||||
all: ${PROGRAMS}
|
all: ${PROGRAMS}
|
||||||
|
|
||||||
spiceterm: ${SOURCES} ${HEADERS} spiceterm.c
|
spiceterm: ${SOURCES} ${HEADERS} spiceterm.c
|
||||||
|
43
spiceterm.c
43
spiceterm.c
@ -1338,9 +1338,8 @@ my_kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
my_kbd_push_keyval(SpiceKbdInstance *sin, uint32_t keySym, int flags)
|
spiceterm_push_keyval(spiceTerm *vt, uint32_t keySym, uint32_t flags)
|
||||||
{
|
{
|
||||||
spiceTerm *vt = SPICE_CONTAINEROF(sin, spiceTerm, keyboard_sin);
|
|
||||||
static int control = 0;
|
static int control = 0;
|
||||||
static int shift = 0;
|
static int shift = 0;
|
||||||
char *esc = NULL;
|
char *esc = NULL;
|
||||||
@ -1349,7 +1348,7 @@ my_kbd_push_keyval(SpiceKbdInstance *sin, uint32_t keySym, int flags)
|
|||||||
|
|
||||||
DPRINTF(1, "flags=%d keySym=%08x", flags, keySym);
|
DPRINTF(1, "flags=%d keySym=%08x", flags, keySym);
|
||||||
|
|
||||||
if (flags & 1) {
|
if (flags & VD_AGENT_KEYVAL_FLAG_DOWN) {
|
||||||
if (keySym == GDK_KEY_Shift_L || keySym == GDK_KEY_Shift_R) {
|
if (keySym == GDK_KEY_Shift_L || keySym == GDK_KEY_Shift_R) {
|
||||||
shift = 1;
|
shift = 1;
|
||||||
} if (keySym == GDK_KEY_Control_L || keySym == GDK_KEY_Control_R) {
|
} if (keySym == GDK_KEY_Control_L || keySym == GDK_KEY_Control_R) {
|
||||||
@ -1457,10 +1456,9 @@ my_kbd_push_keyval(SpiceKbdInstance *sin, uint32_t keySym, int flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ret:
|
ret:
|
||||||
|
|
||||||
if (flags & 2) { // UP
|
if (!(flags & VD_AGENT_KEYVAL_FLAG_DOWN)) { // UP
|
||||||
if (keySym == GDK_KEY_Shift_L || keySym == GDK_KEY_Shift_R) {
|
if (keySym == GDK_KEY_Shift_L || keySym == GDK_KEY_Shift_R) {
|
||||||
shift = 0;
|
shift = 0;
|
||||||
} else if (keySym == GDK_KEY_Control_L || keySym == GDK_KEY_Control_R) {
|
} else if (keySym == GDK_KEY_Control_L || keySym == GDK_KEY_Control_R) {
|
||||||
@ -1482,7 +1480,6 @@ static SpiceKbdInterface my_keyboard_sif = {
|
|||||||
.base.description = "spiceterm keyboard device",
|
.base.description = "spiceterm keyboard device",
|
||||||
.base.major_version = SPICE_INTERFACE_KEYBOARD_MAJOR,
|
.base.major_version = SPICE_INTERFACE_KEYBOARD_MAJOR,
|
||||||
.base.minor_version = SPICE_INTERFACE_KEYBOARD_MINOR,
|
.base.minor_version = SPICE_INTERFACE_KEYBOARD_MINOR,
|
||||||
.push_keyval = my_kbd_push_keyval,
|
|
||||||
.push_scan_freg = my_kbd_push_key,
|
.push_scan_freg = my_kbd_push_key,
|
||||||
.get_leds = my_kbd_get_leds,
|
.get_leds = my_kbd_get_leds,
|
||||||
};
|
};
|
||||||
@ -1655,6 +1652,18 @@ vdagent_reply(spiceTerm *vt, uint32_t type, uint32_t error)
|
|||||||
spice_server_char_device_wakeup(&vt->vdagent_sin);
|
spice_server_char_device_wakeup(&vt->vdagent_sin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dump_message(unsigned char *buf, int size)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++) {
|
||||||
|
printf("%d %02X\n", i, buf[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
static void vdagent_send_capabilities(spiceTerm *vt, uint32_t request)
|
static void vdagent_send_capabilities(spiceTerm *vt, uint32_t request)
|
||||||
{
|
{
|
||||||
VDAgentAnnounceCapabilities *caps;
|
VDAgentAnnounceCapabilities *caps;
|
||||||
@ -1672,6 +1681,7 @@ 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_CLIPBOARD_SELECTION);
|
||||||
VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_SPARSE_MONITORS_CONFIG);
|
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_GUEST_LINEEND_LF);
|
||||||
|
VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_KEYVAL);
|
||||||
|
|
||||||
int msg_size = sizeof(VDIChunkHeader) + sizeof(VDAgentMessage) + size;
|
int msg_size = sizeof(VDIChunkHeader) + sizeof(VDAgentMessage) + size;
|
||||||
g_assert((vdagent_write_buffer_pos + msg_size) < VDAGENT_WBUF_SIZE);
|
g_assert((vdagent_write_buffer_pos + msg_size) < VDAGENT_WBUF_SIZE);
|
||||||
@ -1690,24 +1700,14 @@ static void vdagent_send_capabilities(spiceTerm *vt, uint32_t request)
|
|||||||
msg->size = size;
|
msg->size = size;
|
||||||
|
|
||||||
memcpy(buf + sizeof(VDIChunkHeader) + sizeof(VDAgentMessage), (uint8_t *)caps, size);
|
memcpy(buf + sizeof(VDIChunkHeader) + sizeof(VDAgentMessage), (uint8_t *)caps, size);
|
||||||
|
|
||||||
|
if (0) dump_message(buf, msg_size);
|
||||||
|
|
||||||
spice_server_char_device_wakeup(&vt->vdagent_sin);
|
spice_server_char_device_wakeup(&vt->vdagent_sin);
|
||||||
|
|
||||||
free(caps);
|
free(caps);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
dump_message(unsigned char *buf, int size)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < size; i++) {
|
|
||||||
printf("%d %02X\n", i, buf[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vdagent_grab_clipboard(spiceTerm *vt, uint8_t selection)
|
static void vdagent_grab_clipboard(spiceTerm *vt, uint8_t selection)
|
||||||
{
|
{
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
@ -1846,6 +1846,11 @@ vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
|
|||||||
DPRINTF(1, "%d %d %d %d", len, hdr->port, msg->protocol, msg->type);
|
DPRINTF(1, "%d %d %d %d", len, hdr->port, msg->protocol, msg->type);
|
||||||
|
|
||||||
switch (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: {
|
case VD_AGENT_MOUSE_STATE: {
|
||||||
VDAgentMouseState *info = (VDAgentMouseState *)&msg[1];
|
VDAgentMouseState *info = (VDAgentMouseState *)&msg[1];
|
||||||
spiceterm_motion_event(vt, info->x, info->y, info->buttons);
|
spiceterm_motion_event(vt, info->x, info->y, info->buttons);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user