passing raw events to all widgets?

How can I pass an event to all widgets in my GUI?
I would like to do this so that a single button press will notify all widgets to change it’s color at run-time.

Here is more info:
I know I can process all the other widgets that I would like to change the color from the callback of the current button pressed, but I don’t like this approach. I would like this special button to generate some kind of notification to photon event so that all the widgets that are sensitive to this event will invoke their own callbacks. I guess something like Hotkey, but it’s not keyboard generated events. I am not too familiar with Photon/widget area but I guess it’s like custom events. Like how we can use custom msg/pulse. Does this make sense?

PtSetArg() - is that, that you describe will be best.
Also you may send pulse on button press to other thread that receive this pulse and PtEnter->PtSetArg()->PtLeave if you want to nonblock you interface on button press.

I don’t think this is what I am looking for. Basically what I want to have is a set of code which is able to make other widgets callback to be executed. For example, if I have 5 label widgets and one button, and if I press this button, it will trigger the label widgets to execute their callbacks (maybe raw events callback) to do what it needs to do.
Basically, I want to send an event to all the widgets to execute their callbacks, and only those widgets that are sensitive to that event will respond by executing their appropriate callbacks.

I know it is very infectious to use the lingo provided with a system to describe what you want.
In this case I think it makes things a little confusing.
The underlying request you are making seems to be, that you want to push a button, and in so doing, have all your applications change their colors. Is that right?
You don’t want to inform the widgets. You want to inform the processes.
There are more than one way of going about this. Let me give two versions, trying
to be as simple as possible.

First, assuming the change color button application
knows all the processes that have to change color. In this case, when you press
the button, it’s callback is called. From this callback, you send a private
message to each application (or maybe raise a signal). These processes
react to this message by changing the color of their widgets.

Now assume that no such list exists. How can you still do this? Give each application a very
large (cover (0-64K,0-64K) raw widget with special properties. Make it sensitive to one event
but not opaque. The change color button widget has to be on top, and it emits this event.
Each of the raw widgets has a callback that wakes up when the event passes by, and
goes about the business of changing the widget colors. Of course there is the question of what
color to change this to. The event will not pass this information. You could have some shared
memory that holds this information.

thanks for your reply.
Yes, I was looking for a solution close to the second one you suggested.
Can you give some detail code for this solution? For example, when this button is pressed the callback should generate a event, how can I do this?
Second, when the event is generated how can the other widgets be sensitive to this event? Also you said raw widgets, but can I use other widgets?
And what do you mean “Give each application a very large (cover (0-64K,0-64K)”


I don’t have any specific code that does this. I wrote a screen saver
program for QNX 4. After a few iterations in Photon it stopped working
so I don’t know if it would be useful. It only looks for events, it doesn’t
emit them.

Search the Photon documentation for “emit”

In general, photon events have an x,y location. They travel in the z
direction, and only regions that they intersect can detect them. My
suggestion was to have a very large region that will always intersect
the event. I don’t remember the details of making regions sensitive and
non-opaque, but if you look at the region creation routine it should help.
You might also try to use a raw widget in PhAB to do this. Raw widgets, unlike widgets in general, need their own region.

I don’t understand why I must use raw widgets? Can’t my other widgets also intersect raw events when I produce it like this.

#include <stdio.h>
#include <time.h>
#include <Ph.h>

int main( int argc, char *argv[] )
PhEvent_t event = { 0 };
PhRect_t rect;

 if( NULL == PhAttach( NULL, NULL ) ) {
      fprintf( stderr,
             "Couldn't attach Photon channel.\n");
      exit( EXIT_FAILURE );
 event.type = Ph_EV_EXPOSE;
 event.subtype = 0;
 event.flags = 0;
 event.num_rects = 1;
 event.data_len = 0;
 event.emitter.rid = Ph_DEV_RID;
 rect.ul.x = rect.ul.y = SHRT_MIN; = = SHRT_MAX;
 PhEmit( &event, &rect, NULL );



Well, let me see if I can help with this rather difficult question.
Widgets are not fundamental to Photon. They are software
constructs. Regions however are. Some widgets have a
region, for example Windows and Dialogs. Without a region,
these widgets could not detect events. Widgets contained within
but who themselves do not have a region, can benefit from their
container having a region.

Most events in Photon have a specific x,y location, for example when you click on a mouse, this is at a specific x,y location in the Photon space.
The photon kernel, which transmits this event, searches from front to back for regions that intersect this x,y location which are sensitive to the event.
If the region is opaque to the event, then the event stops. If sensitive, the program that owns this region gets a message. It is up to the application to determine what action occurs. Since the event is usually received by a region owned by the Window widget, the window widget code would translate the absolute x,y location to a relative location, and determine which if any contained widgets need to be informed about the event.

Your situation is a little unusual in that you want to emit a single event, and have every process be informed of it. The Photon way for this to happen is for each application to cover the entire Photon space with a region that is sensitive to, but not opaque to the event. On second thought, I don’t think a raw widget will do, as I believe its
region will be clipped by the region of its container, a Window. So you will have to look at the Photon primitives to create your own region to accomplish all this.

As I said, there are other ways to accomplish this. Here is very simple, but QNX oriented way.

Have a simple “color” resource manager. When your special button is pushed, have the callback send a message to this resource manager with the new color information.

Have all your applications periodically read from the resource manager and determine if a new color has been chosen. They could have a thread in your applications reading this all the time, and then you would get an event driven change.

Ok I see.
Then can you explain what happens when I have two windows (one in front the other behind) and an event is sent to one of the window. Do both window intercept this event or just the one at the top? Furthermore, once an event is intercepted by window, will the event be sent to all the widgets in the window? If not how can I make it so that this event is sent to both windows and all the widgets in side that window?

Since window has its region, if I make it non opaque, but sensitive, wouldn’t it work? And in terms of widgets inside a window, if all the widgets do not consume the event but are sensitive to it, wouldn’t all the widgets be notified eventually? Finally, I don’t understand the concept of event going down through the widget hierarchy and coming back up to the emitter? Then should the emitter always consume an event to avoid infinite loop of events going back and forth?

I hope that there is more clear documentation on this but I can’t find it. QNX doc is either too high level or just bit and Pieces of things regarding this topic.

A lot of questions. Windows only get an event if their region intersects the event and it is sensitive to it. If the one on top is opaque to the event, it stops it, otherwise the event keeps going. You are going to have to handle this event yourself. It will not be sent to all the widgets, and this is not what you want anyway. The application will know what resources need their colors changed, and should change them in the usual manner. I’m going to repeat this, You do not want or care whether the event is sent to all the widgets, you simple update the resources you want to change on receipt of the event.

Mostly NO. You probably don’t want to modify the window’s region. That would be interfering with the window widget. You want to create your own region, one that covers the entire Photon space. The event you will create will only go in one direction. I’m not really sure what type of event you need to use, but probably something non-standard. If you send a mouse click event, something will probably intercept/consume it. The event will not “bounce” back. You do not have to consume the event, Photon will take care of this for you.

Well for starters, the Photon documentation does describe the Photon space and events fairly well, although it is not very practical. The manual describes the Photon calls fairly well, but there is probably no tutorial or “how to” section on this. Just start reading the functions (primitives) that deal with regions.

As I mentioned, there are other ways to accomplish this, and under the circumstances, I think they would be easier.

The reason why I want to make this work was so that I can minimize the coding so that when ever I added this type of widget I don’t have to write a seperate code to update its resources. I wanted to have one generic callback for all widgets to call when this event happens, but I guess this is just a dream.

Thanks anyways
Happy New years