Skip to content

Commit b2ca7db

Browse files
committed
BridJ: Drop all hopes for JAWT ptr on Mac
See http://forum.lwjgl.org/index.php?topic=4326.0
1 parent 6d12883 commit b2ca7db

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/main/java/org/bridj/jawt/JAWTUtils.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
* Contains a method that returns the native peer handle of an AWT component :
4747
* BridJ JAWT utilities
4848
* {@link org.bridj.jawt.JAWTUtils#getNativePeerHandle(java.awt.Component)}
49+
*
50+
* <p>Note that this does not work anymore on Mac OS X
51+
* (<a href="http://forum.lwjgl.org/index.php?topic=4326.0">see this thread</a>).
4952
*/
5053
public class JAWTUtils {
5154

@@ -102,7 +105,12 @@ public static void withLockedSurface(JNIEnv env, JAWT awt, Component component,
102105
pInfo = pInfo.as(JAWT_DrawingSurfaceInfo.class);
103106
}
104107
Pointer<?> platformInfo = pInfo.get().platformInfo();
105-
long peer = platformInfo.getSizeT(); // on win, mac, x11 platforms, the relevant field is the first in the struct !
108+
long peer;
109+
if (Platform.isMacOSX()) {
110+
peer = platformInfo.getPeer();
111+
} else {
112+
peer = platformInfo.getSizeT(); // on win, mac, x11 platforms, the relevant field is the first in the struct !
113+
}
106114
runnable.run(component, peer);
107115
} finally {
108116
surface.Unlock().get().invoke(pSurface);
@@ -131,4 +139,4 @@ public void run(Component component, long peer) {
131139
return 0;
132140
}
133141
}
134-
}
142+
}

src/main/java/org/bridj/jawt/JawtLibrary.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class JawtLibrary {
5858
try {
5959
//if (Platform.isLinux())
6060
// SystemBridJ.getNativeLibrary("headless/libmawt");
61+
// System.loadLibrary("jawt");
6162
} catch (Throwable th) {
6263
}
6364
BridJ.register();

src/test/java/org/bridj/JAWTTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public class JAWTTest {
4242

4343
@Test
4444
public void testWindowPeer() throws Exception {
45+
if (Platform.isMacOSX()) {
46+
// Oracle Java and jawt: it's complicated.
47+
// See http://forum.lwjgl.org/index.php?topic=4326.0
48+
return;
49+
}
4550
assertEquals(6 * Pointer.SIZE, BridJ.sizeOf(JAWT_DrawingSurface.class));
4651
assertEquals(4 * 4, BridJ.sizeOf(JAWT_Rectangle.class));
4752
//assertEquals(4 + 5 * Pointer.SIZE, BridJ.sizeOf(JAWT.class));
@@ -52,6 +57,7 @@ public void testWindowPeer() throws Exception {
5257
f.pack();
5358

5459
f.setVisible(true);
60+
Thread.sleep(500);
5561
long p = JAWTUtils.getNativePeerHandle(f);
5662
assertTrue(p != 0);
5763
f.setVisible(false);

0 commit comments

Comments
 (0)