From patchwork Wed Oct 26 19:04:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 13021172 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D00CC38A2D for ; Wed, 26 Oct 2022 19:22:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onlt8-0005Qt-LR; Wed, 26 Oct 2022 15:16:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onlsv-00059C-0d for qemu-devel@nongnu.org; Wed, 26 Oct 2022 15:16:17 -0400 Received: from mga04.intel.com ([192.55.52.120]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onlss-0001o5-Ex for qemu-devel@nongnu.org; Wed, 26 Oct 2022 15:16:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666811774; x=1698347774; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vG0/Umnus4oxZeDD5SL4LVNoHhqp3Ugt/2pp9G9mp68=; b=KZzz76IK/vj+VyDXlFN2TWZMQI5bF0wmKk1drqmeDY7B2TNr0/9CnGNN hMmbQg01hnhlElKaiqkImMRlP+6nNdKKPCCFKtEmGa7b2ipNtcYkoFPE9 4Z0zx0rMcKnYkkaul67RLBWWxAStTGqkvTMvLtbUhSoZ+/IZ5jAVzzAw2 7cIVj0dMzK6W+8X+ChTMbOiGMBma97VIhBGeLYfmSlW/5eI47si9djtJ9 vppCs65I8PdC1zoH24lT03+UK3g73NUwyHl0TllmTOo3hOrNI1EoFsCVM Y1DI/AvhWyF8ycCbNizLaPf5BxmeiLEJqzSbGUZc6yL5Y+aMdSRh6KXym g==; X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="306769446" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="306769446" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2022 12:16:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="610080569" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="610080569" Received: from dongwonk-z390-aorus-ultra-intel-gfx.fm.intel.com ([10.105.129.122]) by orsmga006.jf.intel.com with ESMTP; 26 Oct 2022 12:16:10 -0700 From: Dongwon Kim To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, berrange@redhat.com, armbru@redhat.com, f4bug@amsat.org, marcandre.lureau@redhat.com, thuth@redhat.com, vivek.kasireddy@intel.com, Dongwon Kim Subject: [RFC PATCH 1/3] ui/gtk: skip drawing guest scanout when associated VC is invisible Date: Wed, 26 Oct 2022 12:04:19 -0700 Message-Id: <20221026190421.16922-2-dongwon.kim@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20221026190421.16922-1-dongwon.kim@intel.com> References: <20221026190421.16922-1-dongwon.kim@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.120; envelope-from=dongwon.kim@intel.com; helo=mga04.intel.com X-Spam_score_int: -48 X-Spam_score: -4.9 X-Spam_bar: ---- X-Spam_report: (-4.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.515, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org A new flag "visible" that shows visibility status of the gfx console. The polarity of the flag determines whether the drawing surface should continuously updated upon scanout flush. The flag is set to 'true' as far as it is in visible state but set to 'false' if its tab is inactivated or untabified window is closed. If set to 'false', QEMU will stop scheduling render events until it is visible again. Cc: Gerd Hoffmann Cc: Daniel P. Berrangé Cc: Markus Armbruster Cc: Philippe Mathieu-Daudé Cc: Marc-André Lureau Cc: Thomas Huth Cc: Vivek Kasireddy Signed-off-by: Dongwon Kim --- include/ui/gtk.h | 1 + ui/gtk-egl.c | 8 ++++++++ ui/gtk-gl-area.c | 8 ++++++++ ui/gtk.c | 11 ++++++++++- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index ae0f53740d..e7c4726aad 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -57,6 +57,7 @@ typedef struct VirtualGfxConsole { bool y0_top; bool scanout_mode; bool has_dmabuf; + bool visible; #endif } VirtualGfxConsole; diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 35f917ceb1..a5944f7095 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -247,6 +247,10 @@ void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl, #ifdef CONFIG_GBM VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); + if (!vc->gfx.visible) { + return; + } + eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, vc->gfx.esurface, vc->gfx.ectx); @@ -341,6 +345,10 @@ void gd_egl_flush(DisplayChangeListener *dcl, VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); GtkWidget *area = vc->gfx.drawing_area; + if (!vc->gfx.visible) { + return; + } + if (vc->gfx.guest_fb.dmabuf) { graphic_hw_gl_block(vc->gfx.dcl.con, true); vc->gfx.guest_fb.dmabuf->draw_submitted = true; diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index 682638a197..14390ac9a9 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -278,6 +278,10 @@ void gd_gl_area_scanout_flush(DisplayChangeListener *dcl, { VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); + if (!vc->gfx.visible) { + return; + } + if (vc->gfx.guest_fb.dmabuf) { graphic_hw_gl_block(vc->gfx.dcl.con, true); vc->gfx.guest_fb.dmabuf->draw_submitted = true; @@ -291,6 +295,10 @@ void gd_gl_area_scanout_dmabuf(DisplayChangeListener *dcl, #ifdef CONFIG_GBM VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); + if (!vc->gfx.visible) { + return; + } + gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area)); egl_dmabuf_import_texture(dmabuf); if (!dmabuf->texture) { diff --git a/ui/gtk.c b/ui/gtk.c index 92daaa6a6e..a1fb42f34d 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1268,15 +1268,20 @@ static void gd_menu_quit(GtkMenuItem *item, void *opaque) static void gd_menu_switch_vc(GtkMenuItem *item, void *opaque) { GtkDisplayState *s = opaque; - VirtualConsole *vc = gd_vc_find_by_menu(s); + VirtualConsole *vc; GtkNotebook *nb = GTK_NOTEBOOK(s->notebook); gint page; + vc = gd_vc_find_current(s); + vc->gfx.visible = false; + + vc = gd_vc_find_by_menu(s); gtk_release_modifiers(s); if (vc) { page = gtk_notebook_page_num(nb, vc->tab_item); gtk_notebook_set_current_page(nb, page); gtk_widget_grab_focus(vc->focus); + vc->gfx.visible = true; } } @@ -1306,6 +1311,7 @@ static gboolean gd_tab_window_close(GtkWidget *widget, GdkEvent *event, VirtualConsole *vc = opaque; GtkDisplayState *s = vc->s; + vc->gfx.visible = false; gtk_widget_set_sensitive(vc->menu_item, true); gd_widget_reparent(vc->window, s->notebook, vc->tab_item); gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(s->notebook), @@ -1379,6 +1385,7 @@ static void gd_menu_untabify(GtkMenuItem *item, void *opaque) gd_update_geometry_hints(vc); gd_update_caption(s); } + vc->gfx.visible = true; } static void gd_menu_show_menubar(GtkMenuItem *item, void *opaque) @@ -2404,6 +2411,8 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts) gtk_menu_item_activate(GTK_MENU_ITEM(s->show_tabs_item)); } gd_clipboard_init(s); + + vc->gfx.visible = true; } static void early_gtk_display_init(DisplayOptions *opts) From patchwork Wed Oct 26 19:04:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 13021166 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 966AAC433FE for ; Wed, 26 Oct 2022 19:19:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onlt9-0005Qx-Uh; Wed, 26 Oct 2022 15:16:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onlsw-00059n-52 for qemu-devel@nongnu.org; Wed, 26 Oct 2022 15:16:20 -0400 Received: from mga04.intel.com ([192.55.52.120]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onlsu-0001oA-AR for qemu-devel@nongnu.org; Wed, 26 Oct 2022 15:16:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666811776; x=1698347776; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VyhdR+JFZF3vUvMpGHJWvJ8DCkfPBmGnMQymf00KSJg=; b=nUB0dL5HZ+mBWxGq+5Hle1DWl1i8dmKrzCEu/RQ5rn05pj0+F2J0sbL0 wPsT0aM8YbzDdY4X8XSXiDMeObNkfhsAwraZ7Y84+G70m4teAgd/vkqvo 5cCG37x1uqueQrMeTwYZ46XM8Hzl8pZSpigwhG83xaX0A3QmruHnAKjp+ gJSQSftnQ5A2fHLtlRqgc/ryKdpsn5U5tWjoWQpgRYMe4GIQrtIaZKEUO f4tn7Nz31e22oE9D/S6OSCGau2mfCCtaWNlE0X8fcvafDVSiOISvmaQHi 4LwWKKWpufw6qmS8hPuC7AY4KsX2Zax67e/NNkhoH/jcWl2qh3gLI9P4C Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="306769452" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="306769452" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2022 12:16:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="610080572" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="610080572" Received: from dongwonk-z390-aorus-ultra-intel-gfx.fm.intel.com ([10.105.129.122]) by orsmga006.jf.intel.com with ESMTP; 26 Oct 2022 12:16:11 -0700 From: Dongwon Kim To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, berrange@redhat.com, armbru@redhat.com, f4bug@amsat.org, marcandre.lureau@redhat.com, thuth@redhat.com, vivek.kasireddy@intel.com, Dongwon Kim Subject: [RFC PATCH 2/3] ui/gtk: set the ui size to 0 when invisible Date: Wed, 26 Oct 2022 12:04:20 -0700 Message-Id: <20221026190421.16922-3-dongwon.kim@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20221026190421.16922-1-dongwon.kim@intel.com> References: <20221026190421.16922-1-dongwon.kim@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.120; envelope-from=dongwon.kim@intel.com; helo=mga04.intel.com X-Spam_score_int: -48 X-Spam_score: -4.9 X-Spam_bar: ---- X-Spam_report: (-4.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.515, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Make guest displays disconnected when not visible. Setting ui size to 0 is used to indicate that the display is disconnected. When the VC is visible again, the ui size is set to associated window's size again which makes the display reconnected and available to the guest. Cc: Gerd Hoffmann Cc: Daniel P. Berrangé Cc: Markus Armbruster Cc: Philippe Mathieu-Daudé Cc: Marc-André Lureau Cc: Thomas Huth Cc: Vivek Kasireddy Signed-off-by: Dongwon Kim --- ui/gtk.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ui/gtk.c b/ui/gtk.c index a1fb42f34d..46c3135f6d 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1270,10 +1270,12 @@ static void gd_menu_switch_vc(GtkMenuItem *item, void *opaque) GtkDisplayState *s = opaque; VirtualConsole *vc; GtkNotebook *nb = GTK_NOTEBOOK(s->notebook); + GdkWindow *window; gint page; vc = gd_vc_find_current(s); vc->gfx.visible = false; + gd_set_ui_size(vc, 0, 0); vc = gd_vc_find_by_menu(s); gtk_release_modifiers(s); @@ -1281,6 +1283,9 @@ static void gd_menu_switch_vc(GtkMenuItem *item, void *opaque) page = gtk_notebook_page_num(nb, vc->tab_item); gtk_notebook_set_current_page(nb, page); gtk_widget_grab_focus(vc->focus); + window = gtk_widget_get_window(vc->gfx.drawing_area); + gd_set_ui_size(vc, gdk_window_get_width(window), + gdk_window_get_height(window)); vc->gfx.visible = true; } } @@ -1312,6 +1317,7 @@ static gboolean gd_tab_window_close(GtkWidget *widget, GdkEvent *event, GtkDisplayState *s = vc->s; vc->gfx.visible = false; + gd_set_ui_size(vc, 0, 0); gtk_widget_set_sensitive(vc->menu_item, true); gd_widget_reparent(vc->window, s->notebook, vc->tab_item); gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(s->notebook), @@ -1347,6 +1353,7 @@ static gboolean gd_win_grab(void *opaque) static void gd_menu_untabify(GtkMenuItem *item, void *opaque) { GtkDisplayState *s = opaque; + GdkWindow *window; VirtualConsole *vc = gd_vc_find_current(s); if (vc->type == GD_VC_GFX && @@ -1385,6 +1392,10 @@ static void gd_menu_untabify(GtkMenuItem *item, void *opaque) gd_update_geometry_hints(vc); gd_update_caption(s); } + + window = gtk_widget_get_window(vc->gfx.drawing_area); + gd_set_ui_size(vc, gdk_window_get_width(window), + gdk_window_get_height(window)); vc->gfx.visible = true; } @@ -1709,7 +1720,9 @@ static gboolean gd_configure(GtkWidget *widget, { VirtualConsole *vc = opaque; - gd_set_ui_size(vc, cfg->width, cfg->height); + if (vc->gfx.visible) { + gd_set_ui_size(vc, cfg->width, cfg->height); + } return FALSE; } From patchwork Wed Oct 26 19:04:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 13021175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 69575C38A2D for ; Wed, 26 Oct 2022 19:24:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onltD-0005Su-6y; Wed, 26 Oct 2022 15:16:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onlsy-00059w-QL for qemu-devel@nongnu.org; Wed, 26 Oct 2022 15:16:24 -0400 Received: from mga04.intel.com ([192.55.52.120]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onlsv-0001o2-JD for qemu-devel@nongnu.org; Wed, 26 Oct 2022 15:16:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666811777; x=1698347777; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DRauN6rnLmMthJgj2sEcAPWQLRjyDdd1lWVuhQCwvVI=; b=ahaO/wrblLRnGTNLLziXEN/CdjnmuOVYjkP2q+5k+vvDRYIRvi98jfkn MZq1tEQsLb2b8oFdLboVFg5Q7ZD+BOQrXfQTbV77X75lO+zXFyN4co3OW z1sqVqfQvVdRL8iM2nD5Vaben/IYWFdXtltJm9BPPN83ZRTyPBXH0Mmcn HkAv8IogAc/n4ZNDHKk5PjeaYCyVFk1sXP5xD8N5FPc5thVyzbYqSwxZd X8o/7cQ1kiHrm9IKXTBXue/VTVXU6PhPEXg7CGGdoIs/cxtqFVZ4GhccI kLHo9w6oeO8B8COIhu5QoxH0vs2ZaVtI3UVuWgQ3zbd4weOyfzJ3GbqEJ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="306769455" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="306769455" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2022 12:16:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="610080575" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="610080575" Received: from dongwonk-z390-aorus-ultra-intel-gfx.fm.intel.com ([10.105.129.122]) by orsmga006.jf.intel.com with ESMTP; 26 Oct 2022 12:16:12 -0700 From: Dongwon Kim To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, berrange@redhat.com, armbru@redhat.com, f4bug@amsat.org, marcandre.lureau@redhat.com, thuth@redhat.com, vivek.kasireddy@intel.com, Dongwon Kim Subject: [RFC PATCH 3/3] ui/gtk: reset visible flag when window is minimized Date: Wed, 26 Oct 2022 12:04:21 -0700 Message-Id: <20221026190421.16922-4-dongwon.kim@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20221026190421.16922-1-dongwon.kim@intel.com> References: <20221026190421.16922-1-dongwon.kim@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.120; envelope-from=dongwon.kim@intel.com; helo=mga04.intel.com X-Spam_score_int: -48 X-Spam_score: -4.9 X-Spam_bar: ---- X-Spam_report: (-4.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.515, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add a callback for window-state-event that resets vc->gfx.visible when associated window is minimized and vice versa. Cc: Gerd Hoffmann Cc: Daniel P. Berrangé Cc: Markus Armbruster Cc: Philippe Mathieu-Daudé Cc: Marc-André Lureau Cc: Thomas Huth Cc: Vivek Kasireddy Signed-off-by: Dongwon Kim --- ui/gtk.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ui/gtk.c b/ui/gtk.c index 46c3135f6d..a81ff287cb 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1337,6 +1337,24 @@ static gboolean gd_tab_window_close(GtkWidget *widget, GdkEvent *event, return TRUE; } +static gboolean gd_window_state_event(GtkWidget *widget, GdkEvent *event, + void *opaque) +{ + VirtualConsole *vc = opaque; + + if (!vc) { + return TRUE; + } + + if (event->window_state.new_window_state & GDK_WINDOW_STATE_ICONIFIED) { + vc->gfx.visible = false; + } else { + vc->gfx.visible = true; + } + + return TRUE; +} + static gboolean gd_win_grab(void *opaque) { VirtualConsole *vc = opaque; @@ -1378,6 +1396,9 @@ static void gd_menu_untabify(GtkMenuItem *item, void *opaque) g_signal_connect(vc->window, "delete-event", G_CALLBACK(gd_tab_window_close), vc); + g_signal_connect(vc->window, "window-state-event", + G_CALLBACK(gd_window_state_event), vc); + gtk_widget_show_all(vc->window); if (qemu_console_is_graphic(vc->gfx.dcl.con)) { @@ -2027,7 +2048,9 @@ static void gd_connect_signals(GtkDisplayState *s) g_signal_connect(s->window, "delete-event", G_CALLBACK(gd_window_close), s); - + g_signal_connect(s->window, "window-state-event", + G_CALLBACK(gd_window_state_event), + gd_vc_find_current(s)); g_signal_connect(s->pause_item, "activate", G_CALLBACK(gd_menu_pause), s); g_signal_connect(s->reset_item, "activate",