Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Xt-equivalent for GTK code

12 views
Skip to first unread message

Roland Mainz

unread,
Aug 22, 2000, 3:00:00 AM8/22/00
to

Hi !

----

I'm looking for the Xt equivalent for the following code:

-- snip --
XClearArea(pdpy, pwin, 0, 0, 0, 0, True );

while (gtk_events_pending()) {
gtk_main_iteration();
}
-- snip --

XClearArea() generates an EXPOSE event and the following even loop
handels all generated events until the event queue becomes empty.
How would the same code look-like for Xt/Athena/Motif ?

----

Bye,
Roland

--
__ . . __
(o.\ \/ /.o) Roland...@informatik.med.uni-giessen.de
\__\/\/__/ gis...@informatik.med.uni-giessen.de
/O /==\ O\ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
(;O/ \/ \O;) TEL +49 641 99-13193 FAX +49 641 99-41359

Pierre Ficheux

unread,
Aug 24, 2000, 3:00:00 AM8/24/00
to Roland Mainz
Roland Mainz wrote:

> I'm looking for the Xt equivalent for the following code:
>
> -- snip --
> XClearArea(pdpy, pwin, 0, 0, 0, 0, True );
>
> while (gtk_events_pending()) {
> gtk_main_iteration();
> }
> -- snip --
>
> XClearArea() generates an EXPOSE event and the following even loop
> handels all generated events until the event queue becomes empty.
> How would the same code look-like for Xt/Athena/Motif ?


Not really. On Xt/Athena/Motif, you can define event handlers for event
masks and most of time evrything is handler by the XtAppMainLoop().
Additionnaly, Xt uses widgets so the code could be:


XtAddEventHandler (pwidget, ExposureMask, False,
(XtEventHandler)expose_handler, (XtPointer)NULL);
...
XtAppMainLoop (app_context);
...
XClearArea(XtDisplay(pwidget), XtWindow(pwidget), 0, 0, 0, 0, True );


regards,

> Roland

--
Pierre FICHEUX -/- COM One, Cestas, France -\- pfic...@com1.fr
http://www.com1.fr/~pficheux
Hiroshima '45 Chernobyl '86 Windows '95

Roland Mainz

unread,
Aug 25, 2000, 3:00:00 AM8/25/00
to
Pierre Ficheux wrote:

> > I'm looking for the Xt equivalent for the following code:
> >
> > -- snip --
> > XClearArea(pdpy, pwin, 0, 0, 0, 0, True );
> >
> > while (gtk_events_pending()) {
> > gtk_main_iteration();
> > }
> > -- snip --
> >
> > XClearArea() generates an EXPOSE event and the following even loop
> > handels all generated events until the event queue becomes empty.
> > How would the same code look-like for Xt/Athena/Motif ?
>
> Not really. On Xt/Athena/Motif, you can define event handlers for event
> masks and most of time evrything is handler by the XtAppMainLoop().
> Additionnaly, Xt uses widgets so the code could be:
>
> XtAddEventHandler (pwidget, ExposureMask, False,
> (XtEventHandler)expose_handler, (XtPointer)NULL);
> ...
> XtAppMainLoop (app_context);
> ...
> XClearArea(XtDisplay(pwidget), XtWindow(pwidget), 0, 0, 0, 0, True );

Mhhh, my intetion is to get something like this:
1. Open display
2. Realize all wigets.
3. Go into main loop.
4. Receive an event when window as been mapped and all widgets have been
rendered.

How to do this ([4] is the most important one...) ?

Pierre Ficheux

unread,
Aug 28, 2000, 3:00:00 AM8/28/00
to Roland Mainz
Roland Mainz wrote:

> Mhhh, my intetion is to get something like this:

> 4. Receive an event when window as been mapped and all widgets have been
> rendered.
>
> How to do this ([4] is the most important one...) ?

Here is a small sample program which handle Expose event of 'hello'
widget:

#include <X11/Intrinsic.h>
#include <X11/Xaw/Label.h>

static void handle_expose (Widget w, XEvent pevent, String *params,
Cardinal nb_params)
{
printf ("Got Expose event\n");
}

