[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Aug 3 20:08:14 1993 
Subject:Re: Prodding Ved from the Outside 
From:jonm (Jonathan Meyer) 
Volume-ID:930803.07 

Re. sending messages to XVed to tell it to open a file.

I have thought quite a bit about this topic recently - it would be useful
in general to be able to send messages to a Poplog running on a display.

My solution would be to use X Windows `properties' to communicate messages
to Poplog processes running on a display.

(What follows requires some knowledge of X and is fairly technical).

I would create a property on the root window of the user's display,
say called __POPLOG_MESSAGE_WINDOWS. This would be a list of window IDS
representing the Poplog processes running on that display.

Each time Poplog starts its connection to an X display it would create an
unmapped OverrideShell widget and append the ID of the widget's window to the 
__POPLOG_MESSAGE_WINDOWS list (using XSetWindowProperty). It would define 
an event handler (using XtAddEventHandler) for the shell widget which looks 
for PropertyNotify events on its window. When a property notify event is 
received Poplog would get the value of e.g. the __POPLOG_MESSAGE property 
associated with the window (using XGetWindowProperty), deleting the property 
in the process. The value of the property would be a string which is
parsed (e.g. compiled).

You would need to write a small C message sending program which would:

  connected to the X display

  read the contents of __POPLOG_MESSAGE_WINDOWS using XGetWindowProperty.

  iterate over the list (most recent entries first) looking for valid 
  window ID's (e.g. using XGetGeometry) (removing invalid window ID's - 
  they represent dead poplogs).

  if a valid window ID is found then the property __POPLOG_MESSAGE
  is created on that window and set to a string representing the
  message (using XSetWindowProperty again). Then the C program waits until:

      a) the __POPLOG_MESSAGE property is deleted (indicating that the Poplog
      process received the message).

      b) the window gets destroyed (the Poplog process exited).
  
      c) a timeout expires (the Poplog process is not responding).

   in case (a) the C message sending program exits with a 0 exit status.

   in case (b) and (c) it continues iterating over __POPLOG_MESSAGE_WINDOWS
   until the list is exhausted and then exits with a 1 exit status.

All clear?

You could very easily imagine a system where Poplog processes can create
multiple message windows, each with different names. The message sending 
program would be altered to not only search for valid window ids, but also 
look for windows with a specific name. Then you could have multiple message 
contexts. You might then do:

   % popsend -client "xved" 'vedscreenbell()'

or
   % popsend -client "hipworks" 'hip_go("myproduction")'

etc.

You could use the exit status of -popsend- to decide to start a new
XVed/HiPWorks process if one didn't exist. 

Unfortunately it would take several days to document and implement a system 
like this properly - anyone got the time?

Comments?

Jon.