mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-03-19 19:54:40 +01:00
Fix native cursor global handle passing
This commit is contained in:
parent
fc2889cc27
commit
f0219aed1a
|
|
@ -401,7 +401,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
|
||||
public void setNativeCursor(Object handle) throws LWJGLException {
|
||||
if (native_mode) {
|
||||
MacOSXNativeMouse.setCursor(handle);
|
||||
MacOSXNativeMouse.setCursor(getCursorHandle(handle));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -457,11 +457,12 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
keyboard_queue.copyEvents(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Native cursor handles */
|
||||
public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
|
||||
if (native_mode) {
|
||||
return MacOSXNativeMouse.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
|
||||
long cursor = MacOSXNativeMouse.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
|
||||
return cursor;
|
||||
}
|
||||
else {
|
||||
return AWTUtil.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
|
||||
|
|
@ -471,6 +472,10 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
public void destroyCursor(Object cursor_handle) {
|
||||
|
||||
}
|
||||
|
||||
private static long getCursorHandle(Object cursor_handle) {
|
||||
return cursor_handle != null ? (Long)cursor_handle : 0;
|
||||
}
|
||||
|
||||
public int getPbufferCapabilities() {
|
||||
return Pbuffer.PBUFFER_SUPPORTED;
|
||||
|
|
|
|||
|
|
@ -89,17 +89,17 @@ final class MacOSXNativeMouse extends EventQueue {
|
|||
|
||||
private native void nUnregisterMouseListener(ByteBuffer window_handle);
|
||||
|
||||
private static native Object nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
|
||||
private static native long nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
|
||||
|
||||
private static native void nDestroyCursor(Object handle) throws LWJGLException;
|
||||
private static native void nDestroyCursor(long handle) throws LWJGLException;
|
||||
|
||||
private static native void nSetCursor(Object handle) throws LWJGLException;
|
||||
private static native void nSetCursor(long handle) throws LWJGLException;
|
||||
|
||||
public synchronized void register() {
|
||||
nRegisterMouseListener(window_handle);
|
||||
}
|
||||
|
||||
public static Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
|
||||
public static long createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
|
||||
try {
|
||||
return nCreateCursor(width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
|
||||
} catch (LWJGLException e) {
|
||||
|
|
@ -107,7 +107,7 @@ final class MacOSXNativeMouse extends EventQueue {
|
|||
}
|
||||
}
|
||||
|
||||
public static void destroyCursor(Object handle) throws LWJGLException {
|
||||
public static void destroyCursor(long handle) throws LWJGLException {
|
||||
try {
|
||||
nDestroyCursor(handle);
|
||||
} catch (LWJGLException e) {
|
||||
|
|
@ -115,7 +115,7 @@ final class MacOSXNativeMouse extends EventQueue {
|
|||
}
|
||||
}
|
||||
|
||||
public static void setCursor(Object handle) throws LWJGLException {
|
||||
public static void setCursor(long handle) throws LWJGLException {
|
||||
try {
|
||||
nSetCursor(handle);
|
||||
} catch (LWJGLException e) {
|
||||
|
|
|
|||
|
|
@ -100,13 +100,11 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nUnregisterMouseL
|
|||
window_info->jmouse = nil;
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nCreateCursor(JNIEnv *env, jobject _this, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) {
|
||||
NSLog(@"nCreateCursor");
|
||||
|
||||
char *bytes = (char *)(*env)->GetDirectBufferAddress(env, image_buffer);
|
||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nCreateCursor(JNIEnv *env, jobject _this, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) {
|
||||
jint *bytes = (jint *)(*env)->GetDirectBufferAddress(env, image_buffer);
|
||||
|
||||
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc]
|
||||
initWithBitmapDataPlanes:(char *)&bytes
|
||||
initWithBitmapDataPlanes:(jint *)&bytes
|
||||
pixelsWide:width pixelsHigh:height
|
||||
bitsPerSample:8
|
||||
samplesPerPixel:4
|
||||
|
|
@ -124,20 +122,14 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nCreateCursor(
|
|||
|
||||
NSCursor *cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(x_hotspot, y_hotspot)];
|
||||
|
||||
[cursor set]; // temporarily set the cursor here as returning the handle doesn't work yet
|
||||
|
||||
return cursor;
|
||||
return (jlong)cursor;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nDestroyCursor(JNIEnv *env, jobject _this, jobject handle) {
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nDestroyCursor(JNIEnv *env, jobject _this, jlong handle) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nSetCursor(JNIEnv *env, jobject _this, jobject handle) {
|
||||
NSLog(@"nSetCursor");
|
||||
|
||||
// TODO - this method should get the cursor from the handle and set it
|
||||
|
||||
//NSCursor *cursor = (NSCursor *)(*env)->GetDirectBufferAddress(env, handle);
|
||||
//[cursor set];
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXNativeMouse_nSetCursor(JNIEnv *env, jobject _this, jlong cursor_pointer) {
|
||||
NSCursor *cursor = (NSCursor *)cursor_pointer;
|
||||
[cursor set];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue