* [Qemu-devel] [PATCH] Support VNC PointerTypeChange psuedo-encoding
@ 2007-01-06 3:30 Anthony Liguori
2007-01-07 17:20 ` [Qemu-devel] " Daniel P. Berrange
0 siblings, 1 reply; 2+ messages in thread
From: Anthony Liguori @ 2007-01-06 3:30 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 913 bytes --]
The following patch adds support to the VNC server for the
PointerTypeChange. This is a new encoding I've defined specifically for
virtualization. It allows a VNC client to support a server that has a
relative mouse (such as a PS/2 mouse in QEMU). If you're familiar with
the mouse being offset in a VNC session, this patch is the proper way to
address that.
This extension is documented at http://tocm.wikidot.com/pointertypechange
It uses a type that I've reserved in the latest RFB spec.
Currently, the only client that supports this encoding is my PoC client
available at http://hg.codemonkey.ws/vnc-gui. I've also talked to Dan
Berrange, the virt-manager maintainer, and I believe he plans on
supporting this extension in virt-manager too. Once QEMU supports the
encoding, I suspect some of the other more popular VNC clients will
considering also supporting it.
Regards,
Anthony Liguori
[-- Attachment #2: vnc-relative-mouse.diff --]
[-- Type: text/x-patch, Size: 2569 bytes --]
diff -r a137f714c033 vnc.c
--- a/vnc.c Sun Dec 17 23:58:38 2006 -0600
+++ b/vnc.c Sun Dec 17 23:58:51 2006 -0600
@@ -68,6 +68,11 @@ struct VncState
int depth; /* internal VNC frame buffer byte per pixel */
int has_resize;
int has_hextile;
+ int has_pointer_type_change;
+ int absolute;
+ int last_x;
+ int last_y;
+
Buffer output;
Buffer input;
kbd_layout_t *kbd_layout;
@@ -671,6 +676,19 @@ static void client_cut_text(VncState *vs
{
}
+static void check_pointer_type_change(VncState *vs, int absolute)
+{
+ if (vs->has_pointer_type_change && vs->absolute != absolute) {
+ vnc_write_u8(vs, 0);
+ vnc_write_u8(vs, 0);
+ vnc_write_u16(vs, 1);
+ vnc_framebuffer_update(vs, absolute, 0,
+ vs->ds->width, vs->ds->height, -257);
+ vnc_flush(vs);
+ }
+ vs->absolute = absolute;
+}
+
static void pointer_event(VncState *vs, int button_mask, int x, int y)
{
int buttons = 0;
@@ -686,21 +704,26 @@ static void pointer_event(VncState *vs,
dz = -1;
if (button_mask & 0x10)
dz = 1;
-
- if (kbd_mouse_is_absolute()) {
+
+ if (vs->absolute) {
kbd_mouse_event(x * 0x7FFF / vs->ds->width,
y * 0x7FFF / vs->ds->height,
dz, buttons);
+ } else if (vs->has_pointer_type_change) {
+ x -= 0x7FFF;
+ y -= 0x7FFF;
+
+ kbd_mouse_event(x, y, dz, buttons);
} else {
- static int last_x = -1;
- static int last_y = -1;
-
- if (last_x != -1)
- kbd_mouse_event(x - last_x, y - last_y, dz, buttons);
-
- last_x = x;
- last_y = y;
- }
+ if (vs->last_x != -1)
+ kbd_mouse_event(x - vs->last_x,
+ y - vs->last_y,
+ dz, buttons);
+ vs->last_x = x;
+ vs->last_y = y;
+ }
+
+ check_pointer_type_change(vs, kbd_mouse_is_absolute());
}
static void reset_keys(VncState *vs)
@@ -829,6 +852,8 @@ static void set_encodings(VncState *vs,
vs->has_hextile = 0;
vs->has_resize = 0;
+ vs->has_pointer_type_change = 0;
+ vs->absolute = -1;
vs->ds->dpy_copy = NULL;
for (i = n_encodings - 1; i >= 0; i--) {
@@ -845,10 +870,15 @@ static void set_encodings(VncState *vs,
case -223: /* DesktopResize */
vs->has_resize = 1;
break;
+ case -257:
+ vs->has_pointer_type_change = 1;
+ break;
default:
break;
}
}
+
+ check_pointer_type_change(vs, kbd_mouse_is_absolute());
}
static int compute_nbits(unsigned int val)
@@ -1124,6 +1154,8 @@ void vnc_display_init(DisplayState *ds,
vs->lsock = -1;
vs->csock = -1;
vs->depth = 4;
+ vs->last_x = -1;
+ vs->last_y = -1;
vs->ds = ds;
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Qemu-devel] Re: [PATCH] Support VNC PointerTypeChange psuedo-encoding
2007-01-06 3:30 [Qemu-devel] [PATCH] Support VNC PointerTypeChange psuedo-encoding Anthony Liguori
@ 2007-01-07 17:20 ` Daniel P. Berrange
0 siblings, 0 replies; 2+ messages in thread
From: Daniel P. Berrange @ 2007-01-07 17:20 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel
On Fri, Jan 05, 2007 at 09:30:32PM -0600, Anthony Liguori wrote:
> The following patch adds support to the VNC server for the
> PointerTypeChange. This is a new encoding I've defined specifically for
> virtualization. It allows a VNC client to support a server that has a
> relative mouse (such as a PS/2 mouse in QEMU). If you're familiar with
> the mouse being offset in a VNC session, this patch is the proper way to
> address that.
>
> This extension is documented at http://tocm.wikidot.com/pointertypechange
>
> It uses a type that I've reserved in the latest RFB spec.
>
> Currently, the only client that supports this encoding is my PoC client
> available at http://hg.codemonkey.ws/vnc-gui. I've also talked to Dan
> Berrange, the virt-manager maintainer, and I believe he plans on
> supporting this extension in virt-manager too. Once QEMU supports the
> encoding, I suspect some of the other more popular VNC clients will
> considering also supporting it.
Yes, I will be implementing this extension in virt-manager, since its the
only approach to mouse pointer sanity which is portable across different
guest OS. Client-end code to make use of this extension is quite simple,
so I expect regular VNC clients could easily add support for it. For those
not familiar with VNC protocol, its worth noting that this extension is
'opt-in' - ie current default mouse pointer handling is unchanged, unless
the VNC client explicitly asks for it to be turned on.
That all said, if you've configured QEMU to use one of the pointer devices
which does absolute co-ordinates correctly (ie the graphics tables), then
you don't want to turn on this extension. ie. If you can get absolute coords
going through the whole stack Local Desktop -> VNC Client -> QEMU -> Guest OS
-> Guest Desktop, then that is the perfect approach because it doesn't
require you to do a local cursor-grab.
Regards,
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-01-07 17:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-06 3:30 [Qemu-devel] [PATCH] Support VNC PointerTypeChange psuedo-encoding Anthony Liguori
2007-01-07 17:20 ` [Qemu-devel] " Daniel P. Berrange
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).