diff --git a/CHANGES.md b/CHANGES.md index 78b815c958..fd67774ada 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,7 @@ Features * [#1239](https://github.com/java-native-access/jna/pull/1239): Improve performance of allocation of `c.s.j.Memory` objects - [@joerg1985](https://github.com/joerg1985). * [#1246](https://github.com/java-native-access/jna/pull/1246): Improve performance of `c.s.j.Structure#read` and `c.s.j.Structure#write` - [@joerg1985](https://github.com/joerg1985). * [#1260](https://github.com/java-native-access/jna/pull/1260): Add mapping for X11 generic events - [@lafoletc](https://github.com/lafoletc). +* [#1265](https://github.com/java-native-access/jna/pull/1265): Add mapping for XQueryExtension - [@lafoletc](https://github.com/lafoletc). Bug Fixes --------- diff --git a/contrib/platform/src/com/sun/jna/platform/unix/X11.java b/contrib/platform/src/com/sun/jna/platform/unix/X11.java index 1fbd6b578a..e48e6c2af2 100644 --- a/contrib/platform/src/com/sun/jna/platform/unix/X11.java +++ b/contrib/platform/src/com/sun/jna/platform/unix/X11.java @@ -285,6 +285,17 @@ class GC extends PointerType { } // TODO: define structure class XImage extends PointerType { } + /** + * The XQueryExtension function determines if the named extension is present. + * @param display Specifies the connection to the X server. + * @param name Specifies the extension name. + * @param major_opcode_return Returns the major opcode. + * @param first_event_return Returns the first event code, if any. + * @param first_error_return Returns the first error code, if any. + * @return if present + */ + boolean XQueryExtension(Display display, String name, IntByReference major_opcode_return, IntByReference first_event_return, IntByReference first_error_return); + /** Definition (incomplete) of the Xext library. */ interface Xext extends Library { Xext INSTANCE = Native.load("Xext", Xext.class); diff --git a/contrib/platform/test/com/sun/jna/platform/unix/X11Test.java b/contrib/platform/test/com/sun/jna/platform/unix/X11Test.java index 7a728db6c9..49c03202e8 100644 --- a/contrib/platform/test/com/sun/jna/platform/unix/X11Test.java +++ b/contrib/platform/test/com/sun/jna/platform/unix/X11Test.java @@ -116,6 +116,24 @@ public void testXGetWMProtocols() { Assert.assertArrayEquals("Sent protocols were not equal to returned procols for XGetWMProtocols", sentAtoms, receivedAtoms); } + public void testXQueryExtension() { + final IntByReference opcode = new IntByReference(0); + final IntByReference first_event = new IntByReference(0); + final IntByReference first_error = new IntByReference(0); + + // check if the XTEST extension is available + if (X11.INSTANCE.XQueryExtension(display, "XTEST", opcode, first_event, first_error)) { + // Opcode for extension should be assigned in range 128-255 + Assert.assertTrue("Value for opcode should be between 128-255.", (opcode.getValue() & 0x80) > 0); + // No first_event defined for XTEST + Assert.assertEquals("Wrong value for first_event returned", 0, first_event.getValue()); + // No first_error defined for XTEST + Assert.assertEquals("Wrong value for first_error returned", 0, first_error.getValue()); + } else { + // XTEST extension is not supported by the X server + } + } + public void testStructureFieldOrder() { StructureFieldOrderInspector.batchCheckStructureGetFieldOrder(X11.class, null, true); }