Skip to content

Commit

Permalink
Add mapping for XQueryExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
lafoletc authored and dbwiddis committed Nov 7, 2020
1 parent 8f17bdd commit 606e615
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -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
---------
Expand Down
11 changes: 11 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/unix/X11.java
Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions contrib/platform/test/com/sun/jna/platform/unix/X11Test.java
Expand Up @@ -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);
}
Expand Down

0 comments on commit 606e615

Please sign in to comment.