[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 7/7] sdl: use mouse mode notifier
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 7/7] sdl: use mouse mode notifier |
Date: |
Wed, 10 Mar 2010 10:51:09 -0600 |
Today we poll the mouse mode whenever there is a mouse movement. There is a
subtle usability problem with this though.
If we're in relative mode and grab is enabled, when we change to absolute mode,
we break grab. This gives a user a seamless transition when the new pointer
is enabled.
But because we poll for mouse change, this grab break won't occur until the user
attempts to move the mouse. By using notifiers, the grab break happens as soon
as possible.
Signed-off-by: Anthony Liguori <address@hidden>
---
sdl.c | 31 ++++++++++++++++++++-----------
1 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/sdl.c b/sdl.c
index 1d1e100..c51eb90 100644
--- a/sdl.c
+++ b/sdl.c
@@ -57,6 +57,7 @@ static SDL_Cursor *guest_sprite = NULL;
static uint8_t allocator;
static SDL_PixelFormat host_format;
static int scaling_active = 0;
+static QEMUNotifier mouse_mode_notifier;
static void sdl_update(DisplayState *ds, int x, int y, int w, int h)
{
@@ -485,6 +486,22 @@ static void sdl_grab_end(void)
sdl_update_caption();
}
+static void sdl_mouse_mode_change(QEMUNotifier *notify)
+{
+ if (kbd_mouse_is_absolute()) {
+ if (!absolute_enabled) {
+ sdl_hide_cursor();
+ if (gui_grab) {
+ sdl_grab_end();
+ }
+ absolute_enabled = 1;
+ }
+ } else if (absolute_enabled) {
+ sdl_show_cursor();
+ absolute_enabled = 0;
+ }
+}
+
static void sdl_send_mouse_event(int dx, int dy, int dz, int x, int y, int
state)
{
int buttons;
@@ -497,19 +514,8 @@ static void sdl_send_mouse_event(int dx, int dy, int dz,
int x, int y, int state
buttons |= MOUSE_EVENT_MBUTTON;
if (kbd_mouse_is_absolute()) {
- if (!absolute_enabled) {
- sdl_hide_cursor();
- if (gui_grab) {
- sdl_grab_end();
- }
- absolute_enabled = 1;
- }
-
dx = x * 0x7FFF / (width - 1);
dy = y * 0x7FFF / (height - 1);
- } else if (absolute_enabled) {
- sdl_show_cursor();
- absolute_enabled = 0;
} else if (guest_cursor) {
x -= guest_x;
y -= guest_y;
@@ -875,6 +881,9 @@ void sdl_display_init(DisplayState *ds, int full_screen,
int no_frame)
dpy_resize(ds);
}
+ mouse_mode_notifier.notify = sdl_mouse_mode_change;
+ qemu_add_mouse_mode_change_notifier(&mouse_mode_notifier);
+
sdl_update_caption();
SDL_EnableKeyRepeat(250, 50);
gui_grab = 0;
--
1.6.5.2
- [Qemu-devel] [PATCH 1/7] Add support for generic notifier lists, Anthony Liguori, 2010/03/10
- [Qemu-devel] [PATCH 2/7] Rewrite mouse handlers to use QTAILQ and to have an activation function, Anthony Liguori, 2010/03/10
- [Qemu-devel] [PATCH 5/7] Expose whether a mouse is an absolute device via QMP and the human monitor., Anthony Liguori, 2010/03/10
- [Qemu-devel] [PATCH 3/7] Add kbd_mouse_has_absolute(), Anthony Liguori, 2010/03/10
- [Qemu-devel] [PATCH 6/7] input: make vnc use mouse mode notifiers, Anthony Liguori, 2010/03/10
- [Qemu-devel] [PATCH 7/7] sdl: use mouse mode notifier,
Anthony Liguori <=
- [Qemu-devel] [PATCH 4/7] Add notifier for mouse mode changes, Anthony Liguori, 2010/03/10
- Re: [Qemu-devel] [PATCH 1/7] Add support for generic notifier lists, Paul Brook, 2010/03/11
- [Qemu-devel] Re: [PATCH 1/7] Add support for generic notifier lists, Paul Brook, 2010/03/11
- [Qemu-devel] Re: [PATCH 1/7] Add support for generic notifier lists, Paolo Bonzini, 2010/03/11
- Re: [Qemu-devel] Re: [PATCH 1/7] Add support for generic notifier lists, Anthony Liguori, 2010/03/11