From: olig9@gmx.de
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [Patch] Release mouse at window edges
Date: Sat, 26 Feb 2005 16:09:45 +0100 (MET) [thread overview]
Message-ID: <6879.1109430585@www57.gmx.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 1231 bytes --]
Hello,
the attached patch makes Qemu ungrab the mouse cursor when the guest mouse
cursor hits the window edges. It also makes qemu automatically grab the
mouse when the host mouse cursor enters the window.
The patch uses the hardware cursor position (in cirrus_vga.c); this means
that it only works when the guest system uses a hardware cursor and when
Cirrus VGA is used.
For Linux guest (tested with GamesKnoppix), it works when enabling
"hw_cursor" in XF86Config-4 (in "Device" setion for "cirrus" driver).
For Win98se, it works when setting display hardware acceleration to maximum
and using the standard b/w, non-animated cursor set.
For Win2k Professional, it requires a newer Cirrus driver (old standard
Win2k driver for "GD5446 compatible" is from 1999, new driver from ISDCorp
is from 2000). It can be found
at
<http://www.hofnet.com/fire/browse.asp?target=%5CCIRRUS%20LOGIC%5CCL-GD5446%5CDRIVERS%5CWIN2000>.
Besides the new driver, you have to do the same as under Win98, and you must
disable mouse shadow.
The patch applies cleanly to qemu-snapshot-2005-02-25_23.tar.bz2.
Oliver Gerlich
--
Lassen Sie Ihren Gedanken freien Lauf... z.B. per FreeSMS
GMX bietet bis zu 100 FreeSMS/Monat: http://www.gmx.net/de/go/mail
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: releasemouse-1.diff --]
[-- Type: text/x-patch; name="releasemouse-1.diff", Size: 3879 bytes --]
diff -Naur qemu-snapshot-2005-02-10_23/hw/cirrus_vga.c qemu-snapshot-2005-02-10_23.patched/hw/cirrus_vga.c
--- qemu-snapshot-2005-02-10_23/hw/cirrus_vga.c 2005-01-26 20:50:16.000000000 +0100
+++ qemu-snapshot-2005-02-10_23.patched/hw/cirrus_vga.c 2005-02-26 15:02:03.000000000 +0100
@@ -1172,6 +1172,13 @@
case 0xf0: // Graphics Cursor X
s->sr[0x10] = reg_value;
s->hw_cursor_x = (reg_value << 3) | (reg_index >> 5);
+#ifdef DEBUG_CIRRUS
+ if (s->hw_cursor_x < 10 || s->hw_cursor_x > s->last_scr_width - 10)
+ printf("hw_cursor_x= %d; last_cursor_x= %d\n", s->hw_cursor_x, s->last_hw_cursor_x);
+#endif
+ if ( (s->hw_cursor_x <= 1 || s->hw_cursor_x >= s->last_scr_width - 12) &&
+ abs(s->hw_cursor_x - s->last_hw_cursor_x) > 4 )
+ s->ds->cursor_release(s->ds, s->hw_cursor_x, s->hw_cursor_y);
break;
case 0x11:
case 0x31:
@@ -1183,6 +1190,13 @@
case 0xf1: // Graphics Cursor Y
s->sr[0x11] = reg_value;
s->hw_cursor_y = (reg_value << 3) | (reg_index >> 5);
+#ifdef DEBUG_CIRRUS
+ if (s->hw_cursor_y < 10 || s->hw_cursor_y > s->last_scr_height - 10)
+ printf("hw_cursor_y= %d; last_cursor_y= %d\n", s->hw_cursor_y, s->last_hw_cursor_y);
+#endif
+ if ( (s->hw_cursor_y <= 1 || s->hw_cursor_y >= s->last_scr_height - 12) &&
+ abs(s->hw_cursor_y - s->last_hw_cursor_y) > 4 )
+ s->ds->cursor_release(s->ds, s->hw_cursor_x, s->hw_cursor_y);
break;
case 0x07: // Extended Sequencer Mode
case 0x08: // EEPROM Control
@@ -2085,6 +2099,7 @@
invalidate_cursor1(s);
s->last_hw_cursor_size = size;
+ s->ds->hw_cursor_size = size;
s->last_hw_cursor_x = s->hw_cursor_x;
s->last_hw_cursor_y = s->hw_cursor_y;
/* compute the real cursor min and max y */
diff -Naur qemu-snapshot-2005-02-10_23/sdl.c qemu-snapshot-2005-02-10_23.patched/sdl.c
--- qemu-snapshot-2005-02-10_23/sdl.c 2005-01-17 23:32:23.000000000 +0100
+++ qemu-snapshot-2005-02-10_23.patched/sdl.c 2005-02-26 15:26:40.000000000 +0100
@@ -308,6 +308,17 @@
vga_update_display();
}
+void sdl_cursor_release(struct DisplayState *s, int x, int y)
+{
+ //printf("releasing cursor at %d/%d\n", x, y);
+ if (gui_grab && !gui_fullscreen && is_active_console(vga_console) &&
+ SDL_GetModState() == KMOD_NONE && !SDL_GetMouseState(NULL, NULL))
+ {
+ sdl_grab_end();
+ SDL_WarpMouse(x, y);
+ }
+}
+
static void sdl_refresh(DisplayState *ds)
{
SDL_Event ev1, *ev = &ev1;
@@ -446,10 +457,12 @@
}
break;
case SDL_ACTIVEEVENT:
- if (gui_grab && (ev->active.gain & SDL_ACTIVEEVENTMASK) == 0 &&
- !gui_fullscreen_initial_grab) {
- sdl_grab_end();
- }
+ if (ev->active.state == SDL_APPMOUSEFOCUS && ev->active.gain == 1 &&
+ !gui_grab && !gui_fullscreen && is_active_console(vga_console) &&
+ ds->hw_cursor_size)
+ {
+ sdl_grab_start();
+ }
break;
default:
break;
@@ -491,6 +504,7 @@
ds->dpy_update = sdl_update;
ds->dpy_resize = sdl_resize;
ds->dpy_refresh = sdl_refresh;
+ ds->cursor_release = sdl_cursor_release;
sdl_resize(ds, 640, 400);
sdl_update_caption();
diff -Naur qemu-snapshot-2005-02-10_23/vl.h qemu-snapshot-2005-02-10_23.patched/vl.h
--- qemu-snapshot-2005-02-10_23/vl.h 2005-02-10 23:00:06.000000000 +0100
+++ qemu-snapshot-2005-02-10_23.patched/vl.h 2005-02-26 01:57:41.000000000 +0100
@@ -542,9 +542,11 @@
int depth;
int width;
int height;
+ int hw_cursor_size;
void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
void (*dpy_resize)(struct DisplayState *s, int w, int h);
void (*dpy_refresh)(struct DisplayState *s);
+ void (*cursor_release)(struct DisplayState *s, int x, int y);
};
static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
next reply other threads:[~2005-02-26 15:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-26 15:09 olig9 [this message]
2005-02-27 4:37 ` [Qemu-devel] [Patch] Release mouse at window edges Brad Campbell
2005-02-27 6:16 ` Brad Campbell
2005-03-01 21:28 ` Fabrice Bellard
2005-03-02 4:48 ` Brad Campbell
2005-03-02 9:53 ` Oliver Gerlich
2005-03-02 11:24 ` Hetz Ben Hamo
2005-03-02 20:06 ` olig9
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=6879.1109430585@www57.gmx.net \
--to=olig9@gmx.de \
--cc=qemu-devel@nongnu.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 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.