Commit f442e08b418785e13b1161edfa9e0c72cc324c41
1 parent
4c44bdcb
Slowdown SDL while minimized
When SDL is invisible/minimized, there is no need to keep calling the VGA refresh 33 times per second. This patch reduces in that case the rate to 2 times per second, which should be responsive enough for the un-minimizing event. (Samuel Thibault) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4050 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
15 additions
and
1 deletions
console.h
| ... | ... | @@ -71,6 +71,7 @@ struct DisplayState { |
| 71 | 71 | int height; |
| 72 | 72 | void *opaque; |
| 73 | 73 | struct QEMUTimer *gui_timer; |
| 74 | + uint64_t gui_timer_interval; | |
| 74 | 75 | |
| 75 | 76 | void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h); |
| 76 | 77 | void (*dpy_resize)(struct DisplayState *s, int w, int h); | ... | ... |
sdl.c
| ... | ... | @@ -510,6 +510,15 @@ static void sdl_refresh(DisplayState *ds) |
| 510 | 510 | !ev->active.gain && !gui_fullscreen_initial_grab) { |
| 511 | 511 | sdl_grab_end(); |
| 512 | 512 | } |
| 513 | + if (ev->active.state & SDL_APPACTIVE) { | |
| 514 | + if (ev->active.gain) { | |
| 515 | + /* Back to default interval */ | |
| 516 | + ds->gui_timer_interval = 0; | |
| 517 | + } else { | |
| 518 | + /* Sleeping interval */ | |
| 519 | + ds->gui_timer_interval = 500; | |
| 520 | + } | |
| 521 | + } | |
| 513 | 522 | break; |
| 514 | 523 | default: |
| 515 | 524 | break; | ... | ... |
vl.c
| ... | ... | @@ -7208,7 +7208,11 @@ static void gui_update(void *opaque) |
| 7208 | 7208 | { |
| 7209 | 7209 | DisplayState *ds = opaque; |
| 7210 | 7210 | ds->dpy_refresh(ds); |
| 7211 | - qemu_mod_timer(ds->gui_timer, GUI_REFRESH_INTERVAL + qemu_get_clock(rt_clock)); | |
| 7211 | + qemu_mod_timer(ds->gui_timer, | |
| 7212 | + (ds->gui_timer_interval ? | |
| 7213 | + ds->gui_timer_interval : | |
| 7214 | + GUI_REFRESH_INTERVAL) | |
| 7215 | + + qemu_get_clock(rt_clock)); | |
| 7212 | 7216 | } |
| 7213 | 7217 | |
| 7214 | 7218 | struct vm_change_state_entry { | ... | ... |