public bool Dequeue(out XEvent xevent) { StartOver: bool got_xevent = false; lock (lockobj) { if (xqueue.Count > 0) { got_xevent = true; xevent = xqueue.Dequeue(); } else { xevent = new XEvent(); /* not strictly needed, but mcs complains */ } } if (got_xevent) { if (xevent.AnyEvent.type == XEventName.Expose) { #if spew Console.Write("E"); Console.Out.Flush(); #endif X11Hwnd hwnd = (X11Hwnd)Hwnd.GetObjectFromWindow(xevent.AnyEvent.window); hwnd.AddExpose(xevent.AnyEvent.window == hwnd.ClientWindow, xevent.ExposeEvent.x, xevent.ExposeEvent.y, xevent.ExposeEvent.width, xevent.ExposeEvent.height); goto StartOver; } else if (xevent.AnyEvent.type == XEventName.ConfigureNotify) { #if spew Console.Write("C"); Console.Out.Flush(); #endif X11Hwnd hwnd = (X11Hwnd)Hwnd.GetObjectFromWindow(xevent.AnyEvent.window); hwnd.AddConfigureNotify(xevent); goto StartOver; } else { #if spew Console.Write("X"); Console.Out.Flush(); #endif /* it was an event we can deal with directly, return it */ return(true); } } else { if (paint_queue.Count > 0) { xevent = paint_queue.Dequeue(); #if spew Console.Write("e"); Console.Out.Flush(); #endif return(true); } else if (configure_queue.Count > 0) { xevent = configure_queue.Dequeue(); #if spew Console.Write("c"); Console.Out.Flush(); #endif return(true); } } if (dispatch_idle && need_dispatch_idle) { OnIdle(EventArgs.Empty); need_dispatch_idle = false; } lock (lockobj) { if (CountUnlocked > 0) { goto StartOver; } if (Monitor.Wait(lockobj, NextTimeout(), true)) { // the lock was reaquired before the // timeout. meaning an event was // enqueued by X11Display.XEventThread. goto StartOver; } else { CheckTimers(); return(false); } } }