From: Samuel Thibault <samuel.thibault@eu.citrix.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] ioemu: fix SDL mouse events processing
Date: Wed, 5 Mar 2008 11:47:04 +0000 [thread overview]
Message-ID: <20080305114704.GC9747@implementation.uk.xensource.com> (raw)
ioemu: fix SDL mouse events processing
- GetRelativeMouseState always returns the last position, so when the
polling loop gets several mouse events in one go, we would send
useless 'no move' events.
- So as to make sure we don't miss any mouse click / double click, we
should not use GetRelativeMouseState() to get the button state, but
keep records of the button state ourselves.
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
diff -r 86e64b684fb2 tools/ioemu/sdl.c
--- a/tools/ioemu/sdl.c Wed Mar 05 11:10:29 2008 +0000
+++ b/tools/ioemu/sdl.c Wed Mar 05 11:41:24 2008 +0000
@@ -360,6 +360,7 @@
{
SDL_Event ev1, *ev = &ev1;
int mod_state;
+ int state;
if (last_vm_running != vm_running) {
last_vm_running = vm_running;
@@ -368,6 +369,7 @@
vga_hw_update();
+ state = SDL_GetMouseState(NULL, NULL);
while (SDL_PollEvent(ev)) {
switch (ev->type) {
case SDL_VIDEOEXPOSE:
@@ -475,41 +477,38 @@
case SDL_MOUSEMOTION:
if (gui_grab || kbd_mouse_is_absolute() ||
absolute_enabled) {
- int dx, dy, state;
- state = SDL_GetRelativeMouseState(&dx, &dy);
- sdl_send_mouse_event(dx, dy, 0, state);
+ int dx, dy;
+ SDL_GetRelativeMouseState(&dx, &dy);
+ if (dx || dy)
+ sdl_send_mouse_event(dx, dy, 0, state);
}
break;
case SDL_MOUSEBUTTONUP:
if (gui_grab || kbd_mouse_is_absolute()) {
- int dx, dy, state;
- state = SDL_GetRelativeMouseState(&dx, &dy);
- sdl_send_mouse_event(dx, dy, 0, state);
+ state &= ~SDL_BUTTON(ev->button.button);
+ sdl_send_mouse_event(0, 0, 0, state);
}
break;
case SDL_MOUSEBUTTONDOWN:
{
SDL_MouseButtonEvent *bev = &ev->button;
if (!gui_grab && !kbd_mouse_is_absolute()) {
- if (ev->type == SDL_MOUSEBUTTONDOWN &&
- (bev->state & SDL_BUTTON_LMASK)) {
+ if (bev->button == SDL_BUTTON_LEFT) {
/* start grabbing all events */
sdl_grab_start();
}
} else {
- int dx, dy, dz, state;
+ int dz;
dz = 0;
- state = SDL_GetRelativeMouseState(&dx, &dy);
+ state |= SDL_BUTTON(bev->button);
#ifdef SDL_BUTTON_WHEELUP
if (bev->button == SDL_BUTTON_WHEELUP) {
dz = -1;
} else if (bev->button == SDL_BUTTON_WHEELDOWN) {
dz = 1;
- } else {
- state = bev->button | state;
}
#endif
- sdl_send_mouse_event(dx, dy, dz, state);
+ sdl_send_mouse_event(0, 0, dz, state);
}
}
break;
next reply other threads:[~2008-03-05 11:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-05 11:47 Samuel Thibault [this message]
2008-03-05 12:18 ` [Qemu-devel] [PATCH] fix SDL mouse events processing Samuel Thibault
2008-03-05 13:09 ` Johannes Schindelin
2008-03-05 13:51 ` Samuel Thibault
2008-03-05 13:54 ` Samuel Thibault
2008-03-05 14:08 ` Johannes Schindelin
2008-03-13 19:50 ` Aurelien Jarno
2008-03-13 23:37 ` Samuel Thibault
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=20080305114704.GC9747@implementation.uk.xensource.com \
--to=samuel.thibault@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.