emacs-devel
[Top][All Lists]
Advanced

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

Re: signal handling bogosities


From: Miles Bader
Subject: Re: signal handling bogosities
Date: 20 Dec 2002 10:44:53 +0900

Gerd Moellmann <address@hidden> writes:
> My feeling is that the cost of restructuring the code to use an event
> loop could be pretty high, but I've never investigated this very
> deeply because Richard thought the current way of doing things is
> good, and an event loop is an abomination :).  There were lots of
> other things to do anyway, so I didn't pursue this further.
> 
> Specifically for mouse-highlighting there may be a cheaper solution,
> though.  IIRC, I once talked with Stefan Monnier about generating
> mouse-highlight input events for mouse highlights instead of doing the
> display directly when handling the mouse movement event (analogous to
> help-echo, for example).
> 
> When that is done, normal redisplay could be used to draw the
> mouse-highlight, but it would have to be extended to use mouse-face
> for part of the text, which it currently doesn't.  Also, the logic
> determining which parts of a buffer/window are to be redisplayed would
> have to be extended somehow so that the highlighted region is
> displayed despite the fact that there have been no buffer changes.

Perhaps I'm confused, but why can't the existing code that runs from the
signal handler just be called from the event loop instead, at least as
an easy first-step?

For instance, if the signal handler currently looks like:

   void signal_handler (...)
   {
     if (some_test)
       do_mouse_stuff (mouse_info);
     else if (some_other_test)
       do_exposure_stuff (other info);
   }

change it to be like:

   void signal_handler (...)
   {
     if (some_test)
       queue_mouse_event (mouse_info);
     else if (some_other_test)
       queue_exposure_event (exposure_info);
   }

   void event_loop_function (...)
   {
      while (event in event loop)
        {
          ...
          if (event->type == mouse_event)
            do_mouse_stuff (event->mouse_info)
          else if (event->type == exposure_event)
            do_exposure_stuff (event->exposure_info)
          ...
        }
   }

In other words, re-use as much of the existing code as possible, but
change the place where it's called.

My (vague) reasoning is that if it currently can be called from a
_signal handler_, which is possibly the worst possible case, then the
code must be pretty safe to call from just about anywhere -- so why not
the event loop?

Thanks,

-Miles
-- 
I'm beginning to think that life is just one long Yoko Ono album; no rhyme
or reason, just a lot of incoherent shrieks and then it's over.  --Ian Wolff



reply via email to

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