diff options
author | Hans de Goede <hdegoede@redhat.com> | 2011-09-23 16:51:48 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2011-09-23 16:51:48 +0200 |
commit | 3cf8fa7d31a3ebf1d051ba0e1bd3df9957bdb112 (patch) | |
tree | efa7339be8eb0b4e8714a283bcff176cb113b505 /src/vdagentd-uinput.c | |
parent | 3e7f2a287d21b57b167d3d49fa3d8640ffcf2d60 (diff) | |
download | vd_agent-3cf8fa7d31a3ebf1d051ba0e1bd3df9957bdb112.tar.gz vd_agent-3cf8fa7d31a3ebf1d051ba0e1bd3df9957bdb112.tar.xz vd_agent-3cf8fa7d31a3ebf1d051ba0e1bd3df9957bdb112.zip |
Make mouse handling multiple monitor aware.
Actually send monitor info from the session agent to the system agent daemon,
and use this information in vdagentd-uinput to properly generate events
for events originating from different monitors on the client.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'src/vdagentd-uinput.c')
-rw-r--r-- | src/vdagentd-uinput.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/vdagentd-uinput.c b/src/vdagentd-uinput.c index 54cccb0..d50dfe7 100644 --- a/src/vdagentd-uinput.c +++ b/src/vdagentd-uinput.c @@ -33,15 +33,19 @@ struct vdagentd_uinput { const char *devname; int fd; + int verbose; int width; int height; - int verbose; + struct vdagentd_guest_xorg_resolution *screen_info; + int screen_count; FILE *errfile; VDAgentMouseState last; }; struct vdagentd_uinput *vdagentd_uinput_create(const char *devname, - int width, int height, FILE *errfile, int verbose) + int width, int height, + struct vdagentd_guest_xorg_resolution *screen_info, int screen_count, + FILE *errfile, int verbose) { struct vdagentd_uinput *uinput; @@ -54,7 +58,8 @@ struct vdagentd_uinput *vdagentd_uinput_create(const char *devname, uinput->verbose = verbose; uinput->errfile = errfile; - vdagentd_uinput_update_size(&uinput, width, height); + vdagentd_uinput_update_size(&uinput, width, height, + screen_info, screen_count); return uinput; } @@ -73,7 +78,9 @@ void vdagentd_uinput_destroy(struct vdagentd_uinput **uinputp) } void vdagentd_uinput_update_size(struct vdagentd_uinput **uinputp, - int width, int height) + int width, int height, + struct vdagentd_guest_xorg_resolution *screen_info, + int screen_count) { struct vdagentd_uinput *uinput = *uinputp; struct uinput_user_dev device = { @@ -83,6 +90,9 @@ void vdagentd_uinput_update_size(struct vdagentd_uinput **uinputp, }; int rc; + uinput->screen_info = screen_info; + uinput->screen_count = screen_count; + if (uinput->width == width && uinput->height == height) return; @@ -170,6 +180,16 @@ void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp, }; int i, down; + if (*uinputp) { + if (mouse->display_id >= uinput->screen_count) { + fprintf(uinput->errfile, "mouse event for unknown monitor (%d >= %d)\n", + mouse->display_id, uinput->screen_count); + return; + } + mouse->x += uinput->screen_info[mouse->display_id].x; + mouse->y += uinput->screen_info[mouse->display_id].y; + } + if (*uinputp && uinput->last.x != mouse->x) { if (uinput->verbose) fprintf(uinput->errfile, "mouse: abs-x %d\n", mouse->x); |