Skip to contentSkip to conversation

ioemu: Slown down refresh interval when SDL is minimized

PATCH New Samuel Thibault 1 participant 1 message Mar 4, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ioemu: Slown down refresh interval when SDL is minimized

ioemu: Slown down refresh interval when SDL is minimized as that saves us the VGA refresh scanning.

tools/ioemu/sdl.c +9 -0
diff -r c6cd384a48bf tools/ioemu/sdl.c
@@ -515,6 +515,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;
tools/ioemu/vl.c +5 -1
diff -r c6cd384a48bf tools/ioemu/vl.c
@@ -6125,7 +6125,11 @@ void gui_update(void *opaque)
 void gui_update(void *opaque)
 {
     display_state.dpy_refresh(&display_state);
-    qemu_mod_timer(gui_timer, GUI_REFRESH_INTERVAL + qemu_get_clock(rt_clock));
+    qemu_mod_timer(gui_timer,
+            (display_state.gui_timer_interval ?
+                display_state.gui_timer_interval :
+                GUI_REFRESH_INTERVAL)
+            + qemu_get_clock(rt_clock));
 }
 
 struct vm_change_state_entry {
tools/ioemu/vl.h +1 -0
diff -r c6cd384a48bf tools/ioemu/vl.h
@@ -935,6 +935,7 @@ struct DisplayState {
     int width;
     int height;
     void *opaque;
+    uint64_t gui_timer_interval;
 
     int switchbpp;
     int shared_buf;