implement missing functionality for Display.getWidth() and Display.getHeight() not updating correctly on resize

This commit is contained in:
kappa1 2012-11-11 18:43:14 +00:00
parent f7012a3020
commit a749ad5c10
2 changed files with 19 additions and 3 deletions

View File

@ -121,6 +121,10 @@ final class MacOSXDisplay implements DisplayImplementation {
private native void nResizeWindow(ByteBuffer window_handle, int x, int y, int width, int height);
private native boolean nWasResized(ByteBuffer window_handle);
private native int nGetWidth(ByteBuffer window_handle);
private native int nGetHeight(ByteBuffer window_handle);
private static boolean isUndecorated() {
return Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated");
@ -561,11 +565,11 @@ final class MacOSXDisplay implements DisplayImplementation {
}
public int getWidth() {
return width;
return nGetWidth(window);
}
public int getHeight() {
return height;
return nGetHeight(window);
}
public boolean isInsideWindow() {

View File

@ -370,6 +370,18 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nWasResized(JNIEn
return was_resized;
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetWidth(JNIEnv *env, jobject this, jobject window_handle) {
MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
jint width = window_info->display_rect.size.width;
return width;
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGetHeight(JNIEnv *env, jobject this, jobject window_handle) {
MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
jint height = window_info->display_rect.size.height;
return height;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nSetResizable(JNIEnv *env, jobject this, jobject window_handle, jboolean resizable) {
MacOSXWindowInfo *window_info = (MacOSXWindowInfo *)(*env)->GetDirectBufferAddress(env, window_handle);
NSUInteger style_mask = [window_info->window styleMask];