Skip to content

Commit 606e615

Browse files
lafoletcdbwiddis
authored andcommitted
Add mapping for XQueryExtension
1 parent 8f17bdd commit 606e615

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Features
1414
* [#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).
1515
* [#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).
1616
* [#1260](https://github.com/java-native-access/jna/pull/1260): Add mapping for X11 generic events - [@lafoletc](https://github.com/lafoletc).
17+
* [#1265](https://github.com/java-native-access/jna/pull/1265): Add mapping for XQueryExtension - [@lafoletc](https://github.com/lafoletc).
1718

1819
Bug Fixes
1920
---------

contrib/platform/src/com/sun/jna/platform/unix/X11.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,17 @@ class GC extends PointerType { }
285285
// TODO: define structure
286286
class XImage extends PointerType { }
287287

288+
/**
289+
* The XQueryExtension function determines if the named extension is present.
290+
* @param display Specifies the connection to the X server.
291+
* @param name Specifies the extension name.
292+
* @param major_opcode_return Returns the major opcode.
293+
* @param first_event_return Returns the first event code, if any.
294+
* @param first_error_return Returns the first error code, if any.
295+
* @return if present
296+
*/
297+
boolean XQueryExtension(Display display, String name, IntByReference major_opcode_return, IntByReference first_event_return, IntByReference first_error_return);
298+
288299
/** Definition (incomplete) of the Xext library. */
289300
interface Xext extends Library {
290301
Xext INSTANCE = Native.load("Xext", Xext.class);

contrib/platform/test/com/sun/jna/platform/unix/X11Test.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,24 @@ public void testXGetWMProtocols() {
116116
Assert.assertArrayEquals("Sent protocols were not equal to returned procols for XGetWMProtocols", sentAtoms, receivedAtoms);
117117
}
118118

119+
public void testXQueryExtension() {
120+
final IntByReference opcode = new IntByReference(0);
121+
final IntByReference first_event = new IntByReference(0);
122+
final IntByReference first_error = new IntByReference(0);
123+
124+
// check if the XTEST extension is available
125+
if (X11.INSTANCE.XQueryExtension(display, "XTEST", opcode, first_event, first_error)) {
126+
// Opcode for extension should be assigned in range 128-255
127+
Assert.assertTrue("Value for opcode should be between 128-255.", (opcode.getValue() & 0x80) > 0);
128+
// No first_event defined for XTEST
129+
Assert.assertEquals("Wrong value for first_event returned", 0, first_event.getValue());
130+
// No first_error defined for XTEST
131+
Assert.assertEquals("Wrong value for first_error returned", 0, first_error.getValue());
132+
} else {
133+
// XTEST extension is not supported by the X server
134+
}
135+
}
136+
119137
public void testStructureFieldOrder() {
120138
StructureFieldOrderInspector.batchCheckStructureGetFieldOrder(X11.class, null, true);
121139
}

0 commit comments

Comments
 (0)