From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#51674: 29.0.50; [PATCH] Fix hang when displaying xwidget script dialog Date: Mon, 08 Nov 2021 10:10:44 +0800 Message-ID: <87fss7s8gr.fsf@yahoo.com> References: <87fss7s8gr.fsf.ref@yahoo.com> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20152"; mail-complaints-to="usenet@ciao.gmane.io" To: 51674@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 08 03:11:20 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mju7z-00056W-PW for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 Nov 2021 03:11:19 +0100 Original-Received: from [::1] (port=36650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mju7y-0003aw-KC for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 07 Nov 2021 21:11:18 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mju7j-0003Z4-1j for bug-gnu-emacs@gnu.org; Sun, 07 Nov 2021 21:11:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43912) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mju7i-0005sF-Nq for bug-gnu-emacs@gnu.org; Sun, 07 Nov 2021 21:11:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mju7i-00035C-JK for bug-gnu-emacs@gnu.org; Sun, 07 Nov 2021 21:11:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 Nov 2021 02:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51674 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163633746111840 (code B ref -1); Mon, 08 Nov 2021 02:11:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Nov 2021 02:11:01 +0000 Original-Received: from localhost ([127.0.0.1]:55458 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mju7g-00034u-RL for submit@debbugs.gnu.org; Sun, 07 Nov 2021 21:11:01 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:38296) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mju7e-00034m-Ua for submit@debbugs.gnu.org; Sun, 07 Nov 2021 21:10:59 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mju7e-0003WJ-QR for bug-gnu-emacs@gnu.org; Sun, 07 Nov 2021 21:10:58 -0500 Original-Received: from sonic310-25.consmr.mail.ne1.yahoo.com ([66.163.186.206]:33219) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mju7c-0005lN-90 for bug-gnu-emacs@gnu.org; Sun, 07 Nov 2021 21:10:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1636337454; bh=OAYTE30hdFmvhAsFmWdpGkhXWC/9A94VYRV0iQaWL+A=; h=From:To:Subject:Date:References:From:Subject:Reply-To; b=DY8mkT7iFhqIZfiYcPLAXLoFAdcCB/mFHbj03duKWgmezsh5mSZEXpy6O6MyPCaIIWZYj3bG2Bj8hBp4pWp7aZdZLhBT+D7aYFwuM3lWkPc+IR7iJ2t+IjPsIJMedmkzcia0jSl/SPxUwcik0ZKMecwNxc0NnRmDqXAVUxIcJNqbJSzXD8hw9JOxiOkfxNV364TtcIA64mBPYaFTAUa1l7wr9gVsqZE2z/qE7Fek1FzxVP+6qvB69zrM4SmxsWkjfA8HsSJQVLE8YcCf7EieWsfneHyW3aduN5+O1jDZro8mq+u8jnGfv48edT1mhvBZ1aFOMySKWAIbIEVNTsk77A== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1636337454; bh=HUpbLA62LhnXF1kByP2WGy1uxql+nPsidZpApwdQ3Xh=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=mxXumFOqEzkGlvUw4YsAFPgGWRsckAIItHT9EhaKSaX79ZTR9Vn4TbDS+AyDbKEBeOdHa+9A/d0Cfdw8pblScb80lAovkPOciaur7xQ8IZi2AkHciMlM7dy9c4xcejZUDZP0FJLZMzDs8PG2sDweiMfzO8x9FpCtjQNDn3nsfd4ZbLa19dav69W6F6ZqJ2Mt5/O2HOeEzFC4g9lZEujLpz/WKCBXI3Xh6QYWtOeWPNOVLWDaLKYriUu0xTIXYIpBVUkwHVIVRRZtobcPhT7kotbjeHUV58jI75XzrsYzl4Vf2QHiWd/i91jsec4eWYurogGjuF19F7Bn67n2l6Otjw== X-YMail-OSG: Ts.2ccIVM1k_Pw7efW3wEJnuVcS_wbK3W6IKTI_o0Ej6yqLMh3cAyNvLi2FJTwt JDu2bH19aETk_djizuAfiBnAsaMFUsBtZJ2wKp6jejLwGWtpe7g2wnJtbrnx7S_xGM1b9xKjQAy7 MgWs1Yx.Lap2s_7QTrGGuE0WNK2CaYE.iibKng38lQ2J6gzox91.3Wfyr.GyDafThrEjO8yopafk MCE36rAd5ukRMZ5xIY80adI2iqgyQknrEF2Tiq1TLIi1PxFKXHq5tOMJ8pMk2Py4nwyOajdvQsxj 5J92ITjdk57tOt5VS96El17Se7ksqvgmjtfbNFdGHtZ0IM9l2Ydcv6zBgHRwSD.J5x6kbb1KdKPP JvMjzMUob25RLkihO.9Qx.GLr5.hH6L3II58MRnRt4tkFl31ppNTzutCOlvWvPbLjJeN8E2FsL7d umCCSiD7hzu0EoO2bHCNRMlYsUTmUrSpgTdGzgzoLHpg11sumv9L.qwBmXbyZI84ucvPKAm2XxY_ 4vni0Osf1l919pC.tBu6r8lL2zU5Sg4kvuCnyrzfdQJEYTln3TGQdu4vkrCNfDLVVzsSALaC0170 r7MoelDXmWUFwghqKj_Id6xfC5T0qTCCO_fJhWJg0Ithg0A15k1lvaFKoLqbYnGDyQ8doUGH7rCQ Er6JeQuhmYqd6ZG3QQw079gV711cMKdyLih2cSr526as8PijAb.xkjcOC22rLItlc.tcfGYxBxpw gJXHE.fw3ANOqS1oxCRxi6Kh2h_IGxMHQxvlBwWr8W_OIBIpUQQan.QjnHl.sVQiKUQggVz8ij4p eJYoZrBA0V95pJIjIE5c7x6_Ct_Mk_2HCxLU9E9mSL X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ne1.yahoo.com with HTTP; Mon, 8 Nov 2021 02:10:54 +0000 Original-Received: by kubenode512.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 1eb40aade18bf69dac97db3fc086ef28; Mon, 08 Nov 2021 02:10:48 +0000 (UTC) X-Mailer: WebService/1.1.19266 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.186.206; envelope-from=luangruo@yahoo.com; helo=sonic310-25.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:219311 Archived-At: --=-=-= Content-Type: text/plain Thanks! --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-hang-when-displaying-xwidget-script-dialog.patch >From 1ce79e6631678dd0c98718bbb0882cc6c169d2b0 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 8 Nov 2021 10:07:55 +0800 Subject: [PATCH] Fix hang when displaying xwidget script dialog * src/xwidget.c (webkit_script_dialog_cb): New function. (Fmake_xwidget): Attach script callback signal. --- src/xwidget.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/xwidget.c b/src/xwidget.c index f95f5f1d7f..ecb973f485 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -50,6 +50,8 @@ Copyright (C) 2011-2021 Free Software Foundation, Inc. static gboolean offscreen_damage_event (GtkWidget *, GdkEvent *, gpointer); static void synthesize_focus_in_event (GtkWidget *); static GdkDevice *find_suitable_keyboard (struct frame *); +static gboolean webkit_script_dialog_cb (WebKitWebView *, WebKitScriptDialog *, + gpointer); #endif static struct xwidget * @@ -240,6 +242,10 @@ DEFUN ("make-xwidget", "create", G_CALLBACK (webkit_create_cb), xw); + g_signal_connect (G_OBJECT (xw->widget_osr), + "script-dialog", + G_CALLBACK (webkit_script_dialog_cb), + NULL); } g_signal_connect (G_OBJECT (xw->widgetwindow_osr), "damage-event", @@ -1242,6 +1248,66 @@ webkit_decide_policy_cb (WebKitWebView *webView, return FALSE; } } + +static gboolean +webkit_script_dialog_cb (WebKitWebView *webview, + WebKitScriptDialog *script_dialog, + gpointer user) +{ + struct frame *f = SELECTED_FRAME (); + WebKitScriptDialogType type; + GtkWidget *widget; + GtkWidget *dialog; + GtkWidget *entry; + GtkWidget *content_area; + const gchar *content; + const gchar *message; + gint result; + + /* Return TRUE to prevent WebKit from showing the default script + dialog in the offscreen window, which runs a nested main loop + Emacs can't respond to, and as such can't pass X events to. */ + if (!FRAME_WINDOW_P (f)) + return TRUE; + + type = webkit_script_dialog_get_dialog_type (script_dialog);; + widget = FRAME_GTK_OUTER_WIDGET (f); + content = webkit_script_dialog_get_message (script_dialog); + + if (type == WEBKIT_SCRIPT_DIALOG_ALERT) + dialog = gtk_dialog_new_with_buttons (content, GTK_WINDOW (widget), + GTK_DIALOG_MODAL, + "Dismiss", 1, NULL); + else + dialog = gtk_dialog_new_with_buttons (content, GTK_WINDOW (widget), + GTK_DIALOG_MODAL, + "OK", 0, "Cancel", 1, NULL); + + if (type == WEBKIT_SCRIPT_DIALOG_PROMPT) + { + entry = gtk_entry_new (); + message = webkit_script_dialog_prompt_get_default_text (script_dialog); + content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + + gtk_widget_show (entry); + gtk_entry_set_text (GTK_ENTRY (entry), message); + gtk_container_add (GTK_CONTAINER (content_area), entry); + } + + result = gtk_dialog_run (GTK_DIALOG (dialog)); + + if (type == WEBKIT_SCRIPT_DIALOG_CONFIRM + || type == WEBKIT_SCRIPT_DIALOG_BEFORE_UNLOAD_CONFIRM) + webkit_script_dialog_confirm_set_confirmed (script_dialog, result == 0); + + if (type == WEBKIT_SCRIPT_DIALOG_PROMPT) + webkit_script_dialog_prompt_set_text (script_dialog, + gtk_entry_get_text (GTK_ENTRY (entry))); + + gtk_widget_destroy (GTK_WIDGET (dialog)); + + return TRUE; +} #endif /* USE_GTK */ -- 2.31.1 --=-=-=--