From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Introducing emacs-webkit and more thoughts on Emacs rendering (was Rethinking the design of xwidgets) Date: Sun, 29 Nov 2020 21:01:31 +0200 Message-ID: <83czzwkmwk.fsf@gnu.org> References: <864kmzupp0.fsf@akirakyle.com> <86pn46awrr.fsf@akirakyle.com> <87y2ise7j5.fsf@gnus.org> <86tutfwhr6.fsf@akirakyle.com> <87h7pfb76z.fsf@gnus.org> <86h7peqkt5.fsf@akirakyle.com> <83tutdsc8i.fsf@gnu.org> <86eeker01y.fsf@akirakyle.com> <83wny5naf5.fsf@gnu.org> <86o8jh9cij.fsf@akirakyle.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33685"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, emacs-devel@gnu.org To: Akira Kyle Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 29 20:02:58 2020 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 1kjRyM-0008dJ-DA for ged-emacs-devel@m.gmane-mx.org; Sun, 29 Nov 2020 20:02:58 +0100 Original-Received: from localhost ([::1]:51952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kjRyL-0001kw-G0 for ged-emacs-devel@m.gmane-mx.org; Sun, 29 Nov 2020 14:02:57 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kjRxE-00017J-Br for emacs-devel@gnu.org; Sun, 29 Nov 2020 14:01:48 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:38505) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kjRxD-0001UG-7Z; Sun, 29 Nov 2020 14:01:47 -0500 Original-Received: from [176.228.60.248] (port=3977 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kjRx8-0000fk-Mq; Sun, 29 Nov 2020 14:01:46 -0500 In-Reply-To: <86o8jh9cij.fsf@akirakyle.com> (message from Akira Kyle on Sat, 28 Nov 2020 18:29:08 -0700) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:260025 Archived-At: > From: Akira Kyle > Cc: larsi@gnus.org, emacs-devel@gnu.org > Date: Sat, 28 Nov 2020 18:29:08 -0700 > > One such fundamental incompatibility stems from the fact that > Emacs may have multiple views on one buffer split across various > windows and/or frames. Gtk assumes that each widget will only have > one view. The 'webkit xwidget type currently works around this by > drawing to an offscreen window then for every window that's > supposed to display the widget, creating a gtk drawing area widget > and copying the offscreen window's surface to the drawing > surface. I don't think gtk really intends for ofscreen widgets to > be used this way and as far as I can tell offscreen window widgets > have been removed in gtk4. > > Another issue is that emacs uses a GtkFixed (or a custom > subclassed EmacsFixed for gtk3) as the container widget for the > main frame area. There isn't a mechanism to control z-ordering of > child widgets other than removing and re-adding them in the > desired z-order, which is what emacs-webkit has to do in order for > child frames to not render below the webkit widget. The same problems plague your experiment with a module, don't they? Anyway, this just tells me that GTK is not a good starting point for embedding widgets. Do other projects build embedded widgets on such shaky grounds? > > As long as the widget can be told to use a given rectangular > > portion of the screen, we should be fine: the current Emacs > > display engine is perfectly capable of handling display elements > > that occupy an area of certain dimensions. > > This is more an issue on the gtk side of things. With the webkit > widget it isn't an issue since the widget doesn't define a minimum > size so any size you request it to render at, it will > obey. However other widgets, such as buttons, sliders, etc, have a > minimum size they will render at. If you tell it to render itself > smaller, it will refuse and so it's impossible to simply tell the > widget "here's the space you have to go in". This becomes a > problem when the widget needs to be clipped at a window boundary > as gtk will happily draw the widgets across them as gtk has no > internal knowledge of Emacs window boundaries being a place that > widget must be clipped at. This is solvable. We already have similar situation in the display engine, where some display element cannot be usefully "clipped". We either don't display it at all or display it on the next screen line, depending on the wrap mode. > The direction I'm thinking of going in the future since I feel > like thus far the xwidget route has been fairly troublesome is to > expose interfaces to the cairo surfaces used in image.c. This > could be through modifying image.c or through defining a new > display element type. I would try to expose the cairo API to lisp > and allow dynamic modules to directly draw to a cairo surface > given to it through the lisp interface. Gtk along with many other > libraries (such as librsvg and poppler) support drawing to a cairo > surface and then Emacs gets to have full control over how that > cario surface ends up on screen. I would see this as a stepping > stone to attempting to do something similar with a opengl surface. My suggestion is to think how to integrate this idea into Emacs proper, without introducing modules into the equation. Modules add another layer of complexity, so I would suggest to design the solution inside Emacs, and only after that see how to do that from a module. One step at a time.