[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

897.0. "Expose event question/problem" by AVIATE::SHAH (Yanks in '89) Wed Jun 07 1989 14:56

	I have a small program that uses expose events and prints out
	the coordinates of the exposed regions of a window.  With this
	program I found a small problem/bug(?).  It seems that exposed
	regions overlap, causing some regions to be drawn twice.  If
	using XOR to draw handles, the handles disappear.

	To reproduce this problem, first compile and link the program
	in the reply of this message.  The Fileview and Work In Progress
	windows are good to use.  Center the Work In Progress (WIP) 
	window in the FileView window.  Run the program that I provide.
	Two windows will be created.  Iconify one of the windows.  Then
	place the other window centered over the Fileview and WIP.  
	Iconify and deiconify the Fileview so that it is on top of the
	window.  Then iconify the window one more time.  A series of
	expose events will be generated and will be printed in the
	DECterm window from which this program was run.  The following is
	the setup of the numbers:
			(a by b at (c,d))
			a - width
			b - height
			(c,d) x and y location.
	This represents the regions that are supposedly exposed.  Some of
	regions overlap, so that exposed area will be redrawn twice.  

	I have a couple of questions.  Am I doing something wrong?  Is 
	this a bug?  etc?


	Thanks,
	-Pratish Shah

T.RTitleUserPersonal
Name
DateLines
897.1EXPOSE.CAVIATE::SHAHYanks in '89Wed Jun 07 1989 14:57148
/*
 * This example demonstrates problems with exposure event handling.  You can
 * specify two command line options: 'n', for no Xlib, which suppresses the
 * use of Xlib event handling routines to process the expose events, and
 * 'w', for window widget, which will create the work area as a window widget
 * rather than a dialog box widget.
 */

#include <decw$include:decwdwtwidgetprog.h>

void YesNoCancel();
void ExposureHandler();
void ButtonHandler();
void SetFlags();

static DwtCallback yesNoCancelCallback[] = {
   {YesNoCancel, NULL},
   {NULL, NULL}
};

static Widget top2;
static Display *display;

static int noXlib, useWindow;

main(argc, argv)
int argc;
char *argv[];
{
   Widget top1, wind1, wind2;
   Arg args[10];
   int i;


   if (argc > 1) SetFlags(argv[1]);
   if (argc > 2) SetFlags(argv[2]);

   top1 = XtInitialize("test1", "test", NULL, 0, &argc, argv);

   i = 0;
   XtSetArg(args[i], DwtNx, 200);                                    ++i;
   XtSetArg(args[i], DwtNy, 200);                                    ++i;
   XtSetValues(top1, args, i);

   i = 0;
   XtSetArg(args[i], DwtNwidth, 500);                                ++i;
   XtSetArg(args[i], DwtNheight, 400);                               ++i;

   if (useWindow) {
      wind1 = DwtWindowCreate(top1, "workarea", args, i);
   } else {
      wind1 = DwtDialogBoxCreate(top1, "workarea", args, i);
   }

   XtManageChild(wind1);
   XtAddEventHandler(wind1, ExposureMask, FALSE, ExposureHandler, NULL);

   display = XtDisplay(top1);

   i = 0;
   XtSetArg(args[i], DwtNx, 275);                                    ++i;
   XtSetArg(args[i], DwtNy, 250);                                    ++i;      
   top2 = XtAppCreateShell("test2", "test", applicationShellWidgetClass,
                           display, args, i);

   i = 0;
   XtSetArg(args[i], DwtNwidth, 500);                                ++i;
   XtSetArg(args[i], DwtNheight, 400);                               ++i;

   if (useWindow) {
      wind2 = DwtWindowCreate(top2, "workarea", args, i);
   } else {
      wind2 = DwtDialogBoxCreate(top2, "workarea", args, i);
   }

   XtManageChild(wind2);
   XtAddEventHandler(wind2, ExposureMask, FALSE, ExposureHandler, NULL);
   XtAddEventHandler(wind2, ButtonPressMask, FALSE, ButtonHandler, NULL);

   XtRealizeWidget(top1);

   XtRealizeWidget(top2);

   XtMainLoop();
}

void
ExposureHandler(windowWidget, data, event)
Widget windowWidget;
caddr_t data;
XExposeEvent *event;
{
   Window window = XtWindow(windowWidget);
   XEvent nextEvent;

   printf("------------------------\n");
   printf("(%d, %d), %d X %d, count = %d\n", event->x, event->y,
                                             event->width, event->height, 
                                             event->count);
   if (!noXlib) {
      XFlush(display);
      while (XCheckTypedWindowEvent(display, window, Expose, &nextEvent)) {
         printf("(%d, %d), %d X %d, count = %d\n", nextEvent.xexpose.x,
                                                   nextEvent.xexpose.y,
                                                   nextEvent.xexpose.width,
                                                   nextEvent.xexpose.height,
                                                   nextEvent.xexpose.count);
      }
   }
}

void
ButtonHandler(window, data, event)
Widget window;
caddr_t data;
XExposeEvent *event;
{
   Widget caution;
   DwtCompString label;

   label = DwtLatin1String("Save work before quitting?");
   caution = DwtCautionBox(top2, "yesnocancel",
                           TRUE, 0, 0, DwtModal,
                           label, NULL,
                           NULL, NULL,
                           DwtYesButton, yesNoCancelCallback, NULL);
   
   XtManageChild(caution);
   XtFree(label);
}

void
YesNoCancel(cautionBox, tag, data)
Widget cautionBox;
Opaque tag;
DwtAnyCallbackStruct *data;
{
   XtDestroyWidget(cautionBox);
}

void
SetFlags(opt)
char *opt;
{
   noXlib |= (*opt == 'n');
   useWindow |= (*opt == 'w');
}

897.2Question...STAR::BRANDENBERGSi vis pacem para bellumWed Jun 07 1989 15:125
    
    Why do you say the regions overlap?  Can you give a specific example?
    
    						monty

897.3Little difficult to explain but here goes nothingAVIATE::SHAHYanks in &#039;89Wed Jun 07 1989 16:1032

If I have three windows as shown below:


	____________________________________________________________
	|___________________________________________________________|
	|							    |
     _____________________________________________________________________
    |_____________________________________________________________________|
    |									  |
    |									  |
    |			______________________________			  |
    |			|_____________________________|			  |
    |			|			      |			  |
    |			|			      |			  |
    |			|			      |			  |
		.
		.
		.

The top window is my window.  The second window is the FileView Window and 
the third is the Work In Progress window.  If the FileView window is iconified,
both the Fileview and WIP window will be get iconified.  There will be a 
series of expose events generated for the regions exposed by the FileView
window and for the WIP window.  However I've noticed that the regions I get
back overlap.  If you run the progrm in note .1 and use the FileView and WIP
window as described, you should get the same result. 


-Pratish Shah

897.4Another expose event problem/bug?AVIATE::SHAHYanks in &#039;89Wed Jun 07 1989 16:2819
	I have another problem with expose events using the same program
	in note .1.

	When this program is run, two windows are created.  Press MB1 in
	window test2.  Then bring window test1 to the front by pressing
	on the title bar.  Then bring window test2 to the front.  Now
	press any one of the options in the dialog box.  The exposed region
	is much larger then the size of the box.  

	However if you just press the mouse button on window test2 and then
	pick any of the options in the dialog box, the reported exposed
	area is correct.

	Is this a bug or something?

	Thanks in advance,
	-Pratish Shah

897.5bugSTAR::BRANDENBERGSi vis pacem para bellumWed Jun 07 1989 16:327
    
    I tried it and it looks like a bug (though one that may be fixed in a
    future release).  Go ahead and QAR it and include the source to
    expose.c.  Thanks.
    
    						monty