Fixed resizing when using Display.setParent

This commit is contained in:
kappaOne 2012-12-03 23:04:30 +00:00
parent 415f25bf97
commit 804f09da47
2 changed files with 10 additions and 8 deletions

View File

@ -90,7 +90,7 @@ final class MacOSXDisplay implements DisplayImplementation {
}
private native ByteBuffer nCreateWindow(int x, int y, int width, int height, boolean fullscreen, boolean undecorated, boolean resizable, ByteBuffer peer_info_handle, ByteBuffer window_handle) throws LWJGLException;
private native ByteBuffer nCreateWindow(int x, int y, int width, int height, boolean fullscreen, boolean undecorated, boolean resizable, boolean parented, ByteBuffer peer_info_handle, ByteBuffer window_handle) throws LWJGLException;
private native boolean nIsMiniaturized(ByteBuffer window_handle);
@ -113,6 +113,7 @@ final class MacOSXDisplay implements DisplayImplementation {
public void createWindow(final DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
boolean fullscreen = Display.isFullscreen();
boolean resizable = Display.isResizable();
boolean parented = (parent != null);
close_requested = false;
@ -122,7 +123,7 @@ final class MacOSXDisplay implements DisplayImplementation {
try {
window = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(),
fullscreen, isUndecorated(), resizable,
peer_handle, window);
parented, peer_handle, window);
this.x = x;
this.y = y;
this.width = mode.getWidth();

View File

@ -158,10 +158,6 @@ static NSAutoreleasePool *pool;
- (void)setParent:(MacOSXWindowInfo*)parent {
_parent = parent;
// Set this NSView as delegate to get native window close events for windowShouldClose method
if (_parent != nil) {
[_parent->window setDelegate:self];
}
}
- (void)keyDown:(NSEvent *)event {
@ -407,7 +403,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nSetTitle(JNIEnv *env
[window_info->window setTitle:title];
}
JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIEnv *env, jobject this, jint x, jint y, jint width, jint height, jboolean fullscreen, jboolean undecorated, jboolean resizable, jobject peer_info_handle, jobject window_handle) {
JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIEnv *env, jobject this, jint x, jint y, jint width, jint height, jboolean fullscreen, jboolean undecorated, jboolean resizable, jboolean parented, jobject peer_info_handle, jobject window_handle) {
if (window_handle == NULL) {
window_handle = newJavaManagedByteBuffer(env, sizeof(MacOSXWindowInfo));
@ -457,6 +453,11 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIE
[window_info->window setContentView:window_info->view];
if (!parented) {
// set NSView as delegate of NSWindow to get windowShouldClose events
[window_info->window setDelegate:window_info->view];
}
// disable any fixed backbuffer size to allow resizing
CGLContextObj cgcontext = (CGLContextObj)[[window_info->view openGLContext] CGLContextObj];
CGLDisable(cgcontext, kCGLCESurfaceBackingSize);
@ -478,7 +479,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIE
[window_info->view setBoundsSize:newBounds];
}
// Inform the view of its parent window info; used to register for window-close callbacks
// Inform the view of its parent window info;
[window_info->view setParent:window_info];
[window_info->window performSelectorOnMainThread:@selector(makeFirstResponder:) withObject:window_info->view waitUntilDone:NO];