]> git.proxmox.com Git - qemu.git/commitdiff
Slowdown SDL while minimized
authoraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 13 Mar 2008 19:20:33 +0000 (19:20 +0000)
committeraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 13 Mar 2008 19:20:33 +0000 (19:20 +0000)
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

console.h
sdl.c
vl.c

index b8a5c6d22a313fa171804c3e3e2357b08aaad72a..1e69ffd0ba9408523efaf6dc87325e9bcdf23f58 100644 (file)
--- a/console.h
+++ b/console.h
@@ -71,6 +71,7 @@ struct DisplayState {
     int height;
     void *opaque;
     struct QEMUTimer *gui_timer;
+    uint64_t gui_timer_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);
diff --git a/sdl.c b/sdl.c
index 05a394c7843f4ececa4d45c5cfb1f9b2c527e641..431e5271195cf205dd7bc327d1c5be951ef55715 100644 (file)
--- a/sdl.c
+++ b/sdl.c
@@ -510,6 +510,15 @@ static void sdl_refresh(DisplayState *ds)
                 !ev->active.gain && !gui_fullscreen_initial_grab) {
                 sdl_grab_end();
             }
+            if (ev->active.state & SDL_APPACTIVE) {
+                if (ev->active.gain) {
+                    /* Back to default interval */
+                    ds->gui_timer_interval = 0;
+                } else {
+                    /* Sleeping interval */
+                    ds->gui_timer_interval = 500;
+                }
+            }
             break;
         default:
             break;
diff --git a/vl.c b/vl.c
index 5b9e4ce7a1d138adfb6ec3ff1dc1c3e59182aac8..2019f9f026cc95a3ac9fa9a09c7860218c98c299 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -7208,7 +7208,11 @@ static void gui_update(void *opaque)
 {
     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,
+        (ds->gui_timer_interval ?
+           ds->gui_timer_interval :
+           GUI_REFRESH_INTERVAL)
+       + qemu_get_clock(rt_clock));
 }
 
 struct vm_change_state_entry {