From 41c90bc7cc120b732c38813f617e8da34955fc0f Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Tue, 28 Oct 2008 09:53:16 +0000 Subject: [PATCH] Windows: Merged native handling of undecorated and fullscreen window property --- src/java/org/lwjgl/opengl/WindowsDisplay.java | 8 +++---- src/native/windows/context.c | 24 +++++-------------- src/native/windows/context.h | 4 ++-- src/native/windows/org_lwjgl_opengl_Display.c | 6 ++--- 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/java/org/lwjgl/opengl/WindowsDisplay.java b/src/java/org/lwjgl/opengl/WindowsDisplay.java index d99885fd..7602130a 100644 --- a/src/java/org/lwjgl/opengl/WindowsDisplay.java +++ b/src/java/org/lwjgl/opengl/WindowsDisplay.java @@ -163,8 +163,7 @@ final class WindowsDisplay implements DisplayImplementation { did_maximize = false; this.parent = parent; long parent_hwnd = parent != null ? getHwnd(parent) : 0; - boolean isUndecorated = isUndecorated(); - this.hwnd = nCreateWindow(fullscreen, x, y, mode.getWidth(), mode.getHeight(), isUndecorated, parent != null, parent_hwnd); + this.hwnd = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(), fullscreen || isUndecorated(), parent != null, parent_hwnd); if (hwnd == 0) { throw new LWJGLException("Failed to create window"); } @@ -188,7 +187,7 @@ final class WindowsDisplay implements DisplayImplementation { throw e; } } - private native long nCreateWindow(boolean fullscreen, int x, int y, int width, int height, boolean undecorated, boolean child_window, long parent_hwnd) throws LWJGLException; + private static native long nCreateWindow(int x, int y, int width, int height, boolean undecorated, boolean child_window, long parent_hwnd) throws LWJGLException; private static boolean isUndecorated() { return Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated"); @@ -421,8 +420,7 @@ final class WindowsDisplay implements DisplayImplementation { private static native void nUpdate(); public void reshape(int x, int y, int width, int height) { - if (!isFullscreen) - nReshape(getHwnd(), x, y, width, height, isUndecorated(), parent != null); + nReshape(getHwnd(), x, y, width, height, isFullscreen || isUndecorated(), parent != null); } private static native void nReshape(long hwnd, int x, int y, int width, int height, boolean undecorated, boolean child); public native DisplayMode[] getAvailableDisplayModes() throws LWJGLException; diff --git a/src/native/windows/context.c b/src/native/windows/context.c index 807f2fe1..9665e632 100644 --- a/src/native/windows/context.c +++ b/src/native/windows/context.c @@ -112,12 +112,9 @@ void closeWindow(HWND *hwnd, HDC *hdc) } } -void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool fullscreen, bool undecorated, bool child_window) { +void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool undecorated, bool child_window) { DWORD exstyle, windowflags; - if (fullscreen) { - exstyle = WS_EX_APPWINDOW; - windowflags = WS_POPUP; - } else if (undecorated) { + if (undecorated) { exstyle = WS_EX_APPWINDOW; windowflags = WS_POPUP; } else if (child_window) { @@ -132,23 +129,14 @@ void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool fulls *exstyle_return = exstyle; } -/* - * Create a window with the specified title, position, size, and - * fullscreen attribute. The window will have DirectInput associated - * with it. - * - * Returns true for success, or false for failure - */ -HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated, bool child_window, HWND parent) +HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool undecorated, bool child_window, HWND parent) { RECT clientSize; DWORD exstyle, windowflags; HWND new_hwnd; - getWindowFlags(&windowflags, &exstyle, fullscreen, undecorated, child_window); + getWindowFlags(&windowflags, &exstyle, undecorated, child_window); - // If we're not a fullscreen window, adjust the height to account for the - // height of the title bar (unless undecorated) clientSize.bottom = height; clientSize.left = 0; clientSize.right = width; @@ -497,5 +485,5 @@ static bool registerDummyWindow() { HWND createDummyWindow(int origin_x, int origin_y) { if (!registerDummyWindow()) return NULL; - return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false, false, NULL); -} \ No newline at end of file + return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false, NULL); +} diff --git a/src/native/windows/context.h b/src/native/windows/context.h index 5e8167f5..75baa396 100644 --- a/src/native/windows/context.h +++ b/src/native/windows/context.h @@ -80,7 +80,7 @@ extern HWND createDummyWindow(int x, int y); /** * Return appropriate window and extended style flags from the given fullscreen and undecorated property */ -extern void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool fullscreen, bool undecorated, bool child_window); +extern void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool undecorated, bool child_window); /* * Create a window with the specified position, size, and @@ -89,7 +89,7 @@ extern void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, boo * * Returns true for success, or false for failure */ -extern HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated, bool child_window, HWND parent); +extern HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool undecorated, bool child_window, HWND parent); extern int findPixelFormatOnDC(JNIEnv *env, HDC hdc, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer); diff --git a/src/native/windows/org_lwjgl_opengl_Display.c b/src/native/windows/org_lwjgl_opengl_Display.c index 7e9a0797..9d6ed463 100644 --- a/src/native/windows/org_lwjgl_opengl_Display.c +++ b/src/native/windows/org_lwjgl_opengl_Display.c @@ -151,7 +151,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion return org_lwjgl_WindowsSysImplementation_JNI_VERSION; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jobject self, jboolean fullscreen, jint x, jint y, jint width, jint height, jboolean undecorated, jboolean child_window, jlong parent_hwnd) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jclass unused, jint x, jint y, jint width, jint height, jboolean undecorated, jboolean child_window, jlong parent_hwnd) { HWND hwnd; static bool oneShotInitialised = false; if (!oneShotInitialised) { @@ -162,7 +162,7 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEn oneShotInitialised = true; } - hwnd = createWindow(WINDOWCLASSNAME, x, y, width, height, fullscreen, undecorated, child_window, (HWND)parent_hwnd); + hwnd = createWindow(WINDOWCLASSNAME, x, y, width, height, undecorated, child_window, (HWND)parent_hwnd); return (INT_PTR)hwnd; } @@ -299,7 +299,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReshape(JNIEnv *env DWORD exstyle, windowflags; RECT clientSize; - getWindowFlags(&windowflags, &exstyle, false, undecorated, child); + getWindowFlags(&windowflags, &exstyle, undecorated, child); // If we're not a fullscreen window, adjust the height to account for the // height of the title bar: