unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* how to find out when display property is deleted in C?
@ 2008-05-12  9:34 joakim
  2008-05-12 14:25 ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: joakim @ 2008-05-12  9:34 UTC (permalink / raw)
  To: emacs-devel

How do I find out when a display property is deleted in C?

In the xwidget patch  I need to delete the corresponding xwdiget when
the display property is deleted.

-- 
Joakim Verona




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

* Re: how to find out when display property is deleted in C?
  2008-05-12  9:34 how to find out when display property is deleted in C? joakim
@ 2008-05-12 14:25 ` Stefan Monnier
  2008-05-12 14:58   ` joakim
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2008-05-12 14:25 UTC (permalink / raw)
  To: joakim; +Cc: emacs-devel

> How do I find out when a display property is deleted in C?

You don't/can't.

> In the xwidget patch I need to delete the corresponding xwdiget when
> the display property is deleted.

What happens if the display property is later re-added?
If that situations is not problematic, then you can keep your xwidgets
in a cache which you can flush every once in a while.

Also what happens if the same display property gets added at two places
(either in the same buffer or in different buffers)?


        Stefan




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

* Re: how to find out when display property is deleted in C?
  2008-05-12 14:25 ` Stefan Monnier
@ 2008-05-12 14:58   ` joakim
  2008-05-12 16:57     ` Stefan Monnier
  2008-05-12 20:08     ` Eli Zaretskii
  0 siblings, 2 replies; 7+ messages in thread
From: joakim @ 2008-05-12 14:58 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

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

>> How do I find out when a display property is deleted in C?
>
> You don't/can't.

Hmm.

>
>> In the xwidget patch I need to delete the corresponding xwdiget when
>> the display property is deleted.
>
> What happens if the display property is later re-added?
> If that situations is not problematic, then you can keep your xwidgets
> in a cache which you can flush every once in a while.

But I need to remove the gtk widget from display the precise moment the
display property goes away, or there will be very awkward display bugs.

As it is now, the widgets happily live on in the emacs window even after
their display property has been deleted. It looks very odd.

Images work differently, since you either draw them or you don't. In the
xwidget case, its the toolkit that owns the actual gtk widget, and the
toolkit must be informed when the widget is not to be drawn.

I could maybe have a new phase at the end of emacs redisplay, where all
xwidgets which haven't been drawn in this redisplay will be deleted.

This will be problematic for widgets that have been moved off screen
by cursor movement in the window though.

> Also what happens if the same display property gets added at two places
> (either in the same buffer or in different buffers)?

They cant be the same, because I require a unique id for every xwidget
in the display property:

(put-text-property (point) (+ 1 (point)) 'display '(xwidget :xwidget-id 3 :type 3 :title "3" :width 400 :height 200))

adding the same id twice is an error, as currently designed.

>
>         Stefan
-- 
Joakim Verona




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

