unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How to find out whether an image is displayed anywhere?
@ 2011-06-26 15:49 Lars Magne Ingebrigtsen
  2011-06-26 20:45 ` Chong Yidong
  2011-06-30 16:34 ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-06-26 15:49 UTC (permalink / raw)
  To: emacs-devel

I just noticed that animated images keep on being animated even if the
images themselves aren't displayed in any buffer.

That seems wrong.

Is there a way to query Emacs whether an image is actually displayed
anywhere?  I looked through image.el, and I couldn't find anything...

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to find out whether an image is displayed anywhere?
  2011-06-26 15:49 How to find out whether an image is displayed anywhere? Lars Magne Ingebrigtsen
@ 2011-06-26 20:45 ` Chong Yidong
  2011-06-26 21:08   ` Lars Magne Ingebrigtsen
  2011-06-30 16:34 ` Stefan Monnier
  1 sibling, 1 reply; 6+ messages in thread
From: Chong Yidong @ 2011-06-26 20:45 UTC (permalink / raw)
  To: emacs-devel

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> I just noticed that animated images keep on being animated even if the
> images themselves aren't displayed in any buffer.
>
> That seems wrong.
>
> Is there a way to query Emacs whether an image is actually displayed
> anywhere?  I looked through image.el, and I couldn't find anything...

AFAIK there is no way to check this right now.  Image lookup is
performed as needed during redisplay.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to find out whether an image is displayed anywhere?
  2011-06-26 20:45 ` Chong Yidong
@ 2011-06-26 21:08   ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 6+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-06-26 21:08 UTC (permalink / raw)
  To: emacs-devel

Chong Yidong <cyd@stupidchicken.com> writes:

> AFAIK there is no way to check this right now.  Image lookup is
> performed as needed during redisplay.

Then I guess Gnus will have to explicitly stop any animation going on in
the article buffer when de-selecting an article.  (I.e, loop over
`image-animate-timer' for the images first and cancel them.)

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to find out whether an image is displayed anywhere?
  2011-06-26 15:49 How to find out whether an image is displayed anywhere? Lars Magne Ingebrigtsen
  2011-06-26 20:45 ` Chong Yidong
@ 2011-06-30 16:34 ` Stefan Monnier
  2011-06-30 18:44   ` Lars Magne Ingebrigtsen
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2011-06-30 16:34 UTC (permalink / raw)
  To: emacs-devel

> Is there a way to query Emacs whether an image is actually displayed
> anywhere?  I looked through image.el, and I couldn't find anything...

There is a way: fontification-functions (aka "jit-lock").  It's a bit
round-about, but with enough work it should be possible to use it for
that purpose (e.g. use a timer to remove the `fontified' property every
N seconds and if it's still nil after an additional M seconds, then turn
off animation.  Or maybe better: after the animation timer fires don't
change the image yet but instead only remove the fontified property and
then change the image from fontification-functions).


        Stefan



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to find out whether an image is displayed anywhere?
  2011-06-30 16:34 ` Stefan Monnier
@ 2011-06-30 18:44   ` Lars Magne Ingebrigtsen
  2011-07-04 19:15     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-06-30 18:44 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Or maybe better: after the animation timer fires don't
> change the image yet but instead only remove the fontified property and
> then change the image from fontification-functions).

I'm not familiar (at all) with the jit-lock functions, but if you think
that's possible, I'm all for it.  :-)  But I'm not the person to
implement something like that.

It sounds like it could be kept nicely local to image.el, though, so the
users of the animated pictures don't have to care.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to find out whether an image is displayed anywhere?
  2011-06-30 18:44   ` Lars Magne Ingebrigtsen
@ 2011-07-04 19:15     ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2011-07-04 19:15 UTC (permalink / raw)
  To: emacs-devel

>> Or maybe better: after the animation timer fires don't
>> change the image yet but instead only remove the fontified property and
>> then change the image from fontification-functions).

> I'm not familiar (at all) with the jit-lock functions, but if you think
> that's possible, I'm all for it.  :-)  But I'm not the person to
> implement something like that.

> It sounds like it could be kept nicely local to image.el, though, so the
> users of the animated pictures don't have to care.

Indeed.  It would look something like:

- change the code that updates the image so that instead of actually
  updating the image, it just sets a `image-upon-redisplay-function'
  text-property on the image, whose value is a function that actually
  updates the image.
- call (jit-lock-register #'image-update-animations) somewhere.
- write image-update-animations which just looks for the
  image-upon-redisplay-function properties in the specified region and
  calls the corresponding function.

There are still some issues with respect to timer management (you may
want not to use a repeating timer but instead to re-arm the timer
manually from the image-upon-redisplay-function).


        Stefan



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-04 19:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-26 15:49 How to find out whether an image is displayed anywhere? Lars Magne Ingebrigtsen
2011-06-26 20:45 ` Chong Yidong
2011-06-26 21:08   ` Lars Magne Ingebrigtsen
2011-06-30 16:34 ` Stefan Monnier
2011-06-30 18:44   ` Lars Magne Ingebrigtsen
2011-07-04 19:15     ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).