From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Handle sharing Cocoa xwidgets more gracefully Date: Tue, 04 Oct 2022 08:26:59 +0800 Message-ID: <87zgec1lik.fsf@yahoo.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38786"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux) Cc: Emacs developers To: =?utf-8?B?7KGw7ISx67mI?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Oct 04 02:38:24 2022 Return-path: Envelope-to: ged-emacs-devel@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 1ofVx2-0009z9-Rt for ged-emacs-devel@m.gmane-mx.org; Tue, 04 Oct 2022 02:38:24 +0200 Original-Received: from localhost ([::1]:36660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ofVx1-0001d4-4o for ged-emacs-devel@m.gmane-mx.org; Mon, 03 Oct 2022 20:38:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ofVmF-0008Qg-T2 for emacs-devel@gnu.org; Mon, 03 Oct 2022 20:27:15 -0400 Original-Received: from sonic306-22.consmr.mail.ne1.yahoo.com ([66.163.189.84]:46854) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ofVmD-00050D-91 for emacs-devel@gnu.org; Mon, 03 Oct 2022 20:27:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1664843231; bh=fKQh+vYQzirBZRghc34JzlFaqKVHSykYi25udkSzTgk=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=uEDxYCVkxne5M8g2Tl5m6QjrJNS2ZmMt/k5tk5Uf3fcxsdJQKOlLL0Ct1g1Rj0JjbAftlzYJClGVOzMJZIdYbOA2OhE22okb6g9JsV7/FwNDpUtyU6+8csmcEytT118x8Xt+4tbdnjxlSQgd8yF21myzFujJ57PsvwqLXiuw2r+Gvj0Spwj2CvvsRi0qbbMgJI5/FTLhogWU1oP9ExczCkTsXsnYnWGYY6vwOpIMTbcfXj3wfbz0v7PqeHbmkW1uwLMYJGW1agWjZtRfPU4hlCeg2At8mYLZkkE2v4LsDUmnHR6eM31YzZdjcVCkh6m9E3rXm0YMKDbsHBlcXhdOeA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1664843231; bh=fx9s27OovZgIrPg6C5D+CsqYqhrT4DlG5C5azBtVjxo=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=HD6PUBnSfhF/kJUJet85xKiEx38CVgFJQVxfYvfoFaffEnxywTuCMJQO3TCnOlIlNKKPDW0doyNx+SK+joTvtbNnILHrBLUeztkJKgmEYmXTH/AEMyJMjOoXpfXZHg9Foa/4OhR0iCFbnbEOSlN1VIYSbCPVUzzmoPNs3xklRK7w63Mk5YP3fbl7WZ+vrvdKfGzomGN5y49uVk4kUWQsLHk1d3mCmRg4d0thO97fFge5x+hD+BlmH/r0SERuIv2aVICBiSGyyhgDvB3nJXPlaya/KTMJR/iyLCFb9QW88TQPpMwEp/BMKV5B14suyZjRxRXzTPOLiMalR4tl2QdPxw== X-YMail-OSG: rtV_5REVM1kcLVu9Xjbb1CK30THHLzhfN8sNwxyEUgxMX.E3aXINFp0VY4mAOJB DP6.my9soaNF7fKoHcNmtFIc0_m60EowyYayvnQO8IvaJlFU.7CrweBUrUZmTowJkTPrgmkzJckV Wof8LN8bsY.MGodMANseAQD9H3dMXnlkfuuYnal.MIrk.0VWNyOL6bcNeoDMINEdHw99hpivUBdk sHFSNrpIsnryJQXwPxbuf7boN_1wrENfla5ipO9DBgf4y0O1wg8UO.4EWqv5tEmE8Q_FuK9FSlsN bmDSjvCkSjn5IrfNd7p4r6C_XHOXHNJhBMNrY9WybIuLHGwHzvDyjxj5wKMtucuff76e373dUnpH e2dv_221BJ.KRLiSK547nLchup35JsfTI2TGAV_6qGhhuWjiDxXhzG0BSuefN60uHmEEVysuiZZY oBhdA.gx4nhstZ6Fb0i3.7vJWucWrsg62fykHLCJXJ_LHs6pyLIG0hTpcB1hdLt3eJDYXmnf0LZ5 XeIDE_h3LTLKkZB1CkE1KEbkwUTBfAh6aXV41JHgzQEGoPUODBVNyPvTE4fcbyFyNbAGQiKxyf4c CMwO94UhxJSXZiYR8DPsa5X6ivwl5UCtGib_Xx84YFQNVhkkyO4_rjkLkQvocDUrDm2akUCfS79x dLsZ3xZD4TGHws5YZ.AdWNR92ke2G9KgtSj6wBCTzXdtJQsyxR93bg6dujJ9bz57TOZfCEwqyE_B a4wIe0NxBdJOE9hOT4rKLFvTInjEDg.WwGQ8VZYutyduJAELvfMDt9hqWFf_mUiTat8ESHJNGLkG KhDohsWNszEeFm8pOEfp9YqBKdfUIEsBFfZQ2V0Mv8 X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.ne1.yahoo.com with HTTP; Tue, 4 Oct 2022 00:27:11 +0000 Original-Received: by hermes--production-sg3-cf9dc7f8d-rww6r (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 86564c98c58e85cc834c2eddf04b7e66; Tue, 04 Oct 2022 00:27:04 +0000 (UTC) In-Reply-To: (=?utf-8?B?IuyhsOyEseu5iCIncw==?= message of "Mon, 3 Oct 2022 23:16:53 +0900") X-Mailer: WebService/1.1.20702 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.189.84; envelope-from=luangruo@yahoo.com; helo=sonic306-22.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: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:296818 Archived-At: =EC=A1=B0=EC=84=B1=EB=B9=88 writes: > Hello,=20 > > Attached is a patch that improves the handling of sharing Cocoa xwidgets.= =20 > > The previous implementation of Cocoa xwidgets poorly handled cases where = the > user tried to share xwidgets between multiple views (by spamming messages= to > *Messages* on every redisplay, and not drawing anything on the second xwi= dget). > The attached patch fixes this issue by showing a warning label in the pla= ce of > the xwidget view.=20 > > I originally tried to create a bug report with the patch by mailing to > bug-gnu-emacs@gnu.org, but it seems that the report wasn=E2=80=99t create= d. As such, > I=E2=80=99m sending the patch to the emacs-devel list. How should I proce= ed with this? > > Thanks. Thanks; since you seem to be the original author of the xwidget code on Mac OS, could you please fix the crash there when an xwidget is deleted but remains on-screen? Some minor formatting comments on the patch below: > From: VirtualBuddy Is this a real email? > * etc/NEWS: Mention fix. Since this is a bug fix, I see no reason to mention it in NEWS. In addition, even if it warranted a mention, it ought to be placed under "Changes in Emacs 29.1 on Non-Free Operating Systems". > * src/nsxwidget.h: Remove now-unused NSView subclasses and functions. > * src/nsxwidget.m: > ([XwWebView mouseDown:], [XwWebView mouseUp:], [XwWebView keyDown:]) > ([XwWebView userContentController:didReceiveScriptMessage:]): Rename fiel= d of > xwidget_view from emacswindow to emacsFrame to better match emacs termino= logy. > (nsxwidget_init, nsxwidget_resize_view, nsxwidget_move_widget_in_view): > Simplify logic by removing field xwWindow and using the xvWindow as the > container. > (nsxwidget_resize, XwWindow, XvWindow): Remove now-unused code. > (nsxwidget_init_view, nsxwidget_delete_view): Handle creating non-primary > xwidget views. > (nsxwidget_show_view, nsxwidget_hide_view): Remove poor hack to hide view= s. > * src/xwidget.c (xwidget_init_view): Update formatting. > (x_draw_xwidget_glyph_string): Handle displaying non-primary xwidget view= s and > remove previous message warning. > (Fxwidget_resize): Remove useless call to nsxwidget_resize, as the subseq= uent > redisplay handles them via nsxwidget_resize_view. > * src/xwidget.h (struct xwidget): Remove field xwWindow and update commen= ts > to be more accurate. > (struct xwidget_view): Add field xvWidget and rename field emacswindow to > emacsFrame to better match emacs terminology. Please make sure that each line of the commit message is no longer than 64 characters in length. > { > - [self.xw->xv->emacswindow mouseDown:event]; > + [self.xw->xv->emacsFrame mouseDown:event]; > [super mouseDown:event]; > } >=20=20 > - (void)mouseUp:(NSEvent *)event > { > - [self.xw->xv->emacswindow mouseUp:event]; > + [self.xw->xv->emacsFrame mouseUp:event]; > [super mouseUp:event]; > } The "emacswindow" field should actually be named "frame", IMHO. > + { > + NSTextField *warningLabel =3D [NSTextField labelWithString:@"Cocoa= Xwidgets do not support sharing widgets."]; This line is too long. Please find a way to make it fit in 80 columns. > + if (xw->xv =3D=3D xv) > + { > + xw->xv =3D NULL; /* Now model has no view. */ > + } Please remove the unnecessary braces here.