emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Introducing emacs-webkit and more thoughts on Emacs rendering (was R


From: Tomas Hlavaty
Subject: Re: Introducing emacs-webkit and more thoughts on Emacs rendering (was Rethinking the design of xwidgets)
Date: Tue, 01 Dec 2020 18:33:56 +0100

On Tue 01 Dec 2020 at 17:58, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Tomas Hlavaty <tom@logand.com>
>> Date: Tue, 01 Dec 2020 09:01:20 +0100
>> 
>> It would be more convenient, if there was a way to specify elisp
>> function to draw an image.  By default, it could just call the existing
>> C code but this would also allow me to specify a different elisp
>> function which would then for example call w3mimgdisplay.
>
> You need to be aware of how this works in Emacs.  In a nutshell,
> there's no function "to draw the image": we call system APIs to do
> that.  By the time we need to draw the image, it is already
> preprocessed into a bitmap/pixmap, so we basically ask the GUI
> subsystem of the OS to bitblt the image to some coordinates on the
> screen which we compute.
>
> The preprocessing of the images into bitmap/pixmap happens when the
> display engine sees a 'display' property that specifies an image.
> At that time we call some image library to convert the image's data
> into bitmap/pixmap; then we cache the result and produce a handle to
> the cache that the drawing routines will use.
>
> So when you ask for the above, you need to fit into this scheme.

Thanks for the great explanation.

I do not have an issue with the way it works currently.

Think of w3mimgdisplay program

- as an alternatine "system API and GUI subsystem of the OS to bitblt
  the image to some coordinates on the screen which we compute".

- as an alternative "some image library to convert the image's data into
  bitmap/pixmap; then we cache the result and produce a handle to the
  cache that the drawing routines will use".

w3mimgdisplay can supply both functions.

w3mimgdisplay program can be run as a kind of "server", where I can say:

- draw this image to these coordinates on the screen

- or additionally, cache image's data and return a handle to the cache,
  which will make redrawing fast.

I think that the only issue for me is that there is no way to implement
an alternative "system API" and "call some image library" in pure elisp.

How much work would it be to enable alternative "system API" and "call
some image library" in pure elisp?

>> It would be more convenient, if an image was represented as elisp data
>> instead of C data.
>
> create-image already knows how to accept image data.

But those must be defined in C, see lookup_image_type.

Or is there a way to define custom image format in pure elisp?

It would be actually enough for me if my custom image was opaque to
emacs (except probably some attributes like width and height) and
w3mimgdisplay handled the rest.

>> iirc there is no way to add new image types without touching C.
>
> No, because you need to know how to convert that into the internal
> format used to draw the image, which is platform dependent.

I don't need to know that.  w3mimgdisplay program does that.  As far as
emacs is concerned, it needs to give to w3mimgdisplay filename to draw
and then use a handle to cache to ask w3mimgdisplay for redraw.

> Why is it a problem to use one of the known image types?  E.g., SVG
> (via the svg.el library).

Because those those are not universally available, e.g. on the console.

Because those might not be suitable.

>> Is there a way to turn off cursor for a buffer?
>
> There's the cursor-type variable.

Thanks.

This does not work on the console.

I suppose I need to use some console specific command/escape sequence.

Is there a way to hook a function when a buffer looses and gains focus?

>> Is there a way run a function after emacs changes something on the
>> screen in a buffer?
>
> That depends by what you mean by "after emacs changes something on the
> screen", since in Emacs redisplay is independent/separate of data
> changes.  Please elaborate.

Example: I am on the console.  I am in dired buffer.  I press my key.
w3mimgdisplay program draws my image on the screen on the specified
coordinates "over" emacs.  All is well (except the blinking cursor which
we can ignore for now).  Now I press another key to display the next
image in the dired buffer.  Emacs redraws some characters, that have
changed.  This disrupts the image drawn earlier and I need to detect,
that I need to tell w3mimgdisplay to redraw the image.  I need to hook
my redraw image function after emacs is done with its drawing.

So far I have to press a key to redraw image.

I tried using timer and redraw after say 1s but that is not so nice.

Is there such hook?  If not, would it be difficult to add it?

Thanks a lot for your help!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]