diff -ur kvm-45.orig/qemu/sdl.c kvm-45/qemu/sdl.c --- kvm-45.orig/qemu/sdl.c 2007-10-02 10:36:33.000000000 +0200 +++ kvm-45/qemu/sdl.c 2007-10-07 08:32:38.000000000 +0200 @@ -47,6 +47,8 @@ static int guest_cursor = 0; static int guest_x, guest_y; static SDL_Cursor *guest_sprite = 0; +static int decimate_counter = 0; +static int idle_counter = 0; static void sdl_update(DisplayState *ds, int x, int y, int w, int h) { @@ -347,17 +349,24 @@ vga_hw_update(); } +#define SDL_IDLE_THRESHOLD 10 +#define SDL_DECIMATE 3 + static void sdl_refresh(DisplayState *ds) { SDL_Event ev1, *ev = &ev1; int mod_state; + int was_idle = 1; if (last_vm_running != vm_running) { last_vm_running = vm_running; sdl_update_caption(); } - vga_hw_update(); + if (idle_counter < SDL_IDLE_THRESHOLD || decimate_counter == 0) + vga_hw_update(); + + decimate_counter = (decimate_counter + 1) % SDL_DECIMATE; while (SDL_PollEvent(ev)) { switch (ev->type) { @@ -366,6 +375,7 @@ break; case SDL_KEYDOWN: case SDL_KEYUP: + was_idle = 0; if (ev->type == SDL_KEYDOWN) { if (!alt_grab) { mod_state = (SDL_GetModState() & gui_grab_code) == @@ -476,6 +486,7 @@ } break; case SDL_MOUSEMOTION: + was_idle = 0; if (gui_grab || kbd_mouse_is_absolute() || absolute_enabled) { sdl_send_mouse_event(0); @@ -483,6 +494,7 @@ break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: + was_idle = 0; { SDL_MouseButtonEvent *bev = &ev->button; if (!gui_grab && !kbd_mouse_is_absolute()) { @@ -515,6 +527,13 @@ break; } } + + if (was_idle) { + if (idle_counter < SDL_IDLE_THRESHOLD) + idle_counter++; + } else { + idle_counter = 0; + } } static void sdl_fill(DisplayState *ds, int x, int y, int w, int h, uint32_t c) @@ -627,6 +646,7 @@ ds->dpy_fill = sdl_fill; ds->mouse_set = sdl_mouse_warp; ds->cursor_define = sdl_mouse_define; + ds->refresh_interval = 10; sdl_resize(ds, 640, 400); sdl_update_caption(); diff -ur kvm-45.orig/qemu/vl.c kvm-45/qemu/vl.c --- kvm-45.orig/qemu/vl.c 2007-10-02 10:36:33.000000000 +0200 +++ kvm-45/qemu/vl.c 2007-10-07 08:34:01.000000000 +0200 @@ -142,7 +142,7 @@ #define DEFAULT_RAM_SIZE 128 #endif /* in ms */ -#define GUI_REFRESH_INTERVAL 30 +#define DEFAULT_GUI_REFRESH_INTERVAL 30 /* Max number of USB devices that can be specified on the commandline. */ #define MAX_USB_CMDLINE 8 @@ -4918,6 +4918,7 @@ ds->dpy_update = dumb_update; ds->dpy_resize = dumb_resize; ds->dpy_refresh = dumb_refresh; + ds->refresh_interval = DEFAULT_GUI_REFRESH_INTERVAL; } /***********************************************************/ @@ -6913,7 +6914,7 @@ { DisplayState *ds = opaque; ds->dpy_refresh(ds); - qemu_mod_timer(ds->gui_timer, GUI_REFRESH_INTERVAL + qemu_get_clock(rt_clock)); + qemu_mod_timer(ds->gui_timer, display_state.refresh_interval + qemu_get_clock(rt_clock)); } struct vm_change_state_entry { diff -ur kvm-45.orig/qemu/vl.h kvm-45/qemu/vl.h --- kvm-45.orig/qemu/vl.h 2007-10-02 10:36:33.000000000 +0200 +++ kvm-45/qemu/vl.h 2007-10-07 08:33:36.000000000 +0200 @@ -970,6 +970,7 @@ int height; void *opaque; QEMUTimer *gui_timer; + int refresh_interval; void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h); void (*dpy_resize)(struct DisplayState *s, int w, int h);