[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

2550.0. "ADA VMS 5.3 toolkit event handling" by SAILN::HA () Fri Mar 30 1990 20:35

My customer is having the following difficulty:

They are running 5.3 VMS, DECWINDOWS, and ADA.

In one process, they have 32 ADA tasks, one of which handles the DECwindows
interface.

One of theses tasks handles X event processing.

Another of these tasks kicks off 6 application shell widgets, plus
they use Xlib calls to handle a zooming/panning and editing window.

The problem is that they can't use XtMainLoop() because it blocks.

They tried:

1) XCheckMaskEvent() in conjuction with XtDispatchEvent(), which
   works on all events except entering text into a simple text
   widget - the cursor does not blink, but you can enter text
   into the widget.  On rare occaisions they see the following
   error:

X error event received from server: Badmatch - parameter mismatch
    Failed request major opcode 42 (X_SetInputFocus)
    Failed request minor opcode  0 (if applicable)
    Resource ID 0x200295 in failed request (if applicable)
    Serial number of failed request 2467
    Current serial number in output stream 2484

2) XtPending() and if there is an event do an XtNextEvent() plus
   XtDispatchEvent().  However, when a timer event is hit,
   XtNextEvent() blocks and all tasks are deadlocked.  The interesting
   thing is that if you keep clicking, eventually things seem to
   flush out and the application continues to work merrily along.
   This is not too keen though since you don't want the users
   to have to click all over the place to unwedge the application.

3) using 2) but having an additional task to handle timeout events
   and the original task handle all other events.  The timeout event
   handler task runs at priority 7 and the other event handler task
   runs at priority 12.  I know this does not work because of 
   re-entrancy problems/two things reading the same queue or two
   things being dispatched simultaneously????

Any suggestions on how they can look for events without blocking
while using the toolkit and ADA?

I looked at the notes dealing with XSelectAsyncInput() and
XSendEvent(), but these routines seem to deal only with windows
and not widgets.


                                            Michael

                              
Cross posted in ADA.
T.RTitleUserPersonal
Name
DateLines
2550.1...GSRC::WESTVariables don't, Constants aren'tMon Apr 02 1990 13:0510
  Well, you got the first answer right...do to re-entrancy problems, especially
with the toolkit you really don't want to use tasks, but if you must then I
believe the general concensus is that only ONE task does ALL toolkit work.

  As for checking the event que so you would not block, take a look at
XPending or the prefered XEventsQueued calls.

					-=> Jim <=-

2550.2XtEvent blocks for IOSAILN::HAMon Apr 02 1990 15:1415
    Ok, they tried putting all toolkit calls and event handling into
    one task and this seems to work - but there is still one problem.
    They are using XtNextEvent() - but this blocks for IO so one of
    their other tasks that does a database retrieval is prevented
    from running.  If they bump the priority of the task doing
    XtNextEvent() down to 6 this allows the database retrieval task
    to continue but this task runs at priority 7 and so once this
    database task runs no more Xt events are recognized.
    
    Also, the customer WHY is XEventsQueued preferred over XPending?
    Is it possible to get a description of how the queues are utilized
    (what is put on the queue, what, which, when, and HOW are events
    removed)?  Is it possible to get the source for the event handling
    code?
    
2550.3Try XtPending/XtProcessEventLEOVAX::TREGGIARITue Apr 03 1990 08:429
    You don't have to use XtNextEvent.  If you want more control over what
    is happening, use XtPending and XtProcessEvent instead.  XtPending
    returns a mask of the type(s) of toolkit input that are pending
    {X event | timer | alternate input}.  XtProcessEvent takes the same
    type of mask and processes exactly one event of the type(s) you
    request.  By simply passing the mask you receive from XtPending back into
    XtProcessEvent, you are guaranteed to never block.
    
    Leo
2550.4To flush or not to flushDECWIN::KLEINTue Apr 03 1990 13:147
>    Also, the customer WHY is XEventsQueued preferred over XPending?

XEventsQueued is preferred because it does not (necessarily) cause the
output queue to be flushed (XFlush) if there are no more events pending.
XPending always does an extra XFlush (for historical reasons).

-steve-
2550.5Ada example of non-blocking event processing...GSRC::WESTVariables don&#039;t, Constants aren&#039;tWed Apr 04 1990 12:1627
  Below is a sample piece of Ada code demonstrating event processing without
blocking.

						-=> Jim <=-

================================================================================

  forever:
  loop

    x.events_queued (
      result	=> number_of_events,
      display	=> display,
      mode	=> x.c_queued_after_flush);

    if number_of_events > 0 then

      x.next_event (
        display		=> display,
	event_return	=> event);

      dwt.xt_dispatch_event (event => event);

    end if;

  end loop forever;
2550.6thanks!SAILN::HAWed Apr 04 1990 18:477
    Thanks for everyone's speedy help!  We've think we've managed 
    to get something working by using XSendEvent to send ourselves
    an event to unwedge ourselves and get things started again.  
    We'll also try out XProcessEvent to see how it works.  The
    only strange thing with XSendEvent is that we try and send
    a ClientMessage and we never seem to get it - has anyone heard
    of this?  Possible bug?  
2550.7Lots of wrong ways to XSendEventDECWIN::KLEINWed Apr 04 1990 19:179
>    We'll also try out XProcessEvent to see how it works.  The
>    only strange thing with XSendEvent is that we try and send
>    a ClientMessage and we never seem to get it - has anyone heard
>   of this?  Possible bug? 

Post your XSendEvent code.  The window field (as well as some of the
other fields) in the event structure must be properly initialized.

-steve-
2550.8I need to condense codeSAILN::HAWed Apr 11 1990 22:577
    Haven't had time to condense down the code - the customer's built
    up all these layers over the X calls and it's going to take
    a bit of work to untangle it.  I'll post it/send you mail when
    I have it in a workable state...
    
    
    						Michael