* Re: how to find out when display property is deleted in C?
  2008-05-12 14:58   ` joakim
@ 2008-05-12 16:57     ` Stefan Monnier
  2008-05-12 20:08     ` Eli Zaretskii
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2008-05-12 16:57 UTC (permalink / raw)
  To: joakim; +Cc: emacs-devel

>>> How do I find out when a display property is deleted in C?
>> You don't/can't.
> Hmm.

>>> In the xwidget patch I need to delete the corresponding xwdiget when
>>> the display property is deleted.
>> What happens if the display property is later re-added?
>> If that situations is not problematic, then you can keep your xwidgets
>> in a cache which you can flush every once in a while.

> But I need to remove the gtk widget from display the precise moment the
> display property goes away, or there will be very awkward display bugs.

how do you deal with the case where the widget is scrolled out of view?

> I could maybe have a new phase at the end of emacs redisplay, where all
> xwidgets which haven't been drawn in this redisplay will be deleted.

Or marked as "out of view".  Yes, that sounds sensible.

>> Also what happens if the same display property gets added at two places
>> (either in the same buffer or in different buffers)?

> They cant be the same, because I require a unique id for every xwidget
> in the display property:

> (put-text-property (point) (+ 1 (point)) 'display '(xwidget :xwidget-id 3 :type 3 :title "3" :width 400 :height 200))

> adding the same id twice is an error, as currently designed.

Is this error properly caught and signalled to the user?


        Stefan




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

* Re: how to find out when display property is deleted in C?
  2008-05-12 14:58   ` joakim
  2008-05-12 16:57     ` Stefan Monnier
@ 2008-05-12 20:08     ` Eli Zaretskii
  2008-05-13  6:55       ` joakim
  1 sibling, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2008-05-12 20:08 UTC (permalink / raw)
  To: joakim; +Cc: monnier, emacs-devel

> From: joakim@verona.se
> Date: Mon, 12 May 2008 16:58:29 +0200
> Cc: emacs-devel@gnu.org
> 
> But I need to remove the gtk widget from display the precise moment the
> display property goes away, or there will be very awkward display bugs.
> 
> As it is now, the widgets happily live on in the emacs window even after
> their display property has been deleted. It looks very odd.

Forgive me for chiming into a discussion I wasn't following about a
subject that I'm mostly ignorant about, but: when the display property
goes away, Emacs triggers a redisplay the next moment it doesn't have
anything more important to do.  That redisplay should supply you with
an event to remove the gtk widgets, no?  Just plug your
widget-removing routines into the code that runs during redisplay.




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

* Re: how to find out when display property is deleted in C?
  2008-05-12 20:08     ` Eli Zaretskii
@ 2008-05-13  6:55       ` joakim
  2008-05-13 18:53         ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: joakim @ 2008-05-13  6:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: monnier, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:


> Forgive me for chiming into a discussion I wasn't following about a
> subject that I'm mostly ignorant about, but: when the display property
> goes away, Emacs triggers a redisplay the next moment it doesn't have
> anything more important to do.  That redisplay should supply you with
> an event to remove the gtk widgets, no?  Just plug your
> widget-removing routines into the code that runs during redisplay.

I tried this and I'm still having difficulties. The redisplay
code optimizes drawing. It appears these optimizations make it so the
xwidget glyph draw routine isnt allways called on redisplay. I tried to
work around this by adding a flag to the buffer modify routines. The
idea is, if the flag is set and the widget hasnt been redrawn, then it
should die. So far I havent had any sucess.

-- 
Joakim Verona




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

* Re: how to find out when display property is deleted in C?
  2008-05-13  6:55       ` joakim
@ 2008-05-13 18:53         ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2008-05-13 18:53 UTC (permalink / raw)
  To: joakim; +Cc: monnier, emacs-devel

> From: joakim@verona.se
> Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
> cc: emacs-devel@gnu.org
> Date: Tue, 13 May 2008 08:55:48 +0200
> 
> > Forgive me for chiming into a discussion I wasn't following about a
> > subject that I'm mostly ignorant about, but: when the display property
> > goes away, Emacs triggers a redisplay the next moment it doesn't have
> > anything more important to do.  That redisplay should supply you with
> > an event to remove the gtk widgets, no?  Just plug your
> > widget-removing routines into the code that runs during redisplay.
> 
> I tried this and I'm still having difficulties. The redisplay
> code optimizes drawing. It appears these optimizations make it so the
> xwidget glyph draw routine isnt allways called on redisplay.

Search xdisp.c for "optimiz", and you will find quite a few ways of
turning off these optimizations.  For example, you could set the
prevent_redisplay_optimizations_p flag of the buffer, or set the value
of this_line_start_pos variable non-positive.  It could be that this
works, but makes redisplay painfully slow, in which case less naive
coding will be needed to turn off optimizations only sometimes.  But
at least you will know that it works; I was taught to make it right
before I make it fast.




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

end of thread, other threads:[~2008-05-13 18:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-12  9:34 how to find out when display property is deleted in C? joakim
2008-05-12 14:25 ` Stefan Monnier
2008-05-12 14:58   ` joakim
2008-05-12 16:57     ` Stefan Monnier
2008-05-12 20:08     ` Eli Zaretskii
2008-05-13  6:55       ` joakim
2008-05-13 18:53         ` Eli Zaretskii

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).