surles@robinett.cs.unc.edu (Mark Surles) (06/13/90)
I'm writing a program which uses a library of existing code, and I'm having trouble with the event queue. My program needs to look at the events on the queue to determine which code (mine or the library's) should get each event. I initally did a qread() to look at the event, and then if my code didn't need it I did a qenter() to put it back for the library. This does NOT work, because qenter() puts the event at the END of the queue - the order of events gets messed up. For most event types I can just do a qtest() to get the event type - I can keep track of the current window to determine what window the event is for. For Window Manager events, however, I need to look at the value field of the event as well as the event type (which window needs a Redraw, etc.). Is there any way to get both the event type and the value without dequeueing the event? Or, can I read the event and then somehow put it back at the FRONT of the queue? Has anyone dealt with this? Is there a solution? Thanks, Mark Surles surles@cs.unc.edu
andru@sgi.com (Andrew Myers) (06/14/90)
In article <14653@thorin.cs.unc.edu> surles@robinett.cs.unc.edu (Mark Surles) writes: >Is there any way to get both the event type and the value >without dequeueing the event? Or, can I read the event and then >somehow put it back at the FRONT of the queue? >Mark Surles >surles@cs.unc.edu You could implement a wrapper around qtest/qread, whose implementation would depend on how deep a pushback you needed. If you only need one level, something like this should suffice: #include "gl.h" #include "assert.h" long q_dev; short q_data; int q_hasdata; long my_qtest() { if (q_hasdata) return q_dev; else return qtest(); } long my_qread(short *data) { if (q_hasdata) { *data = q_data; return q_dev; } else { return qread(data); } } void my_qunread(long dev, short data) { assert(!q_hasdata); /* one level pushback requirement */ assert(dev != 0); /* dev==0 wouldn't make sense */ q_dev = dev; q_data = data; } ----- Andrew