nanogui: Newbie question--passing events between programs


Previous by date: 29 Jan 2002 18:52:45 -0000 Re: Newbie question--passing events between program s, Greg Haerr
Next by date: 29 Jan 2002 18:52:45 -0000 Re: Newbie question--passing events between program s, Alex Holden
Previous in thread: 29 Jan 2002 18:52:45 -0000 Re: Newbie question--passing events between program s, Greg Haerr
Next in thread: 29 Jan 2002 18:52:45 -0000 Re: Newbie question--passing events between program s, Alex Holden

Subject: Re: [nanogui] RE: Newbie question--passing events between program s
From: Alex Holden ####@####.####
Date: 29 Jan 2002 18:52:45 -0000
Message-Id: <3C56EE9F.2030600@linuxhacker.org>

Greg Haerr wrote:

> Take a look at the GrRequestClientData and GrSendClientData
> calls in nanox/client.c.

Actually this brings up a point I've been thinking about recently.

Those calls can indeed be used to send generic blocks of data between 
clients, but at the moment it's only really useful for the clipboard 
(selection), because it's necessary to find out the window ID that you 
want to request data from or send data to before you can do it.

I think we should extend this API by adding three more calls to 
implement a list of tags and associated window IDs. That would allow 
clients to advertise their presence to other clients, enabling arbitrary 
IPC via the Nano-X server. That will have two main advantages over using 
ordinary SysV IPC or named sockets or whatever:

* Automatic portability to every architecture that Nano-X runs on.
* Ability to function even if the clients are on different physical 
machines (once we implement networking support).

The calls would look something like this:

/**
  * GrAddTag:
  * @wid: the ID of the window associated with the tag
  * @tag: the tag string
  *
  * Adds the specified tag with the specified window ID to the server tag
  * list. If the tag already exists, its ID is changed to that specified
  * in this call. tag must be a zero terminated string less than ??
  * characters in length.
  */
void GrAddTag(GR_WINDOW_ID wid, GR_CHAR *tag);

/**
  * GrDeleteTag:
  * @tag: the tag string
  *
  * Deletes the specified tag from the server tag list. If no such tag
  * exists, nothing is changed. tag must be a zero terminated string.
  */
void GrDeleteTag(GR_CHAR *tag);

/**
  * GrFindTag:
  * @tag: the tag string
  *
  * Finds the specified tag in the server tag list and returns the
  * ID of the window associated with it. This is typically used to
  * find the ID of a window with a known tag string which you wish to
  * send data to using GrSendClientData() or request data from
  * using GrRequestClientData(). If the tag is not found, -1 is returned.
  * tag must be a zero terminated string.
  */
GR_WINDOW_ID GrFindTag(GR_CHAR *tag);

So with this API in place, Henry would have been able to decide on a tag 
string for his client window (eg. "henrys_client_1") and call in the client:

GrSelectEvents(client_window_id, GR_EVENT_MASK_CLIENT_DATA);
GrAddTag(client_window_id, "henrys_client_1");

Then in the server do:

client_window_id = GrFindTag("henrys_client_1");
GrSendClientData(server_window_id, client_window_id, 0, 5, 5, "hello");

The client would then receive an event with 
type=GR_EVENT_TYPE_CLIENT_DATA, wid=client_window_id, 
rid=server_window_id, serial=0, len=5, datalen=5, and data="hello".

It might be a good idea to automatically clean the tag list when a 
window is destroyed so we don't get stale tags lying around if a client 
crashes or forgets to delete its tags on exit.

-- 
------------ Alex Holden - http://www.linuxhacker.org ------------
If it doesn't work, you're not hitting it with a big enough hammer


Previous by date: 29 Jan 2002 18:52:45 -0000 Re: Newbie question--passing events between program s, Greg Haerr
Next by date: 29 Jan 2002 18:52:45 -0000 Re: Newbie question--passing events between program s, Alex Holden
Previous in thread: 29 Jan 2002 18:52:45 -0000 Re: Newbie question--passing events between program s, Greg Haerr
Next in thread: 29 Jan 2002 18:52:45 -0000 Re: Newbie question--passing events between program s, Alex Holden


Powered by ezmlm-browse 0.20.