From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yqgm3-0005IJ-Ey for qemu-devel@nongnu.org; Fri, 08 May 2015 07:49:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yqgm2-0000jL-LL for qemu-devel@nongnu.org; Fri, 08 May 2015 07:48:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35903) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yqgm2-0000jA-H7 for qemu-devel@nongnu.org; Fri, 08 May 2015 07:48:58 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 2571CB813C for ; Fri, 8 May 2015 11:48:58 +0000 (UTC) From: Gerd Hoffmann Date: Fri, 8 May 2015 13:48:47 +0200 Message-Id: <1431085731-6362-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1431085731-6362-1-git-send-email-kraxel@redhat.com> References: <1431085731-6362-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 1/5] console: delayed ui_info guest notification List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann So we don't flood the guest with display change notifications while the user resizes the window. Signed-off-by: Gerd Hoffmann --- ui/console.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ui/console.c b/ui/console.c index f5295c4..248dd60 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", -- 1.8.3.1