[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
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 |
1030.0. "xsynchronize with event queue processing bug?" by CSC32::B_BRADACH () Wed Jun 28 1989 11:35
I have a customer who is having a problem with xsynchronize().
He is attempting to capture notify events, and examine the event queue
to see how many entries are currently in the queue.
The code example follows. Any and all comments would be appreciated.
thanks in advance
bernie
csc/cs
CUT HERE
=======================================================================
/*
* Environment:
*
* VAXStation II/GPX running VMS 5.1-1 SDC version. Program was compiled
* using VAX C version 2.4. The program must run on a color system.
*
* Problem: If XSynchronize is enabled, events get placed on the queue but
* XNextEvent fails to remove the entry from the queue.
*
*
* Method to reproduce:
*
* Run the program. Move the pointer into the window that this application
* creates. You will get enter and exit notify events. Once inside the window,
* click MB1 (left mouse button). This will issue a X call and show you the
* number of entries on the queue 2 times per second. Now, enter and leave the
* window and XNextEvent will fail to remove the entries from the queue.
* XQlength reports the correct queue length. If you comment out the call to
* XSynchronize, the program will operate properly.
*
* This failure makes it difficult to debug the X.11 interface because we
* can not switch it into synchronous mode.
*
*/
#include <stdio.h>
#include "decw$include:xlib.h"
#include "decw$include:xutil.h"
/*
* Constant data
*/
#define SQUARE_HEIGHT 10
#define SQUARE_WIDTH 10
#define NUMBER_ROWS 10
#define NUMBER_COLUMNS 10
#define NUMBER_SQUARES NUMBER_ROWS * NUMBER_COLUMNS
Display *display; /* connection to the X server */
Window window; /* application window */
GC gc; /* g context for drawing ops */
int indexes[NUMBER_SQUARES + 1];
int blink_interval[2] = {-5*1000*1000, -1};
cursor_blink()
{ int cnt;
drawSquares(display, window, gc, indexes);
cnt = XQLength(display);
printf("Blink with QLength = %d\r\n", cnt);
SYS$SETIMR(0, blink_interval, cursor_blink, 11, 0);
}
main()
{
int i; /* index variable */
Colormap colormap; /* application specific colormap */
XEvent event; /* incoming events */
XSetWindowAttributes attr; /* window attributes structure */
int numColors; /* number of colors used */
XColor colorDefs[NUMBER_SQUARES];
XColor queryColor;
/*
* Open the display
*/
if ((display = XOpenDisplay("")) == NULL)
fatalError("XOpenDisplay", "could not open display");
XSynchronize(display, 1);
/*
* Create a read/write colormap, with no entries allocated.
*/
colormap = XCreateColormap(display, RootWindow(display, 0),
DefaultVisual(display, 0), AllocNone);
/*
* Create a window of the same visual type as our colormap
*/
attr.event_mask = ExposureMask | ButtonPressMask |
EnterWindowMask | LeaveWindowMask;
attr.colormap = colormap;
window = XCreateWindow(display, RootWindow(display, 0), 0, 0,
NUMBER_COLUMNS * SQUARE_WIDTH,
NUMBER_ROWS * SQUARE_HEIGHT, 5,
DefaultDepth(display, 0), InputOutput,
DefaultVisual(display,0),
CWColormap | CWEventMask, &attr);
/*
* Map window
*/
XMapWindow(display, window);
XFlush(display);
/*
* Allocate enties in out colormap
*/
numColors = NUMBER_SQUARES;
if (XAllocColorCells(display, colormap, False, NULL, 0, indexes,
numColors + 1) == 0)
fatalError("XAllocColorCells", "Are we monochrome?");
/*
* Define entries in out colormap
*/
for (i = 0; i < numColors; i++) {
colorDefs[i].pixel = indexes[i];
colorDefs[i].flags = DoRed | DoGreen | DoBlue;
colorDefs[i].red = i * 0xffff / numColors;
colorDefs[i].green = i * 0xffff / numColors;
colorDefs[i].blue = i * 0xffff / numColors;
}
XStoreColors(display, colormap, colorDefs, numColors);
/*
* Create a GC for drawing operations
*/
gc = XCreateGC(display, window, 0, NULL);
/*
* Process events until a button is pressed
*/
while(1) {
XNextEvent(display, &event);
printf("Event to process\r\n");
switch(event.type) {
case Expose:
drawSquares(display, window, gc, indexes);
break;
case ButtonPress:
XInstallColormap(display, DefaultColormap(display, 0));
SYS$SETIMR(0, blink_interval, cursor_blink, 11, 0);
break;
case EnterNotify:
XInstallColormap(display, colormap);
break;
case LeaveNotify:
XInstallColormap(display, DefaultColormap(display, 0));
break;
default:
break;
}
}
}
/*
* Draw a big square of smaller color squares
*/
drawSquares(display, window, gc, indexes)
Display *display;
Window window;
GC gc;
int *indexes;
{
int row, column, square;
/*
* Draw filled squares in different foreground colors
*/
for (row = square = 0; row < NUMBER_ROWS; row++)
for (column = 0; column < NUMBER_COLUMNS; column++, square++) {
XSetForeground(display, gc, indexes[square]);
XFillRectangle(display, window, gc, SQUARE_WIDTH * column,
SQUARE_HEIGHT * row,
SQUARE_WIDTH, SQUARE_HEIGHT);
}
}
/*
* Something bad happened
*/
fatalError(string1, string2)
char *string1;
char *string2;
{
fprintf(stderr, "Fatal Error: %s in routine %s\n", string1, string2);
exit();
}
T.R | Title | User | Personal Name | Date | Lines |
---|
1030.1 | spr'd the problem | CSC32::B_BRADACH | | Thu Aug 10 1989 12:18 | 5 |
| problem has been spr'd.
bernie
|