--- old/src/solaris/classes/sun/awt/X11/XlibWrapper.java 2009-08-11 19:21:23.000000000 +0400 +++ new/src/solaris/classes/sun/awt/X11/XlibWrapper.java 2009-08-11 19:21:23.000000000 +0400 @@ -599,8 +599,6 @@ } isBuildInternal = getBuildInternal(); - -// System.loadLibrary("mawt"); } static int getDataModel() { @@ -648,4 +646,39 @@ } static native void PrintXErrorEvent(long display, long event_ptr); + + /** + * The interface to be implemented by a predicate object used with the + * CheckIfEvent() method. + */ + public static interface CheckEventPredicate { + + /** + * Returns true if the event matches some criteria, false otherwise. + */ + boolean doesMatch(XEvent event); + } + + /** + * Invokes the XCheckIfEvent(). + * The returned event (if any) MUST BE disposed by the caller. + * + * @return the matched event or null if no match found. + */ + public static XEvent CheckIfEvent(long display, CheckEventPredicate predicate) { + XEvent ev = new XEvent(); + + if (CheckIfEvent(display, ev, ev.pData, predicate)) { + return ev; + } else { + ev.dispose(); + return null; + } + } + + /* + * NOTE: The passed event_return MUST be equal to the event.pData. + */ + private static native boolean CheckIfEvent(long display, XEvent event, + long event_return, CheckEventPredicate predicate); }