nanogui: Newbie question--passing events between programs


Previous by date: 29 Jan 2002 12:26:44 -0000 SetTop box Development [sorta an advert], Darran D. Rimron-Molloy
Next by date: 29 Jan 2002 12:26:44 -0000 Re: Newbie question--passing events between program s, Henry Chea
Previous in thread: 29 Jan 2002 12:26:44 -0000 Newbie question--passing events between programs, Henry Chea
Next in thread: 29 Jan 2002 12:26:44 -0000 Re: Newbie question--passing events between program s, Henry Chea

Subject: RE: Newbie question--passing events between programs
From: Henry Chea ####@####.####
Date: 29 Jan 2002 12:26:44 -0000
Message-Id: <F53B81109388D044A3CF6E7300FF7F0F1E1FE7@gotz-fs1.semcon.se>

Hi again,

Yeah I know I'm replying to my own message, but I'm desperate *desperate*!
=)

I have been searching for countless hours how to solve my problem (making a
control program pass events via the Nano-X server to another program that
listens for the events), and have come across what is perhaps the solution
though I do not know how to use it:

GrRegisterInput(int fd)
GrPrepareSelect (int * maxfd , void * rfdset)
and
GrServiceSelect (void * rfdset , GR_FNCALLBACKEVENT fncb)

Those three functions seem to be what I need, but I can't figure out how to
use them nor can I find any documentation/examples on their use (I tried
decifering the source code too but I'm not that smart).

Can someone please help me?  I would be very greatful!

Maybe point me to examples, docs, or perhaps edit my source code below to
show how to solve the problem?

Thanks again,
Henry Chea
Semcon Sweden AB

****************************
//control.c
#include <stdio.h>
#define MWINCLUDECOLORS
#include "microwin/nano-X.h"

GR_WINDOW_ID control_wid;
GR_GC_ID gc;

int control_fd;

void event_handler (GR_EVENT *event);

int main (void)
{
        if ((control_fd = GrOpen()) < 0)
        {
                fprintf (stderr, "GrOpen failed");
                exit (1);
        }


        gc = GrNewGC();
        GrSetGCUseBackground (gc, GR_FALSE);
        GrSetGCForeground (gc, BLUE);

        control_wid = GrNewWindowEx (GR_WM_PROPS_NOMOVE |
                        GR_WM_PROPS_BORDER |
                        GR_WM_PROPS_NOAUTOMOVE |
                        GR_WM_PROPS_NOAUTORESIZE,
                        "Control Window",
                        GR_ROOT_WINDOW_ID,
                        0, 0, 150, 478, YELLOW);

        GrSelectEvents (control_wid, GR_EVENT_MASK_EXPOSURE |
                        GR_EVENT_MASK_BUTTON_DOWN);

        GrMapWindow (control_wid);
        GrMainLoop (event_handler);
}

void event_handler (GR_EVENT *event)
{
        switch (event->type)
        {
        case GR_EVENT_TYPE_EXPOSURE:
                GrText (control_wid, gc, 20, 20,
                        "Click me", -1, GR_TFASCII);
                break;

        case GR_EVENT_TYPE_BUTTON_DOWN:
                GrClearWindow (control_wid , GR_TRUE);
                ???SOMEHOW_SEND_EVENT_TO_NANO-X_HERE???
                break;
        }
}

******************************
//SLAVE.C
#include <stdio.h>
#define MWINCLUDECOLORS
#include "microwin/nano-X.h"

GR_WINDOW_ID slave_wid;
GR_GC_ID gc;

void event_handler (GR_EVENT *event);

int slave_fd;

int main (void)
{
        if ((slave_fd = GrOpen()) < 0)
        {
                fprintf (stderr, "GrOpen failed");
                exit (1);
        }

        gc = GrNewGC();
        GrSetGCUseBackground (gc, GR_FALSE);
        GrSetGCForeground (gc, RED);

        slave_wid = GrNewWindowEx (GR_WM_PROPS_APPFRAME |
                        GR_WM_PROPS_CAPTION |
                        GR_WM_PROPS_CLOSEBOX,
                        "slave Window",
                        GR_ROOT_WINDOW_ID,
                        150, 150, 200, 100, WHITE);

        GrSelectEvents (slave_wid, GR_EVENT_MASK_CLOSE_REQ|
                        ???EVENT_PASSED_FROM_CONTROL_PROGRAM???);

        GrMapWindow (slave_wid);
        GrMainLoop (event_handler);
}

void event_handler (GR_EVENT *event)
{
        switch (event->type)
        {
        case GR_EVENT_TYPE_CLOSE_REQ:
                GrClose();
                exit (0);

        case ???EVENT_PASSED_FROM_CONTROL_PROGRAM???:
                GrText (slave_wid, gc, 50, 50,
                        "Received a message from control", -1, GR_TFASCII);
                break;
        }
}
******************************

-----Original Message-----
From: Henry Chea
To: ####@####.####
Sent: 1/28/2002 10:10 AM
Subject: Newbie question--passing events between programs

Hi all,

In Nano-X I want to create a "control" program that creates and passes
events to "slave" programs.  That is to say that the slave programs
listen for events created by the control program.

Ideally I would like to make a control program that creates and inserts
events into the Nano-X server event queue.  

Can anyone help show me how to do this?

Thanks for the help,

Henry Chea
Semcon Sweden AB

Previous by date: 29 Jan 2002 12:26:44 -0000 SetTop box Development [sorta an advert], Darran D. Rimron-Molloy
Next by date: 29 Jan 2002 12:26:44 -0000 Re: Newbie question--passing events between program s, Henry Chea
Previous in thread: 29 Jan 2002 12:26:44 -0000 Newbie question--passing events between programs, Henry Chea
Next in thread: 29 Jan 2002 12:26:44 -0000 Re: Newbie question--passing events between program s, Henry Chea


Powered by ezmlm-browse 0.20.