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
flar@bendenweyr.Eng.Sun.COM (Jim Graham) (01/15/91)
Oh, and one last thing. You probably also want to set the /Exclusivity flag on the event so that the event doesn't continue on past you and possibly reach another client (such as olwm) and cause contention over who "owns" the interaction. You should also make the uptransition interest synchronous and exclusive and any interest in mousedragging exclusive (but not synchronous). ...jim
smith@canon.co.uk (Mark Smith) (01/15/91)
ks@tut.fi (Syst{ Kari) writes: > I'm trying to have a canvas which is interactively moved by the > user. Here is a simplified code: > > [ ...code deleted... ] > > 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. Check out the section about blocking the global event queue on pages 125-126 of the NeWS 2.1 Programmer's Guide. In your example, you should change this line in /MakeInterests: > /DownTransition Canvas MakeInterest to: > /DownTransition Canvas MakeInterest dup /Synchronous true put This sets the Synchronous key in the interest to true, which makes the DownTransition event block the input queue. You should add 'unblockinputqueue' to your callback routine, after spinning off the event manager waiting for the UpTransition. =========================================================================== Mark Smith smith@canon.co.uk Canon Research Centre Europe ...uunet!mcsun!ukc!uos-ee!canon!smith --------------------------------------------------------------------------- soft driven slow and mad like some new language