Implement Mouse.isInsideWindow() on OS X
This commit is contained in:
parent
f0219aed1a
commit
6c090f1f61
|
@ -83,6 +83,8 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
private boolean skipViewportValue = false;
|
||||
private static final IntBuffer current_viewport = BufferUtils.createIntBuffer(16);
|
||||
|
||||
private boolean mouseInsideWindow;
|
||||
|
||||
private boolean close_requested;
|
||||
|
||||
private boolean native_mode = true;
|
||||
|
@ -165,6 +167,18 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
close_requested = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseInsideWindow() {
|
||||
synchronized (this) {
|
||||
mouseInsideWindow = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseOutsideWindow() {
|
||||
synchronized (this) {
|
||||
mouseInsideWindow = false;
|
||||
}
|
||||
}
|
||||
|
||||
public native void nDestroyCALayer(ByteBuffer peer_info_handle);
|
||||
|
||||
|
@ -564,7 +578,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
public boolean isInsideWindow() {
|
||||
return true;
|
||||
return mouseInsideWindow;
|
||||
}
|
||||
|
||||
public void setResizable(boolean resizable) {
|
||||
|
|
|
@ -91,9 +91,9 @@ final class MacOSXNativeMouse extends EventQueue {
|
|||
|
||||
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(long handle) throws LWJGLException;
|
||||
private static native void nDestroyCursor(long cursor_handle) throws LWJGLException;
|
||||
|
||||
private static native void nSetCursor(long handle) throws LWJGLException;
|
||||
private static native void nSetCursor(long cursor_handle) throws LWJGLException;
|
||||
|
||||
public synchronized void register() {
|
||||
nRegisterMouseListener(window_handle);
|
||||
|
@ -107,17 +107,17 @@ final class MacOSXNativeMouse extends EventQueue {
|
|||
}
|
||||
}
|
||||
|
||||
public static void destroyCursor(long handle) throws LWJGLException {
|
||||
public static void destroyCursor(long cursor_handle) throws LWJGLException {
|
||||
try {
|
||||
nDestroyCursor(handle);
|
||||
nDestroyCursor(cursor_handle);
|
||||
} catch (LWJGLException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setCursor(long handle) throws LWJGLException {
|
||||
public static void setCursor(long cursor_handle) throws LWJGLException {
|
||||
try {
|
||||
nSetCursor(handle);
|
||||
nSetCursor(cursor_handle);
|
||||
} catch (LWJGLException e) {
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -336,7 +336,7 @@ static NSAutoreleasePool *pool;
|
|||
[_trackingArea release];
|
||||
}
|
||||
|
||||
int options = (NSTrackingMouseEnteredAndExited | NSTrackingCursorUpdate | NSTrackingActiveAlways);
|
||||
int options = (NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways);
|
||||
_trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
|
||||
options:options
|
||||
owner:self
|
||||
|
@ -345,18 +345,25 @@ static NSAutoreleasePool *pool;
|
|||
}
|
||||
|
||||
-(void)mouseEntered:(NSEvent *)event {
|
||||
// TODO
|
||||
NSLog(@"MOUSE ENTERED");
|
||||
JNIEnv *env = attachCurrentThread();
|
||||
if (env == nil || event == nil || _parent == nil || _parent->jdisplay == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
jclass display_class = (*env)->GetObjectClass(env, _parent->jdisplay);
|
||||
jmethodID mouseInsideWindow_callback = (*env)->GetMethodID(env, display_class, "mouseInsideWindow", "()V");
|
||||
(*env)->CallVoidMethod(env, _parent->jdisplay, mouseInsideWindow_callback);
|
||||
}
|
||||
|
||||
-(void)mouseExited:(NSEvent *)event {
|
||||
// TODO
|
||||
NSLog(@"MOUSE EXITED");
|
||||
}
|
||||
|
||||
-(void)cursorUpdate:(NSEvent *)event {
|
||||
// TODO
|
||||
NSLog(@"CURSOR UPDATE");
|
||||
JNIEnv *env = attachCurrentThread();
|
||||
if (env == nil || event == nil || _parent == nil || _parent->jdisplay == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
jclass display_class = (*env)->GetObjectClass(env, _parent->jdisplay);
|
||||
jmethodID mouseOutsideWindow_callback = (*env)->GetMethodID(env, display_class, "mouseOutsideWindow", "()V");
|
||||
(*env)->CallVoidMethod(env, _parent->jdisplay, mouseOutsideWindow_callback);
|
||||
}
|
||||
|
||||
- (void) drawRect:(NSRect)rect {
|
||||
|
@ -473,6 +480,10 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIE
|
|||
window_info->window = [peer_info->parent window];
|
||||
[peer_info->parent addSubview:window_info->view];
|
||||
[window_info->view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||
|
||||
if (window_info->jdisplay == NULL) {
|
||||
window_info->jdisplay = (*env)->NewGlobalRef(env, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue