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)