From de712f85676ca0a386c956165bb6460d65206c46 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 16 May 2002 22:48:44 +0000 Subject: [PATCH] XDisplay's nextEvent completed --- src/XDisplay.cc | 22 ++++++++++++++++++++++ src/XDisplay.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/XDisplay.cc b/src/XDisplay.cc index 1dfd55d0..822f244a 100644 --- a/src/XDisplay.cc +++ b/src/XDisplay.cc @@ -131,3 +131,25 @@ void XDisplay::ungrab() { if (--_grabs == 0) XUngrabServer(_display); } + + +/* + * Gets the next event on the queue from the X server. + * + * Returns: true if e contains a new event; false if there is no event to be + * returned. + */ +bool XDisplay::nextEvent(XEvent &e) { + if(!XPending(_display)) + return false; + XNextEvent(_display, &e); + if (_last_bad_window != None) { + if (e.xany.window == _last_bad_window) { + cerr << "XDisplay::nextEvent(): Removing event for bad window from " << + "event queue\n"; + return false; + } else + _last_bad_window = None; + } + return true; +} diff --git a/src/XDisplay.h b/src/XDisplay.h index a506eee9..b736fd42 100644 --- a/src/XDisplay.h +++ b/src/XDisplay.h @@ -77,6 +77,8 @@ public: void grab(); void ungrab(); + + bool nextEvent(XEvent &e); }; #endif // _XDisplay_h -- 2.45.2