Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mapping for XQueryExtension #1265

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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