main(int argc, char **argv)
{
Widget topLevel, hello;
XtAppContext app;

topLevel = XtAppInitialize (&app, "XExpose", NULL, 0, &argc, argv,
NULL, NULL, 0);
hello = XtVaCreateManagedWidget ("hello_world", labelWidgetClass,
topLevel, NULL);
XtAddEventHandler (hello, ExposureMask, False,
(XtEventHandler)handle_expose, NULL);

XtRealizeWidget(topLevel);
XtAppMainLoop(app);
}

You should use the following Imakefile:

LDLIBS = XawClientLibs
SimpleProgramTarget(xexpose)

Then:

xmkmf
make
xexpose &

You should check-out http://www.rahul.net/kenton wich contains *lots*
of pointers about X programming...

Roland Mainz

unread,
Aug 28, 2000, 3:00:00 AM8/28/00
to
Pierre Ficheux wrote:

[snip]


> main(int argc, char **argv)
> {
> Widget topLevel, hello;
> XtAppContext app;
>
> topLevel = XtAppInitialize (&app, "XExpose", NULL, 0, &argc, argv,
> NULL, NULL, 0);
> hello = XtVaCreateManagedWidget ("hello_world", labelWidgetClass,
> topLevel, NULL);
> XtAddEventHandler (hello, ExposureMask, False,
> (XtEventHandler)handle_expose, NULL);
>
> XtRealizeWidget(topLevel);
> XtAppMainLoop(app);
> }

Is handle_expose() called before or after the widgets processed the
EXPOSE event ?

Rick Scott

unread,
Aug 29, 2000, 3:00:00 AM8/29/00
to
Well, according to the good ole man page....

"The Intrinsics do not specify the order in which event
handlers will be called when an event arrives."

The man page does offer a way to be sure when it is called....

--
Rick Scott (LessTif developer)

Antony Uspensky

unread,
Aug 29, 2000, 3:00:00 AM8/29/00
to
Roland Mainz wrote:
>
> Is handle_expose() called before or after the widgets processed the
> EXPOSE event ?
>
The order is not defined, if I'm right, but probably after because you
usually form an unique pair of handler_procedure<->client_data and it is
inserted at the tail of list. Read intrinsics.ps, section 7.11.
If you need to call this routine before or after all other handlers, use
XtInsertEventHandler().

Roland Mainz

unread,
Aug 29, 2000, 3:00:00 AM8/29/00
to
Pierre Ficheux wrote:

> > Mhhh, my intetion is to get something like this:
> > 4. Receive an event when window as been mapped and all widgets have been
> > rendered.

[snip]


> You should check-out http://www.rahul.net/kenton wich contains *lots*
> of pointers about X programming...

I looked into it before I posted my question here - without success.

To explain my real problem:
I'd like to print complete Xt/Athena/Motif GUIs with libXp/Xprt (X print
system).
The idea is:
1. Open window on Xprt
2. Create GUI.
3. XpStartPage()
4. redraw_GUI()
5. XpEndPage()
6. clean_up()

Any drawing command between XpStartPage() and XpEndPage() is tracked by
the X11 print server and converted into printer commands
(PostScript/PCL/CUPS etc.).
Therefore I need a way to do step 4 (redraw whole GUI and wait until the
complete redraw is done). Any ideas ?

Antony Uspensky

unread,
Sep 1, 2000, 4:18:05 AM9/1/00
to
Antony Uspensky wrote:
>
> ... if I'm right ...

I was wrong: Expose (and NoExpose, GraphicsExpose and VisibilityNotify)
has special meaning for Intrinsics - the last contains internal handlers
for the events and call these handlers before all other ones registered
by Xt*EventHandler() (and callbacks, of course).
So I see only 2 solutions:
a) subclass your widget - add exposeCallback and supply Expose class
method, from which just call exposeCallbacks and then Expose class
method of superclass.
b) break XtAppMainLoop into parts and insert some checking procedure
into it - the last will get Expose events before any other part of your
application.
{
XEvent ev;
for (;;) {
XtAppNextEvent(app_context, &ev);
if (ev.type == Expose) exposeProc();
XtDispatchEvent(&ev);
}
}

0 new messages