[comp.windows.open-look] a problem with tNt

ks@tut.fi (Syst{ Kari) (01/15/91)

I'm trying to have a canvas which is interactively moved by the
user. Here is a simplified code:

/Movable ClassCanvas []
classbegin
  /FillColor 1 0 0 rgbcolor def
  /minsize { 50 50 } def
  /movefromuser {
      /movefromuser super send
      parent setcanvas
      (moved to % %\n) [ /location self send ] printf
      /paint parent send
  } def
  /MakeInterests {
      /MakeInterests super send
      /LeftMouseButton {pop /movefromuser }
      /DownTransition Canvas MakeInterest
  } def
classend def


/win [AbsoluteBag] [] framebuffer /new OpenLookBaseFrame send def
100 400 400 400 /reshape win send
/m [100 100 Movable ] /addclient /client win send send
/activate win send
/map win send

Every now and then (if mouse clicked very fast) the /movefromuser method
seems to loose the UpTransition. The consequence that system keeps drawing
the outline of the movable canvas and no other window can get a focus.
Another (too fast) click is a way to get rid of this problem.

Anybody had same kind of problems? 

Configuration:
 OW 2.0
 SS1, color, 16MB, no GX





--
% This article represents my personal views.
% NeWS flash: "X is the Fortran of windowing systems."
% Kari Systa, Tampere Univ. Technology, Box 527, 33101 Tampere, Finland
% work: +358 31 162585      fax: +358 31 162913      home: +358 31 177412

flar@bendenweyr.Eng.Sun.COM (Jim Graham) (01/15/91)

In OpenWindows 2.0 (NeWS version 2.1), you have to set the /Synchronous
flag on interests whose associated actions modify the event propagation
strategy.  The reason for this is that all events are now delivered
immediately upon generation unlike previous versions of NeWS which would
only deliver events once per cycle through the process dispatcher.

So, if the up event is generated while your PS code is still trying to
express the interest in that event, the event could pass you right by.
To solve this, make the interest in the downtransition Synchronous (see
your NeWS 2.1 programming guide for more information).  Then, when the
downtransition is delivered, the input queue is automatically blocked
until you unblock it, thereby holding the uptransition from being delivered
until you are ready for it (i.e. have expressed interest in it).

|>   /MakeInterests {
|>       /MakeInterests super send
|>       /LeftMouseButton {pop /movefromuser }
|>       /DownTransition Canvas MakeInterest
	 dup /Synchronous true put			% add this line
|>   } def

Then, in the /movefromuser method, put an unblockinputqueue after the
code which creates the /Uptransition interest and expresses it.  In
general try to put the code which modifies event propagation (maps canvases
or expresses or revokes interests) as early in your event handling
code as possible and then unblock the input queue as soon as you can
to avoid holding up event propagation any more than you have to.

					...jim