From patchwork Wed Jun 21 00:43:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 13286523 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 BA1A3EB64D8 for ; Wed, 21 Jun 2023 01:04:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBmGC-0007ml-Mt; Tue, 20 Jun 2023 21:03:48 -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 1qBmGA-0007mL-QR for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:46 -0400 Received: from mga11.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBmG8-0001GW-TG for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687309424; x=1718845424; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3lzjvxFJKYJyk+nzcElwzHCDA3yRPOKrv0YkI3O6ra4=; b=W4lRqY706T9yoFDDWUVBizJeI4RgUk/pzZT6E6e7a3m1y3iBfoaBSEG2 fhjxbEI9JmgjC/fXwY/ZZStzb0A3KCMyLuKWCyd/T0+bvHylBsEYsNbG3 9GO1m9ySDoE02M+YLdK6GBeN3XnxPAcXcfTE0oYsk5L7Q6fDQm4fHlYCX fLDsa2P4jn8pI9AfFW+FkhebiZ3x5jv+yka2Lu1sC2SrWyXoXhwpvgXAa Wlf+6QoHGXM3aXTV0T+ZPJTJOlrLjoiWWGBGfY9bjQQpv3f0btU5ZqxIC DVPWPX8w+oeGbHVH/nOgYtyRyuVNxl10RQXDMk6mviNf/QLkgE6Gp8USo Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="357522803" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="357522803" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2023 18:03:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="838429551" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="838429551" Received: from dongwonk-z390-aorus-ultra-intel-gfx.fm.intel.com ([10.105.129.122]) by orsmga004.jf.intel.com with ESMTP; 20 Jun 2023 18:03:38 -0700 From: Dongwon Kim To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, berrange@redhat.com, armbru@redhat.com, philmd@linaro.org, marcandre.lureau@redhat.com, vivek.kasireddy@intel.com, Dongwon Kim Subject: [RFC PATCH 1/9] ui/gtk: skip drawing guest scanout when associated VC is invisible Date: Tue, 20 Jun 2023 17:43:47 -0700 Message-Id: <20230621004355.19920-2-dongwon.kim@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230621004355.19920-1-dongwon.kim@intel.com> References: <20230621004355.19920-1-dongwon.kim@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.93; envelope-from=dongwon.kim@intel.com; helo=mga11.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org A new flag "visible" that specifies 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' when the window bound to the VC is in visible state but set to 'false' when the window is inactivated or closed. When invisible, QEMU will skip any of draw events. Cc: Gerd Hoffmann Cc: Daniel P. Berrangé Cc: Markus Armbruster Cc: Philippe Mathieu-Daudé Cc: Marc-André Lureau 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 | 10 +++++++++- 4 files changed, 26 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 19130041bc..443873e266 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 && !vc->gfx.guest_fb.dmabuf->draw_submitted) { 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 c384a1516b..68b16a5ff1 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 && !vc->gfx.guest_fb.dmabuf->draw_submitted) { 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 e50f950f2b..84c50d835e 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1350,15 +1350,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; } } @@ -1388,6 +1393,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), @@ -1461,6 +1467,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) @@ -2499,6 +2506,7 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts) #ifdef CONFIG_GTK_CLIPBOARD gd_clipboard_init(s); #endif /* CONFIG_GTK_CLIPBOARD */ + vc->gfx.visible = true; } static void early_gtk_display_init(DisplayOptions *opts) From patchwork Wed Jun 21 00:43:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 13286528 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 A7321EB64D7 for ; Wed, 21 Jun 2023 01:05:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBmGE-0007ns-AU; Tue, 20 Jun 2023 21:03:50 -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 1qBmGC-0007ma-2A for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:48 -0400 Received: from mga11.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBmG8-0001Gy-OG for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687309424; x=1718845424; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RefJekrSGuk5pNLcoaQG7BqPnJIgpirHosYa5MtoteM=; b=XLD1akbbg92UhdPrp9Wj6OvrIpq7JWS+JDR32JmdXxBg9s4eReX664Nr naHsLsV7hzQXnkhLQC0a/g0gLVzyGERWMKIneT+TBH6uqQd0Uu+CEN6wm dAi2ZpYaZ3EDYpMDuHRLjE9zofKXnCt+LoRmi7EcN400CHPwIdkmF8+QK Kot5gBAdtYX7xcxQ88MOES+BN2vRAKdDqrUiNJmaqeaEuR7tbR4WcIdPh xJ5ykEJL+zSwPUMgF7hZ0yYNPUmTR7jI3vmbzS+qbNP/FujJOA7hGvNJV i5X+p9/ZVAP6NurpvpIc1R4r8ckxV+LpYyRK5M2b3NYPeU1a+jTnLiPGm g==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="357522808" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="357522808" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2023 18:03:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="838429556" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="838429556" Received: from dongwonk-z390-aorus-ultra-intel-gfx.fm.intel.com ([10.105.129.122]) by orsmga004.jf.intel.com with ESMTP; 20 Jun 2023 18:03:39 -0700 From: Dongwon Kim To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, berrange@redhat.com, armbru@redhat.com, philmd@linaro.org, marcandre.lureau@redhat.com, vivek.kasireddy@intel.com, Dongwon Kim Subject: [RFC PATCH 2/9] ui/gtk: set the ui size to 0 when invisible Date: Tue, 20 Jun 2023 17:43:48 -0700 Message-Id: <20230621004355.19920-3-dongwon.kim@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230621004355.19920-1-dongwon.kim@intel.com> References: <20230621004355.19920-1-dongwon.kim@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.93; envelope-from=dongwon.kim@intel.com; helo=mga11.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Getting guest displays disconnected by setting ui size to 0 when the VC is set as invisible. When the VC is set as visible again, the ui size is restored back to its previous size to reconnect guest displays. Cc: Gerd Hoffmann Cc: Daniel P. Berrangé Cc: Markus Armbruster Cc: Philippe Mathieu-Daudé Cc: Marc-André Lureau 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 84c50d835e..ff4a5c58ea 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1352,10 +1352,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); @@ -1363,6 +1365,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; } } @@ -1394,6 +1399,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), @@ -1429,6 +1435,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 && @@ -1467,6 +1474,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; } @@ -1791,7 +1802,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 Jun 21 00:43:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 13286522 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 ABEFFEB64D7 for ; Wed, 21 Jun 2023 01:04:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBmGF-0007oZ-1z; Tue, 20 Jun 2023 21:03:51 -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 1qBmGC-0007nF-Ve for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:48 -0400 Received: from mga11.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBmGB-0001GW-3s for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687309427; x=1718845427; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8ecAhgIN3FOozG45b0VPagWbfpHdvTXwa+wo0o/M2p8=; b=QAyRfyJracLCMnGxqnOCWRVRW+eiILo/V6TKZjqV2ierXC7qA2pEnv+4 E2mv6fEqrNEoV99RgQk1NmotByRW7MBY58klmNGC8+55iHVNNZ4pBReRj U7TdA5RPTqJEL0ZC9z82xz0+tb5ekHycvPGBv9J6fy+GlS0qJi4894B+/ kH7VhuL6C7moKzlClSOfqakcV6ufu/KNEabk7PaKZvVU2UkQ3YRE9oIP7 VhaBZooFayUXciO348IpcLql0JVO05aWBIsizqaZ1EiiGH2n3geB8WpwO Om0eK5A0KFDt8+6TcX7TUUgZxfkuhVMN1kfIzBTnKJVbawScrxQVWaDRv Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="357522813" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="357522813" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2023 18:03:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="838429561" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="838429561" Received: from dongwonk-z390-aorus-ultra-intel-gfx.fm.intel.com ([10.105.129.122]) by orsmga004.jf.intel.com with ESMTP; 20 Jun 2023 18:03:40 -0700 From: Dongwon Kim To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, berrange@redhat.com, armbru@redhat.com, philmd@linaro.org, marcandre.lureau@redhat.com, vivek.kasireddy@intel.com, Dongwon Kim Subject: [RFC PATCH 3/9] ui/gtk: reset visible flag when window is minimized Date: Tue, 20 Jun 2023 17:43:49 -0700 Message-Id: <20230621004355.19920-4-dongwon.kim@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230621004355.19920-1-dongwon.kim@intel.com> References: <20230621004355.19920-1-dongwon.kim@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.93; envelope-from=dongwon.kim@intel.com; helo=mga11.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: 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 or restored. In case of virtio-gpu blob scanout, if the window is minimized before the rendering event for the last guest scanout frame is finished, it cancels the draw submission and unblocks the pipeline to prevent a permanent lockup. Cc: Gerd Hoffmann Cc: Daniel P. Berrangé Cc: Markus Armbruster Cc: Philippe Mathieu-Daudé Cc: Marc-André Lureau Cc: Vivek Kasireddy Signed-off-by: Dongwon Kim --- ui/gtk.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/ui/gtk.c b/ui/gtk.c index ff4a5c58ea..f9096aea14 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1419,6 +1419,35 @@ 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; + gd_set_ui_size(vc, 0, 0); + if (vc->gfx.guest_fb.dmabuf && + vc->gfx.guest_fb.dmabuf->draw_submitted) { + vc->gfx.guest_fb.dmabuf->draw_submitted = false; + graphic_hw_gl_block(vc->gfx.dcl.con, false); + } + } else { + GdkWindow *window; + 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; + } + + return TRUE; +} + static gboolean gd_win_grab(void *opaque) { VirtualConsole *vc = opaque; @@ -1460,6 +1489,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)) { @@ -2498,6 +2530,11 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts) } vc = gd_vc_find_current(s); + + g_signal_connect(s->window, "window-state-event", + G_CALLBACK(gd_window_state_event), + vc); + gtk_widget_set_sensitive(s->view_menu, vc != NULL); #ifdef CONFIG_VTE gtk_widget_set_sensitive(s->copy_item, From patchwork Wed Jun 21 00:43:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 13286527 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 6CE51EB64D8 for ; Wed, 21 Jun 2023 01:05:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBmGE-0007oI-GC; Tue, 20 Jun 2023 21:03:50 -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 1qBmGC-0007nC-RO for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:48 -0400 Received: from mga11.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBmGB-0001Fp-3H for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687309427; x=1718845427; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NzRNLrigI1mTX2rfYDAoYeRMXBVawCRCZ4B/zs9bAh4=; b=Ll4JLANsvskJi0GlYGsedDV7pkEzdMOCSgDDm0BBcZSgy6rZ3ZoIRabJ kCVzFR/2334GDajbB63t8MqrYAd7EzOOaf16BWHQCIcuDdGUsUTO9zipq lwLvQ8z/S2A1dW1lbuJ3vuomqkKSMZgNIc/vYTmDJVwEIR4x78eQMVYVT xp0QkPtHnPsgo4jSh4G8weXWOW8qpI6tIUVmD81b9I5oX3KzDyhFw12u5 RYEaikf6Ru622dWUjKlsH8R+yD845mF07tcZB/jmsXBS+nplsYwLFF6ik Tw2Iol/15ZcAB40EdGEBbqvMM1Nncd4xXJod7MdvpGA+95a7YG1kfoGrC A==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="357522819" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="357522819" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2023 18:03:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="838429566" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="838429566" Received: from dongwonk-z390-aorus-ultra-intel-gfx.fm.intel.com ([10.105.129.122]) by orsmga004.jf.intel.com with ESMTP; 20 Jun 2023 18:03:41 -0700 From: Dongwon Kim To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, berrange@redhat.com, armbru@redhat.com, philmd@linaro.org, marcandre.lureau@redhat.com, vivek.kasireddy@intel.com, Dongwon Kim Subject: [RFC PATCH 4/9] ui/gtk: Disable the scanout when a detached tab is closed Date: Tue, 20 Jun 2023 17:43:50 -0700 Message-Id: <20230621004355.19920-5-dongwon.kim@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230621004355.19920-1-dongwon.kim@intel.com> References: <20230621004355.19920-1-dongwon.kim@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.93; envelope-from=dongwon.kim@intel.com; helo=mga11.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Vivek Kasireddy When a detached tab window is closed, the underlying (EGL) context is destroyed; therefore, disable the scanout which also destroys the underlying framebuffer (id) and other objects. Also add calls to make the context current in disable scanout and other missing places. Cc: Gerd Hoffmann Cc: Daniel P. Berrangé Cc: Markus Armbruster Cc: Philippe Mathieu-Daudé Cc: Marc-André Lureau Signed-off-by: Vivek Kasireddy Signed-off-by: Dongwon Kim --- ui/gtk-egl.c | 3 +++ ui/gtk-gl-area.c | 2 ++ ui/gtk.c | 1 + 3 files changed, 6 insertions(+) diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 443873e266..aa22ebbd98 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -214,6 +214,9 @@ void gd_egl_scanout_disable(DisplayChangeListener *dcl) { VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); + eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, + vc->gfx.esurface, vc->gfx.ectx); + vc->gfx.w = 0; vc->gfx.h = 0; gtk_egl_set_scanout_mode(vc, false); diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index 68b16a5ff1..8228cc9f3f 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -270,6 +270,7 @@ void gd_gl_area_scanout_disable(DisplayChangeListener *dcl) { VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); + gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area)); gtk_gl_area_set_scanout_mode(vc, false); } @@ -282,6 +283,7 @@ void gd_gl_area_scanout_flush(DisplayChangeListener *dcl, return; } + gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area)); if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) { graphic_hw_gl_block(vc->gfx.dcl.con, true); vc->gfx.guest_fb.dmabuf->draw_submitted = true; diff --git a/ui/gtk.c b/ui/gtk.c index f9096aea14..90ecb8b82f 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1400,6 +1400,7 @@ static gboolean gd_tab_window_close(GtkWidget *widget, GdkEvent *event, vc->gfx.visible = false; gd_set_ui_size(vc, 0, 0); + dpy_gl_scanout_disable(vc->gfx.dcl.con); 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), From patchwork Wed Jun 21 00:43:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 13286521 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 9C01EEB64D7 for ; Wed, 21 Jun 2023 01:04:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBmGF-0007ox-PT; Tue, 20 Jun 2023 21:03:51 -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 1qBmGE-0007nz-8c for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:50 -0400 Received: from mga11.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBmGC-0001Gy-Cj for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687309428; x=1718845428; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hy79wK9DpN3H5yoP1fsmyNoeHbhQG7E7cc12uKXGjIw=; b=WFqtmKPGE2g+X3D/C6LaCB2TCu1u3Q4TpIlxdeS86829iO87lgy8CUNt X7w1gttOAM0Y4xBiIda9ZTQaKDK3u6OfkjfDuanbNn7bUjIUZOH7EZL3q Rh/QxmY1biiFxjUWIjD5yhswZKmz6dBiRspsol3o9Ca7DbLan/XAEQ3Cw KCVsESjRlLeXY5ieua1nbbR2l777Zbu02OYGdmZ+nNykQjzKGEkQC+5pz bUAvgtyXeu7wvVUarwtGp56jR1k3AebGSH3bEY3CvTK6dWGWxKrO9QkxR MLeug9qv6D6yeP2HiTpu8EPp9VUwxtEi5ClGJwN4BUhcHPR9YMY9TYU0L A==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="357522825" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="357522825" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2023 18:03:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="838429569" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="838429569" Received: from dongwonk-z390-aorus-ultra-intel-gfx.fm.intel.com ([10.105.129.122]) by orsmga004.jf.intel.com with ESMTP; 20 Jun 2023 18:03:42 -0700 From: Dongwon Kim To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, berrange@redhat.com, armbru@redhat.com, philmd@linaro.org, marcandre.lureau@redhat.com, vivek.kasireddy@intel.com, Dongwon Kim Subject: [RFC PATCH 5/9] ui/gtk: Factor out tab window creation into a separate function Date: Tue, 20 Jun 2023 17:43:51 -0700 Message-Id: <20230621004355.19920-6-dongwon.kim@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230621004355.19920-1-dongwon.kim@intel.com> References: <20230621004355.19920-1-dongwon.kim@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.93; envelope-from=dongwon.kim@intel.com; helo=mga11.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Vivek Kasireddy Pull the code that creates a new window associated with a notebook tab into a separate function. This new function can be useful not just when user wants to detach a tab but also in the future when a new window creation is needed in other scenarios. Cc: Gerd Hoffmann Cc: Daniel P. Berrangé Cc: Markus Armbruster Cc: Philippe Mathieu-Daudé Cc: Marc-André Lureau Signed-off-by: Vivek Kasireddy Signed-off-by: Dongwon Kim --- ui/gtk.c | 71 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index 90ecb8b82f..d8323a3a9d 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1462,6 +1462,44 @@ static gboolean gd_win_grab(void *opaque) return TRUE; } +static void gd_tab_window_create(VirtualConsole *vc) +{ + GtkDisplayState *s = vc->s; + + gtk_widget_set_sensitive(vc->menu_item, false); + vc->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(vc->window), + surface_width(vc->gfx.ds), + surface_height(vc->gfx.ds)); +#if defined(CONFIG_OPENGL) + if (vc->gfx.esurface) { + eglDestroySurface(qemu_egl_display, vc->gfx.esurface); + vc->gfx.esurface = NULL; + } + if (vc->gfx.ectx) { + eglDestroyContext(qemu_egl_display, vc->gfx.ectx); + vc->gfx.ectx = NULL; + } +#endif + gd_widget_reparent(s->notebook, vc->window, vc->tab_item); + + g_signal_connect(vc->window, "delete-event", + G_CALLBACK(gd_tab_window_close), vc); + gtk_widget_show_all(vc->window); + + if (qemu_console_is_graphic(vc->gfx.dcl.con)) { + GtkAccelGroup *ag = gtk_accel_group_new(); + gtk_window_add_accel_group(GTK_WINDOW(vc->window), ag); + + GClosure *cb = g_cclosure_new_swap(G_CALLBACK(gd_win_grab), + vc, NULL); + gtk_accel_group_connect(ag, GDK_KEY_g, HOTKEY_MODIFIERS, 0, cb); + } + + gd_update_geometry_hints(vc); + gd_update_caption(s); +} + static void gd_menu_untabify(GtkMenuItem *item, void *opaque) { GtkDisplayState *s = opaque; @@ -1474,38 +1512,7 @@ static void gd_menu_untabify(GtkMenuItem *item, void *opaque) FALSE); } if (!vc->window) { - gtk_widget_set_sensitive(vc->menu_item, false); - vc->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); -#if defined(CONFIG_OPENGL) - if (vc->gfx.esurface) { - eglDestroySurface(qemu_egl_display, vc->gfx.esurface); - vc->gfx.esurface = NULL; - } - if (vc->gfx.esurface) { - eglDestroyContext(qemu_egl_display, vc->gfx.ectx); - vc->gfx.ectx = NULL; - } -#endif - gd_widget_reparent(s->notebook, vc->window, vc->tab_item); - - 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)) { - GtkAccelGroup *ag = gtk_accel_group_new(); - gtk_window_add_accel_group(GTK_WINDOW(vc->window), ag); - - GClosure *cb = g_cclosure_new_swap(G_CALLBACK(gd_win_grab), - vc, NULL); - gtk_accel_group_connect(ag, GDK_KEY_g, HOTKEY_MODIFIERS, 0, cb); - } - - gd_update_geometry_hints(vc); - gd_update_caption(s); + gd_tab_window_create(vc); } window = gtk_widget_get_window(vc->gfx.drawing_area); From patchwork Wed Jun 21 00:43:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 13286530 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 96503EB64D7 for ; Wed, 21 Jun 2023 01:05:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBmGH-0007pT-3F; Tue, 20 Jun 2023 21:03:53 -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 1qBmGF-0007ow-OD for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:51 -0400 Received: from mga11.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBmGD-0001Fp-7X for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687309429; x=1718845429; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iIvXRDjNpdwCohk7Bble4vBFfcTjdFku6wDTuZGtskc=; b=OJ0QvkH/eQIrz9vgr4BUWd3iCWGJ9M2R7valvHW64ASbSv9vQmEF9/qi XngH57ZfBKENUinWxo7w0PaVy6lo1qA0mt7C2gkFNguy6nkl2y/4y74VM ELe33lS6eZTxm62yAQNnNZCPNp0PwvE3z9E47oAJmDsTIQn3h0GQ0vi3h 5RjAhstnmiPTHTzWtvPzaefZ3NC9sq1nN/ekOxKfYuwK4jsPS0eL7q8g2 7I5poZBOhzx46OBmkFz8UL3G7DTAkGI9sXFcOP25tKiadtHzEQRTZSdz+ snoUmNy7M+LNTuvw5vKk3FJQ1Z5IM8pU/VDYgLlIe0azuwTQeS3XXgtlf Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="357522830" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="357522830" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2023 18:03:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="838429572" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="838429572" Received: from dongwonk-z390-aorus-ultra-intel-gfx.fm.intel.com ([10.105.129.122]) by orsmga004.jf.intel.com with ESMTP; 20 Jun 2023 18:03:42 -0700 From: Dongwon Kim To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, berrange@redhat.com, armbru@redhat.com, philmd@linaro.org, marcandre.lureau@redhat.com, vivek.kasireddy@intel.com, Dongwon Kim Subject: [RFC PATCH 6/9] ui/gtk: Add a new parameter to assign connectors/monitors to GFX VCs Date: Tue, 20 Jun 2023 17:43:52 -0700 Message-Id: <20230621004355.19920-7-dongwon.kim@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230621004355.19920-1-dongwon.kim@intel.com> References: <20230621004355.19920-1-dongwon.kim@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.93; envelope-from=dongwon.kim@intel.com; helo=mga11.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Vivek Kasireddy The new parameter named "connector" can be used to assign physical monitors/connectors to individual GFX VCs such that when the monitor is connected or hotplugged, the associated GTK window would be moved to it. If the monitor is disconnected or unplugged, the associated GTK window would be hidden and a relevant disconnect event would be sent to the Guest. Usage: -device virtio-gpu-pci,max_outputs=2,blob=true,... -display gtk,gl=on,connectors.0=eDP-1,connectors.1=DP-1..... Cc: Gerd Hoffmann Cc: Daniel P. Berrangé Cc: Markus Armbruster Cc: Philippe Mathieu-Daudé Cc: Marc-André Lureau Signed-off-by: Vivek Kasireddy Signed-off-by: Dongwon Kim --- include/ui/gtk.h | 1 + qapi/ui.json | 11 +- qemu-options.hx | 5 +- ui/gtk.c | 271 +++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 263 insertions(+), 25 deletions(-) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index e7c4726aad..189817ab88 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -84,6 +84,7 @@ typedef struct VirtualConsole { GtkWidget *menu_item; GtkWidget *tab_item; GtkWidget *focus; + GdkMonitor *monitor; VirtualConsoleType type; union { VirtualGfxConsole gfx; diff --git a/qapi/ui.json b/qapi/ui.json index 2755395483..0f5ab35bae 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1315,13 +1315,22 @@ # @show-menubar: Display the main window menubar. Defaults to "on". # (Since 8.0) # +# @connectors: List of physical monitor/connector names where the GTK +# windows containing the respective graphics virtual consoles +# (VCs) are to be placed. If a mapping exists for a VC, it +# will be moved to that specific monitor or else it would +# not be displayed anywhere and would appear disconnected +# to the guest. +# (Since 8.1) +# # Since: 2.12 ## { 'struct' : 'DisplayGTK', 'data' : { '*grab-on-hover' : 'bool', '*zoom-to-fit' : 'bool', '*show-tabs' : 'bool', - '*show-menubar' : 'bool' } } + '*show-menubar' : 'bool', + '*connectors' : ['str'] } } ## # @DisplayEGLHeadless: diff --git a/qemu-options.hx b/qemu-options.hx index b57489d7ca..2eb0d6a129 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2044,7 +2044,7 @@ DEF("display", HAS_ARG, QEMU_OPTION_display, #if defined(CONFIG_GTK) "-display gtk[,full-screen=on|off][,gl=on|off][,grab-on-hover=on|off]\n" " [,show-tabs=on|off][,show-cursor=on|off][,window-close=on|off]\n" - " [,show-menubar=on|off]\n" + " [,show-menubar=on|off][,connectors.=]\n" #endif #if defined(CONFIG_VNC) "-display vnc=[,]\n" @@ -2139,6 +2139,9 @@ SRST ``show-menubar=on|off`` : Display the main window menubar, defaults to "on" + ``connectors=`` : VC to connector mappings to display the VC + window on a specific monitor + ``curses[,charset=]`` Display video output via curses. For graphics device models which support a text mode, QEMU can display this output using a diff --git a/ui/gtk.c b/ui/gtk.c index d8323a3a9d..f4c71454a3 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -38,6 +38,7 @@ #include "qemu/cutils.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" +#include "qemu/option.h" #include "ui/console.h" #include "ui/gtk.h" @@ -741,6 +742,39 @@ static void gd_set_ui_size(VirtualConsole *vc, gint width, gint height) dpy_set_ui_info(vc->gfx.dcl.con, &info, true); } +static void gd_ui_hide(VirtualConsole *vc) +{ + QemuUIInfo info; + + vc->gfx.visible = false; + info = *dpy_get_ui_info(vc->gfx.dcl.con); + info.width = 0; + info.height = 0; + dpy_set_ui_info(vc->gfx.dcl.con, &info, false); +} + +static void gd_ui_show(VirtualConsole *vc) +{ + QemuUIInfo info; + GtkDisplayState *s = vc->s; + GdkWindow *window = gtk_widget_get_window(vc->gfx.drawing_area); + + info = *dpy_get_ui_info(vc->gfx.dcl.con); + info.width = gdk_window_get_width(window); + info.height = gdk_window_get_height(window); + dpy_set_ui_info(vc->gfx.dcl.con, &info, false); + + if (gd_is_grab_active(s)) { + gd_grab_keyboard(vc, "user-request-main-window"); + gd_grab_pointer(vc, "user-request-main-window"); + } else { + gd_ungrab_keyboard(s); + gd_ungrab_pointer(s); + } + + vc->gfx.visible = true; +} + #if defined(CONFIG_OPENGL) static gboolean gd_render_event(GtkGLArea *area, GdkGLContext *context, @@ -1352,12 +1386,10 @@ 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); + gd_ui_hide(vc); vc = gd_vc_find_by_menu(s); gtk_release_modifiers(s); @@ -1365,10 +1397,7 @@ 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; + gd_ui_show(vc); } } @@ -1398,8 +1427,8 @@ static gboolean gd_tab_window_close(GtkWidget *widget, GdkEvent *event, VirtualConsole *vc = opaque; GtkDisplayState *s = vc->s; - vc->gfx.visible = false; - gd_set_ui_size(vc, 0, 0); + gd_ui_hide(vc); + dpy_gl_scanout_disable(vc->gfx.dcl.con); gtk_widget_set_sensitive(vc->menu_item, true); gd_widget_reparent(vc->window, s->notebook, vc->tab_item); @@ -1430,20 +1459,14 @@ static gboolean gd_window_state_event(GtkWidget *widget, GdkEvent *event, } if (event->window_state.new_window_state & GDK_WINDOW_STATE_ICONIFIED) { - vc->gfx.visible = false; - gd_set_ui_size(vc, 0, 0); + gd_ui_hide(vc); if (vc->gfx.guest_fb.dmabuf && vc->gfx.guest_fb.dmabuf->draw_submitted) { vc->gfx.guest_fb.dmabuf->draw_submitted = false; graphic_hw_gl_block(vc->gfx.dcl.con, false); } } else { - GdkWindow *window; - 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; + gd_ui_show(vc); } return TRUE; @@ -1503,7 +1526,6 @@ static void gd_tab_window_create(VirtualConsole *vc) 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 && @@ -1515,10 +1537,205 @@ static void gd_menu_untabify(GtkMenuItem *item, void *opaque) gd_tab_window_create(vc); } - 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; + gd_ui_show(vc); +} + +static void gd_window_show_on_monitor(GdkDisplay *dpy, VirtualConsole *vc, + gint monitor_num) +{ + GtkDisplayState *s = vc->s; + GdkMonitor *monitor = gdk_display_get_monitor(dpy, monitor_num); + GdkRectangle geometry; + + if (!vc->window) { + gd_tab_window_create(vc); + } + + gdk_window_show(gtk_widget_get_window(vc->window)); + gd_update_windowsize(vc); + gdk_monitor_get_geometry(monitor, &geometry); + /* + * Note: some compositors (mainly Wayland ones) may not honor a + * request to move to a particular location. The user is expected + * to drag the window to the preferred location in this case. + */ + gtk_window_move(GTK_WINDOW(vc->window), geometry.x, geometry.y); + + if (s->opts->has_full_screen && s->opts->full_screen) { + gtk_widget_set_size_request(vc->gfx.drawing_area, -1, -1); + gtk_window_fullscreen(GTK_WINDOW(vc->window)); + } + + vc->monitor = monitor; + gd_ui_show(vc); + + if (vc->window) { + g_signal_connect(vc->window, "window-state-event", + G_CALLBACK(gd_window_state_event), vc); + } + + gd_update_cursor(vc); +} + +static int gd_monitor_lookup(GdkDisplay *dpy, char *label) +{ + GdkMonitor *monitor; + int total_monitors = gdk_display_get_n_monitors(dpy); + int i; + + for (i = 0; i < total_monitors; i++) { + monitor = gdk_display_get_monitor(dpy, i); + if (monitor && !g_strcmp0(gdk_monitor_get_model(monitor), label)) { + return i; + } + } + return -1; +} + +static gboolean gd_vc_is_misplaced(GdkDisplay *dpy, GdkMonitor *monitor, + VirtualConsole *vc) +{ + GdkWindow *window = gtk_widget_get_window(vc->gfx.drawing_area); + GdkMonitor *mon = gdk_display_get_monitor_at_window(dpy, window); + const char *monitor_name = gdk_monitor_get_model(monitor); + + if (!vc->monitor) { + if (!g_strcmp0(monitor_name, vc->label)) { + return TRUE; + } + } else { + if (mon && mon != vc->monitor) { + return TRUE; + } + } + return FALSE; +} + +static void gd_vc_add_remove_monitor(GdkDisplay *dpy, GtkDisplayState *s) +{ + VirtualConsole *vc; + GdkMonitor *monitor; + gint monitor_num; + int i; + + /* + * We need to call gd_vc_is_misplaced() after a monitor is added to + * ensure that the Host compositor has not moved our windows around. + */ + for (i = 0; i < s->nb_vcs; i++) { + vc = &s->vc[i]; + if (vc->label) { + monitor_num = gd_monitor_lookup(dpy, vc->label); + if (monitor_num >= 0) { + monitor = gdk_display_get_monitor(dpy, monitor_num); + if (gd_vc_is_misplaced(dpy, monitor, vc)) { + gd_window_show_on_monitor(dpy, vc, monitor_num); + } + } else if (vc->monitor) { + vc->monitor = NULL; + if (vc->window) { + g_signal_handlers_disconnect_by_func(vc->window, + G_CALLBACK(gd_window_state_event), + vc); + } + + gd_ui_hide(vc); + /* if window exist, hide it */ + if (vc->window) { + gdk_window_hide(gtk_widget_get_window(vc->window)); + } + } + } + } +} + +static void gd_monitors_reset_timer(void *opaque) +{ + GtkDisplayState *s = opaque; + GdkDisplay *dpy = gdk_display_get_default(); + + gd_vc_add_remove_monitor(dpy, s); +} + +static void gd_monitors_changed(GdkScreen *scr, void *opaque) +{ + GtkDisplayState *s = opaque; + QEMUTimer *mon_reset_timer; + + mon_reset_timer = timer_new_ms(QEMU_CLOCK_REALTIME, + gd_monitors_reset_timer, s); + timer_mod(mon_reset_timer, + qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 2000); +} + +static VirtualConsole *gd_next_gfx_vc(GtkDisplayState *s) +{ + VirtualConsole *vc; + int i; + + for (i = 0; i < s->nb_vcs; i++) { + vc = &s->vc[i]; + if (vc->type == GD_VC_GFX && + qemu_console_is_graphic(vc->gfx.dcl.con) && + !vc->label) { + return vc; + } + } + return NULL; +} + +static void gd_vc_free_labels(GtkDisplayState *s) +{ + VirtualConsole *vc; + int i; + + for (i = 0; i < s->nb_vcs; i++) { + vc = &s->vc[i]; + if (vc->type == GD_VC_GFX && + qemu_console_is_graphic(vc->gfx.dcl.con)) { + g_free(vc->label); + vc->label = NULL; + } + } +} + +static void gd_connectors_init(GdkDisplay *dpy, GtkDisplayState *s) +{ + VirtualConsole *vc; + strList *conn; + gint monitor_num; + gboolean first_vc = TRUE; + + gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item), + FALSE); + gd_vc_free_labels(s); + for (conn = s->opts->u.gtk.connectors; conn; conn = conn->next) { + vc = gd_next_gfx_vc(s); + if (!vc) { + break; + } + if (first_vc) { + vc->window = s->window; + first_vc = FALSE; + } + + vc->label = g_strdup(conn->value); + monitor_num = gd_monitor_lookup(dpy, vc->label); + if (monitor_num >= 0) { + gd_window_show_on_monitor(dpy, vc, monitor_num); + } else { + if (vc->window) { + g_signal_handlers_disconnect_by_func(vc->window, + G_CALLBACK(gd_window_state_event), + vc); + } + gd_ui_hide(vc); + if (vc->window) { + gdk_window_hide(gtk_widget_get_window(vc->window)); + } + } + } } static void gd_menu_show_menubar(GtkMenuItem *item, void *opaque) @@ -1843,7 +2060,7 @@ static gboolean gd_configure(GtkWidget *widget, VirtualConsole *vc = opaque; if (vc->gfx.visible) { - gd_set_ui_size(vc, cfg->width, cfg->height); + gd_ui_show(vc); } return FALSE; } @@ -2180,6 +2397,10 @@ static void gd_connect_signals(GtkDisplayState *s) G_CALLBACK(gd_menu_grab_input), s); g_signal_connect(s->notebook, "switch-page", G_CALLBACK(gd_change_page), s); + if (s->opts->u.gtk.has_connectors) { + g_signal_connect(gdk_screen_get_default(), "monitors-changed", + G_CALLBACK(gd_monitors_changed), s); + } } static GtkWidget *gd_create_menu_machine(GtkDisplayState *s) @@ -2561,6 +2782,10 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts) opts->u.gtk.show_tabs) { gtk_menu_item_activate(GTK_MENU_ITEM(s->show_tabs_item)); } + + if (s->opts->u.gtk.has_connectors) { + gd_connectors_init(window_display, s); + } #ifdef CONFIG_GTK_CLIPBOARD gd_clipboard_init(s); #endif /* CONFIG_GTK_CLIPBOARD */ From patchwork Wed Jun 21 00:43:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 13286525 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 77F3CEB64D7 for ; Wed, 21 Jun 2023 01:05:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBmGG-0007pA-Do; Tue, 20 Jun 2023 21:03:52 -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 1qBmGF-0007oY-0p for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:51 -0400 Received: from mga11.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBmGD-0001GW-9c for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687309429; x=1718845429; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jsUvvs3uPDjPnHLHhR8XgDCXj27+som4PR/bEyALolQ=; b=F2/1P5vd6T/rN3biRJLkW99xS7EI4l1SDoGhiQ4L4Ms0kFuUvfX13B2o Uag9Q7qrgYqr9dlWT+nmAZ6Hcsy4bsZB36/Wo07qz6oE7qw1Rvfwmd5zb qX9/V69lrSGKAqN9vXsm8bfYcbS7CTPL04hLP0ti6YJKXIn248/boDIgS HUcFizMQsxdZB5qeP9J6L+7tq5kVFSxk48GGVwjIrm5Ec/Awm/3OUlkBF wi3HdyaggFM01Zi3ecL8JG0y9dG3y8VhjLGEuHmoo7ONLaalA8zZbXlOy WuEebHjhJCuJBDX73Un/lQ8ne24G2URsPxJw74efRmy+/X+JAp/V7OWgM w==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="357522835" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="357522835" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2023 18:03:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="838429576" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="838429576" Received: from dongwonk-z390-aorus-ultra-intel-gfx.fm.intel.com ([10.105.129.122]) by orsmga004.jf.intel.com with ESMTP; 20 Jun 2023 18:03:43 -0700 From: Dongwon Kim To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, berrange@redhat.com, armbru@redhat.com, philmd@linaro.org, marcandre.lureau@redhat.com, vivek.kasireddy@intel.com, Dongwon Kim Subject: [RFC PATCH 7/9] ui/gtk: unblock gl if draw submitted already or fence is not yet signaled Date: Tue, 20 Jun 2023 17:43:53 -0700 Message-Id: <20230621004355.19920-8-dongwon.kim@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230621004355.19920-1-dongwon.kim@intel.com> References: <20230621004355.19920-1-dongwon.kim@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.93; envelope-from=dongwon.kim@intel.com; helo=mga11.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Remove monitor while a guest frame is still being processed could block the guest (virtio-gpu) scanout pipe line. It is needed to manually flush the pipeline to prevent the permanent lockup. Cc: Gerd Hoffmann Cc: Daniel P. Berrangé Cc: Markus Armbruster Cc: Philippe Mathieu-Daudé Cc: Marc-André Lureau Cc: Vivek Kasireddy Signed-off-by: Dongwon Kim --- ui/gtk.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index f4c71454a3..e4ef1f7173 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -598,10 +598,21 @@ void gd_hw_gl_flushed(void *vcon) VirtualConsole *vc = vcon; QemuDmaBuf *dmabuf = vc->gfx.guest_fb.dmabuf; - qemu_set_fd_handler(dmabuf->fence_fd, NULL, NULL, NULL); - close(dmabuf->fence_fd); - dmabuf->fence_fd = -1; - graphic_hw_gl_block(vc->gfx.dcl.con, false); + if (!dmabuf) { + return; + } + + if (dmabuf->fence_fd > 0) { + qemu_set_fd_handler(dmabuf->fence_fd, NULL, NULL, NULL); + close(dmabuf->fence_fd); + dmabuf->fence_fd = -1; + graphic_hw_gl_block(vc->gfx.dcl.con, false); + } else if (dmabuf->draw_submitted) { + /* if called after a frame is submitted but render event + * is not scheduled yet, cancel submitted draw. */ + dmabuf->draw_submitted = false; + graphic_hw_gl_block(vc->gfx.dcl.con, false); + } } /** DisplayState Callbacks (opengl version) **/ @@ -742,6 +753,9 @@ static void gd_set_ui_size(VirtualConsole *vc, gint width, gint height) dpy_set_ui_info(vc->gfx.dcl.con, &info, true); } +static gboolean gd_window_state_event(GtkWidget *widget, GdkEvent *event, + void *opaque); + static void gd_ui_hide(VirtualConsole *vc) { QemuUIInfo info; @@ -751,6 +765,8 @@ static void gd_ui_hide(VirtualConsole *vc) info.width = 0; info.height = 0; dpy_set_ui_info(vc->gfx.dcl.con, &info, false); + /* forcefully cancel rendering sequence */ + gd_hw_gl_flushed(vc); } static void gd_ui_show(VirtualConsole *vc) @@ -1460,11 +1476,6 @@ static gboolean gd_window_state_event(GtkWidget *widget, GdkEvent *event, if (event->window_state.new_window_state & GDK_WINDOW_STATE_ICONIFIED) { gd_ui_hide(vc); - if (vc->gfx.guest_fb.dmabuf && - vc->gfx.guest_fb.dmabuf->draw_submitted) { - vc->gfx.guest_fb.dmabuf->draw_submitted = false; - graphic_hw_gl_block(vc->gfx.dcl.con, false); - } } else { gd_ui_show(vc); } From patchwork Wed Jun 21 00:43:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 13286526 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 E1707EB64D7 for ; Wed, 21 Jun 2023 01:05:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBmGH-0007pj-MB; Tue, 20 Jun 2023 21:03:53 -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 1qBmGG-0007p6-9V for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:52 -0400 Received: from mga11.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBmGE-0001Gy-Iv for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687309430; x=1718845430; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dlMd5Y05RlitQ/LDn4QHI3iY/Scnnj1sren1XCBp1Gw=; b=Wb3w+EvlgTBNjKv+xhkG/232K0Wb5rrpEpyErmB3+eKadw/74Ga48fCe AaWORwY3ifNNLkGqMGwDrcWt+SlYHJu9qWTRZY67z7KagJIbTrHjjHFiO mc/5cW6SY/fNhSg9xg5HA5xhOzkIXvVcWwzeNd961iwV43m9IxkNPCV4m Ru/972KzgF6NA4HeSwF2uQbV9hFLJRiZ9AICqk1eFjQ1TcS905TQGtjK5 U0u/kxXyIhBOy582ree+DeSi8p3i/rgFIqnyvyeVBzwX5aP1CrLFJkcF0 n7+pcBvhLPVyFXKI6G3tQm7ku1rxWA066AfRG62PnZt5WA9clZktmsK4u g==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="357522840" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="357522840" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2023 18:03:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="838429580" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="838429580" Received: from dongwonk-z390-aorus-ultra-intel-gfx.fm.intel.com ([10.105.129.122]) by orsmga004.jf.intel.com with ESMTP; 20 Jun 2023 18:03:44 -0700 From: Dongwon Kim To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, berrange@redhat.com, armbru@redhat.com, philmd@linaro.org, marcandre.lureau@redhat.com, vivek.kasireddy@intel.com, Dongwon Kim Subject: [RFC PATCH 8/9] ui/gtk: skip drawing if any of ctx/surface/image don't exist Date: Tue, 20 Jun 2023 17:43:54 -0700 Message-Id: <20230621004355.19920-9-dongwon.kim@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230621004355.19920-1-dongwon.kim@intel.com> References: <20230621004355.19920-1-dongwon.kim@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.93; envelope-from=dongwon.kim@intel.com; helo=mga11.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Rendering of scanout could be skipped if ctx/surface/image don't exist due to an asynchronous event such as monitors being disconnected. Cc: Gerd Hoffmann Cc: Daniel P. Berrangé Cc: Markus Armbruster Cc: Philippe Mathieu-Daudé Cc: Marc-André Lureau Cc: Vivek Kasireddy Signed-off-by: Dongwon Kim --- ui/gtk-egl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index aa22ebbd98..8eae2b4b1f 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -106,6 +106,11 @@ void gd_egl_draw(VirtualConsole *vc) if (!vc->gfx.ds) { return; } + + if (!vc->gfx.esurface || !vc->gfx.ectx || !vc->gfx.ds->image) { + return; + } + eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, vc->gfx.esurface, vc->gfx.ectx); From patchwork Wed Jun 21 00:43:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 13286524 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 165DCEB64D8 for ; Wed, 21 Jun 2023 01:04:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBmGJ-0007qU-4u; Tue, 20 Jun 2023 21:03:55 -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 1qBmGH-0007pU-4A for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:53 -0400 Received: from mga11.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBmGF-0001GW-CN for qemu-devel@nongnu.org; Tue, 20 Jun 2023 21:03:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687309431; x=1718845431; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NADUm1702aVn1LWj7KvqXMVwTggCDu8sw+9YZB3ZF08=; b=U8uObmwoVfgkknpcZ07grSTyfEPzQ3czWXOXdoUkleVb//7e8SmMLmBo G1eDgZ+wsHqDEzjRTvvteCC+/NDrAsBMnpbZPg2ixUBgaGKuZZNR/hons MH/ze9EYTDKDC3LipbJSj9HhGG7NBeR/oz6a6iyFVZxSYwPVjpDc0BeBY AlDjC6fwc1td587zIK17IPW6Ll48zd96+hYNdjH4qirFUUaJek+VOcGn/ /1Va6HVK9ni0gKlghmwtiyFJfVISz45MH708bz0QlHv38dBYcn4kafHxL R9zXaQSuzlkmPMLLaMhVwcdr+ImSCX6t3aGncgCqRwgkaPRXNF3i+FRiI g==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="357522845" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="357522845" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2023 18:03:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="838429584" X-IronPort-AV: E=Sophos;i="6.00,258,1681196400"; d="scan'208";a="838429584" Received: from dongwonk-z390-aorus-ultra-intel-gfx.fm.intel.com ([10.105.129.122]) by orsmga004.jf.intel.com with ESMTP; 20 Jun 2023 18:03:45 -0700 From: Dongwon Kim To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, berrange@redhat.com, armbru@redhat.com, philmd@linaro.org, marcandre.lureau@redhat.com, vivek.kasireddy@intel.com, Dongwon Kim Subject: [RFC PATCH 9/9] ui/gtk: skip refresh/rendering if VC is invisible Date: Tue, 20 Jun 2023 17:43:55 -0700 Message-Id: <20230621004355.19920-10-dongwon.kim@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230621004355.19920-1-dongwon.kim@intel.com> References: <20230621004355.19920-1-dongwon.kim@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.93; envelope-from=dongwon.kim@intel.com; helo=mga11.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Skip any drawing activities if VC is invisible because it can't be finished. Cc: Gerd Hoffmann Cc: Daniel P. Berrangé Cc: Markus Armbruster Cc: Philippe Mathieu-Daudé Cc: Marc-André Lureau Cc: Vivek Kasireddy Signed-off-by: Dongwon Kim --- ui/gtk-egl.c | 4 ++++ ui/gtk-gl-area.c | 4 ++++ ui/gtk.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 8eae2b4b1f..63bfad1f06 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -148,6 +148,10 @@ void gd_egl_refresh(DisplayChangeListener *dcl) gd_update_monitor_refresh_rate( vc, vc->window ? vc->window : vc->gfx.drawing_area); + if (!vc->gfx.visible) { + return; + } + if (!vc->gfx.esurface) { gd_egl_init(vc); if (!vc->gfx.esurface) { diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index 8228cc9f3f..8d01addb3b 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -123,6 +123,10 @@ void gd_gl_area_refresh(DisplayChangeListener *dcl) gd_update_monitor_refresh_rate(vc, vc->window ? vc->window : vc->gfx.drawing_area); + if (!vc->gfx.visible) { + return; + } + if (!vc->gfx.gls) { if (!gtk_widget_get_realized(vc->gfx.drawing_area)) { return; diff --git a/ui/gtk.c b/ui/gtk.c index e4ef1f7173..0bc35b64e0 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -847,6 +847,10 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque) #if defined(CONFIG_OPENGL) if (vc->gfx.gls) { + if (!vc->gfx.visible) { + return TRUE; + } + if (gtk_use_gl_area) { /* invoke render callback please */ return FALSE;