aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2015-03-12 12:51:13 +0100
committerGerd Hoffmann <kraxel@redhat.com>2015-05-06 08:38:05 +0200
commitcf1ecc82ab84dbfb4b6eea02c329bf9c2aa856ec (patch)
treeec33ad4a194549ac9bd47244c416a7dba26287f4 /ui
parent874e9aeeeb74c5459639a93439a502d262847e68 (diff)
console: delayed ui_info guest notification
So we don't flood the guest with display change notifications while the user resizes the window. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/console.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/ui/console.c b/ui/console.c
index f5295c4688..248dd605f1 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -126,6 +126,7 @@ struct QemuConsole {
Object *device;
uint32_t head;
QemuUIInfo ui_info;
+ QEMUTimer *ui_timer;
const GraphicHwOps *hw_ops;
void *hw;
@@ -1383,14 +1384,28 @@ void unregister_displaychangelistener(DisplayChangeListener *dcl)
gui_setup_refresh(ds);
}
+static void dpy_set_ui_info_timer(void *opaque)
+{
+ QemuConsole *con = opaque;
+
+ con->hw_ops->ui_info(con->hw, con->head, &con->ui_info);
+}
+
int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info)
{
assert(con != NULL);
con->ui_info = *info;
- if (con->hw_ops->ui_info) {
- return con->hw_ops->ui_info(con->hw, con->head, info);
+ if (!con->hw_ops->ui_info) {
+ return -1;
}
- return -1;
+
+ /*
+ * Typically we get a flood of these as the user resizes the window.
+ * Wait until the dust has settled (one second without updates), then
+ * go notify the guest.
+ */
+ timer_mod(con->ui_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 1000);
+ return 0;
}
void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h)
@@ -1724,6 +1739,7 @@ QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head,
ds = get_alloc_displaystate();
trace_console_gfx_new();
s = new_console(ds, GRAPHIC_CONSOLE, head);
+ s->ui_timer = timer_new_ms(QEMU_CLOCK_REALTIME, dpy_set_ui_info_timer, s);
graphic_console_set_hwops(s, hw_ops, opaque);
if (dev) {
object_property_set_link(OBJECT(s), OBJECT(dev), "device",