From: Owen smith <owen.smith@citrix.com>
To: qemu-devel@nongnu.org
Cc: stefano.stabellini@eu.citrix.com,
Owen smith <owen.smith@citrix.com>,
xen-devel@lists.xen.org
Subject: [Qemu-devel] [PATCH v2 4/5] xenfb: Add "feature-no-abs-rescale"
Date: Wed, 17 Sep 2014 15:30:41 +0100 [thread overview]
Message-ID: <1410964242-3341-5-git-send-email-owen.smith@citrix.com> (raw)
In-Reply-To: <1410964242-3341-1-git-send-email-owen.smith@citrix.com>
Some frontends may require absolute axes that are not scaled to
DisplaySurface sizes.
backend: feature-no-abs-rescale
Value: 0/1 (boolean)
Default: 0
Indicates whether backend supports unscaled absolute axes. Unscaled
axes are in the range [0, 0x7fff].
frontend: request-no-abs-rescale
Value: 0/1 (boolean)
Default: 0
When set to 1, frontend is requesting unscaled absolute axes.
Unscaled absolute axes are only reported when absolute axes are used
(when "request-abs-pointer" is also set to "1"). Frontend sets
this value before connecting.
Signed-off-by: Owen smith <owen.smith@citrix.com>
---
hw/display/xenfb.c | 44 ++++++++++++++++++++++++++++++++++----------
1 file changed, 34 insertions(+), 10 deletions(-)
diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
index 829036f..0794075 100644
--- a/hw/display/xenfb.c
+++ b/hw/display/xenfb.c
@@ -61,6 +61,7 @@ struct common {
struct XenInput {
struct common c;
int abs_pointer_wanted; /* Whether guest supports absolute pointer */
+ int no_abs_rescale; /* Guest wants unscaled absolute axes */
int button_state; /* Last seen pointer button state */
int extended;
QEMUPutKbdEntry *qkbd;
@@ -329,6 +330,26 @@ static void xenfb_key_event(void *opaque, int scancode)
xenfb_send_key(xenfb, down, scancode2linux[scancode]);
}
+static void xenfb_mouse_rescale(struct XenInput *xenfb,
+ int *dx, int *dy)
+{
+ DisplaySurface *surface;
+ int dw, dh;
+
+ if (xenfb->c.con == NULL) {
+ return;
+ }
+ surface = qemu_console_surface(xenfb->c.con);
+ if (surface == NULL) {
+ return;
+ }
+ dw = surface_width(surface);
+ dh = surface_height(surface);
+
+ *dx = *dx * (dw - 1) / 0x7fff;
+ *dy = *dy * (dh - 1) / 0x7fff;
+}
+
/*
* Send a mouse event from the client to the guest OS
*
@@ -342,18 +363,16 @@ static void xenfb_mouse_event(void *opaque,
int dx, int dy, int dz, int button_state)
{
struct XenInput *xenfb = opaque;
- DisplaySurface *surface = qemu_console_surface(xenfb->c.con);
- int dw = surface_width(surface);
- int dh = surface_height(surface);
int i;
- if (xenfb->abs_pointer_wanted)
- xenfb_send_position(xenfb,
- dx * (dw - 1) / 0x7fff,
- dy * (dh - 1) / 0x7fff,
- dz);
- else
- xenfb_send_motion(xenfb, dx, dy, dz);
+ if (xenfb->abs_pointer_wanted) {
+ if (!xenfb->no_abs_rescale) {
+ xenfb_mouse_rescale(xenfb, &dx, &dy);
+ }
+ xenfb_send_position(xenfb, dx, dy, dz);
+ } else {
+ xenfb_send_motion(xenfb, dx, dy, dz);
+ }
for (i = 0 ; i < 8 ; i++) {
int lastDown = xenfb->button_state & (1 << i);
@@ -370,6 +389,7 @@ static void xenfb_mouse_event(void *opaque,
static int input_init(struct XenDevice *xendev)
{
xenstore_write_be_int(xendev, "feature-abs-pointer", 1);
+ xenstore_write_be_int(xendev, "feature-no-abs-rescale", 1);
return 0;
}
@@ -398,6 +418,10 @@ static void input_connected(struct XenDevice *xendev)
&in->abs_pointer_wanted) == -1) {
in->abs_pointer_wanted = 0;
}
+ if (xenstore_read_fe_int(xendev, "request-no-abs-rescale",
+ &in->no_abs_rescale) == -1) {
+ in->no_abs_rescale = 0;
+ }
if (in->qmouse) {
qemu_remove_mouse_event_handler(in->qmouse);
--
2.1.0
next prev parent reply other threads:[~2014-09-17 14:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-17 14:30 [Qemu-devel] [PATCH v2 0/5] xenfb: Add support for Windows PV frontend Owen smith
2014-09-17 14:30 ` [Qemu-devel] [PATCH v2 1/5] xenfb: Unregister keyboard event handler correctly Owen smith
2014-09-26 15:10 ` Stefano Stabellini
2014-09-17 14:30 ` [Qemu-devel] [PATCH v2 2/5] xenfb: Activate mouse event handler Owen smith
2014-09-26 15:12 ` Stefano Stabellini
2014-09-17 14:30 ` [Qemu-devel] [PATCH v2 3/5] xenfb: Add option to use a grant ref for shared page Owen smith
2014-09-17 16:42 ` [Qemu-devel] [Xen-devel] " Ian Campbell
2014-09-26 15:17 ` [Qemu-devel] " Stefano Stabellini
2014-09-17 14:30 ` Owen smith [this message]
2014-09-26 15:25 ` [Qemu-devel] [PATCH v2 4/5] xenfb: Add "feature-no-abs-rescale" Stefano Stabellini
2014-09-17 14:30 ` [Qemu-devel] [PATCH v2 5/5] xenfb: Add "feature-no-console" Owen smith
2014-09-26 15:42 ` Stefano Stabellini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1410964242-3341-5-git-send-email-owen.smith@citrix.com \
--to=owen.smith@citrix.com \
--cc=qemu-devel@nongnu.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).