Windows: Merged native handling of undecorated and fullscreen window property

This commit is contained in:
Elias Naur 2008-10-28 09:53:16 +00:00
parent d464876fe0
commit 41c90bc7cc
4 changed files with 14 additions and 28 deletions

View File

@ -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;

View File

@ -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);
}
return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false, NULL);
}

View File

@ -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);

View File

@ -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: