mcintyrd@cs.rpi.edu (David McIntyre) (03/14/89)
I have a question about the toolkit and event handling.
I have a box widget, which I want to draw on using the Xlib
graphics primitives. I can do this, no problem.
Next, I want to catch exposure events on this widget so that
I can redraw the graphics if desired. I do this by
calling XtAddEventHandler on this widget, with an
ExposureMask.
I catch lots of expose events. This is good. However, as
soon as I actually draw on the box, I no longer get
ANY expose events for this widget. Adding the event
handler again does not help!
Synopsis: The event handler on my box widget won't catch
expose events after I have drawn on it.
I am using X11R3, Athena Tookit, Sun 3/60.
I would really appreciate any help that anyone can send me.
-Dave
PS. I think this is a better question that than last
stupid question I posted, eh?
Dave "mr question" McIntyre | "....say you're thinking about a plate
mcintyre@turing.cs.rpi.edu | of shrimp.....and someone says to
office : 518-276-8633 | you `plate,' or `shrimp'......"
home : 518-271-6664 |kit@ATHENA.MIT.EDU (Chris D. Peterson) (03/15/89)
> Synopsis: The event handler on my box widget won't catch > expose events after I have drawn on it. I cannot reproduce this one, the code provided here seems to do the right thing. It draws and X every time the window is exposed. Chris D. Peterson MIT X Consortium / Project Athena Net: kit@athena.mit.edu Phone: (617) 253 - 1326 USMail: MIT - Room E40-321 77 Massachusetts Ave. Cambridge, MA 02139 --- cut here --- /* * Test of drawing in a box on exposeure events. */ #include <stdio.h> #include <X11/Intrinsic.h> #include <X11/Box.h> #include <X11/StringDefs.h> static void ExposureProc(); GC gc; void main (argc, argv) int argc; char **argv; { Widget toplevel, box; Arg args[10]; Cardinal num_args = 0; XGCValues values; toplevel = XtInitialize(NULL, "Demo", NULL, (Cardinal) 0, &argc, argv); XtSetArg(args[num_args], XtNwidth, 100); num_args++; XtSetArg(args[num_args], XtNheight, 100); num_args++; XtSetArg(args[num_args], XtNbackground, XtScreen(toplevel)->white_pixel); num_args++; box = XtCreateManagedWidget("helloWorld", boxWidgetClass, toplevel, args, num_args); values.foreground = XtScreen(toplevel)->black_pixel; values.line_width = 5; gc = XtGetGC(box, GCForeground | GCLineWidth, &values); XtAddEventHandler(box, ExposureMask, FALSE, ExposureProc, NULL); XtRealizeWidget(toplevel); XtMainLoop(); } /* ARGSUSED */ static void ExposureProc(w, junk, event) Widget w; caddr_t junk; XEvent * event; { Window win = XtWindow(w); Display * disp = XtDisplay(w); XExposeEvent * expose = (XExposeEvent *) event; if (expose->count != 0) return; XDrawLine(disp, win, gc, 10, 10, 90, 90); XDrawLine(disp, win, gc, 10, 90, 90, 10); }