|
From: <ka...@us...> - 2012-11-01 22:39:29
|
Revision: 3808
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3808&view=rev
Author: kappa1
Date: 2012-11-01 22:39:22 +0000 (Thu, 01 Nov 2012)
Log Message:
-----------
Fix memory leaks by adding an NSAutoreleasePool when creating a windows and draining it on window destroy
Modified Paths:
--------------
branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m
Modified: branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m
===================================================================
--- branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m 2012-11-01 22:21:23 UTC (rev 3807)
+++ branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m 2012-11-01 22:39:22 UTC (rev 3808)
@@ -53,6 +53,8 @@
static NSOpenGLPixelFormat *default_format = nil;
+static NSAutoreleasePool *pool;
+
@implementation MacOSXKeyableWindow
- (BOOL)canBecomeKeyWindow;
{
@@ -390,21 +392,6 @@
[window_info->window setStyleMask:style_mask];
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nDestroyWindow(JNIEnv *env, jobject this, jobject window_handle) {
- MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
-
- if (window_info->window != nil) {
- [window_info->window close];
- }
- window_info->window = nil;
-
- if (window_info->view != nil) {
- [window_info->view release];
- }
- window_info->view = nil;
- //[window_info->window release];
-}
-
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nSetTitle(JNIEnv *env, jobject this, jobject window_handle, jobject title_buffer) {
MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
const char *title_cstr = (const char *)(*env)->GetDirectBufferAddress(env, title_buffer);
@@ -421,6 +408,8 @@
return NULL;
}
}
+
+ pool = [[NSAutoreleasePool alloc] init];
MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
@@ -467,6 +456,22 @@
return window_handle;
}
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nDestroyWindow(JNIEnv *env, jobject this, jobject window_handle) {
+ MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
+
+ if (window_info->window != nil) {
+ [window_info->window close];
+ }
+ window_info->window = nil;
+
+ if (window_info->view != nil) {
+ [window_info->view release];
+ }
+ window_info->view = nil;
+ //[window_info->window release];
+ [pool drain];
+}
+
JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion
(JNIEnv *env, jobject ignored) {
return org_lwjgl_MacOSXSysImplementation_JNI_VERSION;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2012-11-10 00:42:41
|
Revision: 3822
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3822&view=rev
Author: kappa1
Date: 2012-11-10 00:42:34 +0000 (Sat, 10 Nov 2012)
Log Message:
-----------
Switch to using the correct Cocoa method for Display.isCloseRequested()
Modified Paths:
--------------
branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m
Modified: branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m
===================================================================
--- branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m 2012-11-06 21:55:11 UTC (rev 3821)
+++ branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m 2012-11-10 00:42:34 UTC (rev 3822)
@@ -78,16 +78,14 @@
return default_format;
}
-- (void) windowWillClose:(NSNotification *)notification
-{
- MacOSXKeyableWindow *closingWindow = [notification object];
-
- if (_parent != nil && closingWindow == _parent->window) {
+- (BOOL)windowShouldClose:(id)sender {
+ if (_parent != nil) {
JNIEnv *env = attachCurrentThread();
jclass display_class = (*env)->GetObjectClass(env, _parent->jdisplay);
jmethodID close_callback = (*env)->GetMethodID(env, display_class, "doHandleQuit", "()V");
(*env)->CallVoidMethod(env, _parent->jdisplay, close_callback);
}
+ return NO;
}
- (id)initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat*)format
@@ -163,18 +161,10 @@
}
- (void)setParent:(MacOSXWindowInfo*)parent {
- // Un-register for native window close events if we have a parent window already
- if (_parent != nil) {
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:NSWindowWillCloseNotification
- object:_parent->window];
- }
_parent = parent;
- // Register for native window close events if we now have a parent window
+ // Set this NSView as delegate to get native window close events for windowShouldClose method
if (_parent != nil) {
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(windowWillClose:) name:NSWindowWillCloseNotification
- object:_parent->window];
+ [_parent->window setDelegate:self];
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2012-11-11 15:48:18
|
Revision: 3823
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3823&view=rev
Author: kappa1
Date: 2012-11-11 15:48:08 +0000 (Sun, 11 Nov 2012)
Log Message:
-----------
Run some Cocoa methods in nCreateWindow on the main thread (Thread-0) instead of the JNI thread.
Modified Paths:
--------------
branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m
Modified: branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m
===================================================================
--- branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m 2012-11-10 00:42:34 UTC (rev 3822)
+++ branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m 2012-11-11 15:48:08 UTC (rev 3823)
@@ -430,10 +430,14 @@
[window_info->view setParent:window_info];
[window_info->window setContentView:window_info->view];
- [window_info->window makeKeyAndOrderFront:[NSApplication sharedApplication]];
- [window_info->window makeFirstResponder:window_info->view];
- [window_info->window setReleasedWhenClosed:YES];
- [window_info->window setInitialFirstResponder:window_info->view];
+ //[window_info->window makeKeyAndOrderFront:[NSApplication sharedApplication]];
+ //[window_info->window makeFirstResponder:window_info->view];
+ //[window_info->window setReleasedWhenClosed:YES];
+ //[window_info->window setInitialFirstResponder:window_info->view];
+ [window_info->window performSelectorOnMainThread:@selector(makeKeyAndOrderFront:) withObject:[NSApplication sharedApplication] waitUntilDone:NO];
+ [window_info->window performSelectorOnMainThread:@selector(makeFirstResponder:) withObject:window_info->view waitUntilDone:NO];
+ [window_info->window performSelectorOnMainThread:@selector(setReleasedWhenClosed:) withObject:window_info->window waitUntilDone:NO];
+ [window_info->window performSelectorOnMainThread:@selector(setInitialFirstResponder:) withObject:window_info->view waitUntilDone:NO];
if (window_info->window_options != NSApplicationPresentationDefault) {
printf("Non-default\n"); fflush(stdout);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2012-11-14 21:06:16
|
Revision: 3827
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3827&view=rev
Author: kappa1
Date: 2012-11-14 21:06:09 +0000 (Wed, 14 Nov 2012)
Log Message:
-----------
Implement Mouse Dragging when using the Right Mouse Button or the Scroll Wheel Button
Modified Paths:
--------------
branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m
Modified: branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m
===================================================================
--- branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m 2012-11-13 21:13:11 UTC (rev 3826)
+++ branches/osx-java7/LWJGL/src/native/macosx/org_lwjgl_opengl_Display.m 2012-11-14 21:06:09 UTC (rev 3827)
@@ -294,6 +294,30 @@
(*env)->CallVoidMethod(env, _parent->jmouse, mousemove, loc.x, loc.y, [event deltaX], [event deltaY], 0.0f, time);
}
+- (void)rightMouseDragged:(NSEvent *)event {
+ JNIEnv *env = attachCurrentThread();
+ if (env == nil || event == nil || _parent == nil) {
+ return;
+ }
+ long time = [event timestamp] * 1000000000;
+ jclass mouse_class = (*env)->GetObjectClass(env, _parent->jmouse);
+ jmethodID mousemove = (*env)->GetMethodID(env, mouse_class, "mouseMoved", "(FFFFFJ)V");
+ NSPoint loc = [self convertPoint:[event locationInWindow] toView:self];
+ (*env)->CallVoidMethod(env, _parent->jmouse, mousemove, loc.x, loc.y, [event deltaX], [event deltaY], 0.0f, time);
+}
+
+- (void)otherMouseDragged:(NSEvent *)event {
+ JNIEnv *env = attachCurrentThread();
+ if (env == nil || event == nil || _parent == nil) {
+ return;
+ }
+ long time = [event timestamp] * 1000000000;
+ jclass mouse_class = (*env)->GetObjectClass(env, _parent->jmouse);
+ jmethodID mousemove = (*env)->GetMethodID(env, mouse_class, "mouseMoved", "(FFFFFJ)V");
+ NSPoint loc = [self convertPoint:[event locationInWindow] toView:self];
+ (*env)->CallVoidMethod(env, _parent->jmouse, mousemove, loc.x, loc.y, [event deltaX], [event deltaY], 0.0f, time);
+}
+
- (void)mouseMoved:(NSEvent *)event {
JNIEnv *env = attachCurrentThread();
if (env == nil || event == nil || _parent == nil || _parent->jmouse == nil) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|