aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/Window.java94
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/windows/WindowsWindow.java136
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/egl/EGLContext.java15
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/egl/EGLDrawable.java2
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java24
-rw-r--r--src/classes/javax/media/opengl/GLDrawableFactory.java2
-rwxr-xr-xsrc/native/jogl/WindowsWindow.c299
7 files changed, 554 insertions, 18 deletions
diff --git a/src/classes/com/sun/javafx/newt/Window.java b/src/classes/com/sun/javafx/newt/Window.java
new file mode 100755
index 000000000..c9437a196
--- /dev/null
+++ b/src/classes/com/sun/javafx/newt/Window.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt;
+
+public abstract class Window {
+ /** OpenKODE window type */
+ public static final String KD = "KD";
+
+ /** Microsoft Windows window type */
+ public static final String WINDOWS = "Windows";
+
+ /** X11 window type */
+ public static final String X11 = "X11";
+
+ /** Mac OS X window type */
+ public static final String MACOSX = "MacOSX";
+
+ /** Creates a Window of the default type for the current operating system. */
+ public static Window create() {
+ String osName = System.getProperty("os.name");
+ String osNameLowerCase = osName.toLowerCase();
+ String windowType;
+ if (osNameLowerCase.startsWith("wind")) {
+ windowType = WINDOWS;
+ } else if (osNameLowerCase.startsWith("mac os x")) {
+ windowType = MACOSX;
+ } else {
+ windowType = X11;
+ }
+ return create(windowType);
+ }
+
+
+ public static Window create(String type) {
+ try {
+ Class windowClass = null;
+ if (KD.equals(type)) {
+ windowClass = Class.forName("com.sun.javafx.newt.kd.KDWindow");
+ } else if (WINDOWS.equals(type)) {
+ windowClass = Class.forName("com.sun.javafx.newt.windows.WindowsWindow");
+ } else if (X11.equals(type)) {
+ windowClass = Class.forName("com.sun.javafx.newt.x11.X11Window");
+ } else if (MACOSX.equals(type)) {
+ windowClass = Class.forName("com.sun.javafx.newt.macosx.MacOSXWindow");
+ } else {
+ throw new RuntimeException("Unknown window type \"" + type + "\"");
+ }
+ return (Window) windowClass.newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected Window() {
+ }
+
+ public abstract void setSize(int width, int height);
+ public abstract int getWidth();
+ public abstract int getHeight();
+ public abstract boolean setFullscreen(boolean fullscreen);
+ public abstract long getWindowHandle();
+ public abstract void pumpMessages();
+}
diff --git a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java
new file mode 100755
index 000000000..dfe423096
--- /dev/null
+++ b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt.windows;
+
+import com.sun.javafx.newt.*;
+import com.sun.opengl.impl.*;
+
+public class WindowsWindow extends Window {
+ private long window;
+ private static final String WINDOW_CLASS_NAME = "NewtWindow";
+ // Default width and height -- will likely be re-set immediately by user
+ private int width = 100;
+ private int height = 100;
+
+ static {
+ NativeLibLoader.loadCore();
+
+ if (!initIDs()) {
+ throw new RuntimeException("Failed to initialize jmethodIDs");
+ }
+ }
+
+ public WindowsWindow() {
+ long wndClass = getWindowClass();
+ window = CreateWindow(WINDOW_CLASS_NAME, getHInstance(), width, height);
+ if (window == 0) {
+ throw new RuntimeException("Error creating window");
+ }
+ }
+
+ public void setSize(int width, int height) {
+ setSize0(window, width, height);
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ return setFullScreen0(window, fullscreen);
+ }
+
+ public long getWindowHandle() {
+ return window;
+ }
+
+ public void pumpMessages() {
+ DispatchMessages(window);
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ private static long windowClass;
+ private static synchronized long getWindowClass() {
+ if (windowClass == 0) {
+ windowClass = RegisterWindowClass(WINDOW_CLASS_NAME, getHInstance());
+ if (windowClass == 0) {
+ throw new RuntimeException("Error while registering window class");
+ }
+ }
+ return windowClass;
+ }
+ private static long hInstance;
+ private static synchronized long getHInstance() {
+ if (hInstance == 0) {
+ // FIXME: will require modification once this is moved into its own DLL ("newt")
+ hInstance = LoadLibraryW("jogl");
+ if (hInstance == 0) {
+ throw new RuntimeException("Error finding HINSTANCE for \"jogl\"");
+ }
+ }
+ return hInstance;
+ }
+
+ private static native boolean initIDs();
+ private static native long LoadLibraryW(String libraryName);
+ private static native long RegisterWindowClass(String windowClassName, long hInstance);
+ private native long CreateWindow(String windowClassName, long hInstance, int width, int height);
+ private static native void DispatchMessages(long window);
+ private native void setSize0(long window, int width, int height);
+ private native boolean setFullScreen0(long window, boolean fullscreen);
+
+ private void keyDown(long key) {
+ }
+
+ private void keyUp(long key) {
+ }
+
+ private void sizeChanged(int newWidth, int newHeight) {
+ width = newWidth;
+ height = newHeight;
+ }
+
+ private void windowClosed() {
+ }
+
+ private void windowDestroyed() {
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/egl/EGLContext.java b/src/classes/com/sun/opengl/impl/egl/EGLContext.java
index f55b611ca..25ac2c726 100755
--- a/src/classes/com/sun/opengl/impl/egl/EGLContext.java
+++ b/src/classes/com/sun/opengl/impl/egl/EGLContext.java
@@ -123,11 +123,16 @@ public class EGLContext extends GLContextImpl {
}
EGLDrawableFactory factory = (EGLDrawableFactory) GLDrawableFactory.getFactory();
- int clientVersion = (EGLDrawableFactory.PROFILE_GLES2.equals(factory.getProfile()) ? 2 : 1);
- int[] contextAttrs = new int[] {
- EGL.EGL_CONTEXT_CLIENT_VERSION, clientVersion,
- EGL.EGL_NONE
- };
+ boolean isGLES2 = EGLDrawableFactory.PROFILE_GLES2.equals(factory.getProfile());
+ int[] contextAttrs = null;
+ // FIXME: need to determine whether to specify the context
+ // attributes based on the EGL version
+ if (isGLES2) {
+ contextAttrs = new int[] {
+ EGL.EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL.EGL_NONE
+ };
+ }
context = EGL.eglCreateContext(display, config, shareWith, contextAttrs, 0);
if (context == 0) {
throw new GLException("Error creating OpenGL context");
diff --git a/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java
index c9cc19913..49dea75ce 100755
--- a/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java
+++ b/src/classes/com/sun/opengl/impl/egl/EGLDrawable.java
@@ -92,7 +92,7 @@ public class EGLDrawable implements GLDrawable {
if (realized) {
// Create the window surface
surface = EGL.eglCreateWindowSurface(display, config, nativeWindow, null);
- if (surface == 0) {
+ if (surface == EGL.EGL_NO_SURFACE) {
throw new GLException("Creation of window surface (eglCreateWindowSurface) failed");
}
}
diff --git a/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
index bbef9a54f..be594ce46 100755
--- a/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
@@ -190,18 +190,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
public int[] glCapabilities2AttribList(GLCapabilities caps) {
- int renderBit;
-
- if (PROFILE_GLES1.equals(getProfile())) {
- renderBit = EGL.EGL_OPENGL_ES_BIT;
- } else if (PROFILE_GLES2.equals(getProfile())) {
- renderBit = EGL.EGL_OPENGL_ES2_BIT;
- } else {
- throw new GLException("Unknown profile \"" + getProfile() + "\" (expected OpenGL ES 1 or OpenGL ES 2)");
- }
-
- return new int[] {
- EGL.EGL_RENDERABLE_TYPE, renderBit,
+ int[] attrs = new int[] {
EGL.EGL_DEPTH_SIZE, caps.getDepthBits(),
// FIXME: does this need to be configurable?
EGL.EGL_SURFACE_TYPE, EGL.EGL_WINDOW_BIT,
@@ -210,8 +199,19 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
EGL.EGL_BLUE_SIZE, caps.getBlueBits(),
EGL.EGL_ALPHA_SIZE, caps.getAlphaBits(),
EGL.EGL_STENCIL_SIZE, (caps.getStencilBits() > 0 ? caps.getStencilBits() : EGL.EGL_DONT_CARE),
+ EGL.EGL_NONE, EGL.EGL_NONE,
EGL.EGL_NONE
};
+
+ // FIXME: we need to query the EGL version to determine
+ // whether we are allowed to specify the renderable type
+
+ if (PROFILE_GLES2.equals(getProfile())) {
+ attrs[attrs.length - 3] = EGL.EGL_RENDERABLE_TYPE;
+ attrs[attrs.length - 2] = EGL.EGL_OPENGL_ES2_BIT;
+ }
+
+ return attrs;
}
/*
diff --git a/src/classes/javax/media/opengl/GLDrawableFactory.java b/src/classes/javax/media/opengl/GLDrawableFactory.java
index 42727fc48..45b3e0dc4 100644
--- a/src/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/classes/javax/media/opengl/GLDrawableFactory.java
@@ -104,7 +104,9 @@ public abstract class GLDrawableFactory {
Class clazz = Class.forName("com.sun.opengl.impl.egl.EGLDrawableFactory");
Constructor c = clazz.getDeclaredConstructor(new Class[] { String.class });
factory = (GLDrawableFactory) c.newInstance(new Object[] { profile });
+ return;
} catch (Exception e) {
+ e.printStackTrace();
}
} else if (!PROFILE_GL_20.equals(profile)) {
// We require that the user passes in one of the known profiles
diff --git a/src/native/jogl/WindowsWindow.c b/src/native/jogl/WindowsWindow.c
new file mode 100755
index 000000000..8742e5fbe
--- /dev/null
+++ b/src/native/jogl/WindowsWindow.c
@@ -0,0 +1,299 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+#include <windows.h>
+#include <stdlib.h>
+
+/* This typedef is apparently needed for Microsoft compilers before VC8 */
+#if _MSC_VER < 1400
+#ifdef _WIN64
+typedef long long intptr_t;
+#else
+typedef int intptr_t;
+#endif
+#endif
+
+#include "com_sun_javafx_newt_windows_WindowsWindow.h"
+
+static jmethodID keyDownID = NULL;
+static jmethodID keyUpID = NULL;
+static jmethodID sizeChangedID = NULL;
+static jmethodID windowClosedID = NULL;
+static jmethodID windowDestroyedID = NULL;
+
+// This is set by DispatchMessages, below, and cleared when it exits
+static JNIEnv* env = NULL;
+
+// Really need to factor this out in to a separate run-time file
+static jchar* GetNullTerminatedStringChars(JNIEnv* env, jstring str)
+{
+ jchar* strChars = NULL;
+ strChars = calloc((*env)->GetStringLength(env, str) + 1, sizeof(jchar));
+ if (strChars != NULL) {
+ (*env)->GetStringRegion(env, str, 0, (*env)->GetStringLength(env, str), strChars);
+ }
+ return strChars;
+}
+
+static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ RECT rc;
+ int useDefWindowProc = 0;
+ jobject window = NULL;
+
+ window = (jobject) GetWindowLongPtr(wnd, GWLP_USERDATA);
+ if (window == NULL || env == NULL) {
+ // Shouldn't happen
+ return DefWindowProc(wnd, message, wParam, lParam);
+ }
+
+ switch (message) {
+ case WM_CLOSE:
+ (*env)->CallVoidMethod(env, window, windowClosedID);
+ DestroyWindow(wnd);
+ break;
+
+ case WM_DESTROY:
+ (*env)->CallVoidMethod(env, window, windowDestroyedID);
+ break;
+
+ case WM_KEYDOWN:
+ (*env)->CallVoidMethod(env, window, keyDownID, (jlong) wParam);
+ useDefWindowProc = 1;
+ break;
+
+ case WM_KEYUP:
+ (*env)->CallVoidMethod(env, window, keyUpID, (jlong) wParam);
+ useDefWindowProc = 1;
+ break;
+
+ case WM_SIZE:
+ GetClientRect(wnd, &rc);
+ (*env)->CallVoidMethod(env, window, sizeChangedID, (jint) rc.right, (jint) rc.bottom);
+ break;
+
+ default:
+ useDefWindowProc = 1;
+ }
+
+ if (useDefWindowProc)
+ return DefWindowProc(wnd, message, wParam, lParam);
+ return 0;
+}
+
+/*
+ * Class: com_sun_javafx_newt_windows_WindowsWindow
+ * Method: initIDs
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_initIDs
+ (JNIEnv *env, jclass clazz)
+{
+ keyDownID = (*env)->GetMethodID(env, clazz, "keyDown", "(J)V");
+ keyUpID = (*env)->GetMethodID(env, clazz, "keyUp", "(J)V");
+ sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(II)V");
+ windowClosedID = (*env)->GetMethodID(env, clazz, "windowClosed", "()V");
+ windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
+ if (keyDownID == NULL ||
+ keyUpID == NULL ||
+ sizeChangedID == NULL ||
+ windowClosedID == NULL ||
+ windowDestroyedID == NULL) {
+ return JNI_FALSE;
+ }
+ return JNI_TRUE;
+}
+
+/*
+ * Class: com_sun_javafx_newt_windows_WindowsWindow
+ * Method: LoadLibraryW
+ * Signature: (Ljava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_LoadLibraryW
+ (JNIEnv *env, jclass clazz, jstring dllName)
+{
+ jchar* _dllName = GetNullTerminatedStringChars(env, dllName);
+ HMODULE lib = LoadLibraryW(_dllName);
+ free(_dllName);
+ return (jlong) (intptr_t) lib;
+}
+
+/*
+ * Class: com_sun_javafx_newt_windows_WindowsWindow
+ * Method: RegisterWindowClass
+ * Signature: (Ljava/lang/String;J)J
+ */
+JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_RegisterWindowClass
+ (JNIEnv *env, jclass clazz, jstring appName, jlong hInstance)
+{
+ WNDCLASSW* wc;
+ const char* _appName = NULL;
+
+ wc = calloc(1, sizeof(WNDCLASSW));
+ /* register class */
+ wc->style = CS_HREDRAW | CS_VREDRAW;
+ wc->lpfnWndProc = (WNDPROC)wndProc;
+ wc->cbClsExtra = 0;
+ wc->cbWndExtra = 0;
+ /* This cast is legal because the HMODULE for a DLL is the same as
+ its HINSTANCE -- see MSDN docs for DllMain */
+ wc->hInstance = (HINSTANCE) hInstance;
+ wc->hIcon = NULL;
+ wc->hCursor = 0;
+ wc->hbrBackground = GetStockObject(BLACK_BRUSH);
+ wc->lpszMenuName = NULL;
+ wc->lpszClassName = GetNullTerminatedStringChars(env, appName);
+ if (!RegisterClassW(wc)) {
+ free(wc);
+ return 0;
+ }
+ return (jlong) (intptr_t) wc;
+}
+
+/*
+ * Class: com_sun_javafx_newt_windows_WindowsWindow
+ * Method: CreateWindow
+ * Signature: (Ljava/lang/String;II)J
+ */
+JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_CreateWindow
+ (JNIEnv *env, jobject obj, jstring windowClassName, jlong hInstance, jint defaultWidth, jint defaultHeight)
+{
+ jchar* wndClassName = GetNullTerminatedStringChars(env, windowClassName);
+ DWORD windowStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
+ int x, y;
+ int width, height;
+ HWND window = NULL;
+
+#ifdef UNDER_CE
+ width = GetSystemMetrics(SM_CXSCREEN);
+ height = GetSystemMetrics(SM_CYSCREEN);
+ x = y = 0;
+#else
+ windowStyle |= WS_OVERLAPPEDWINDOW;
+ x = CW_USEDEFAULT;
+ y = 0;
+ width = defaultWidth;
+ height = defaultHeight;
+#endif
+ window = CreateWindowW(wndClassName, wndClassName, windowStyle,
+ x, y, width, height,
+ NULL, NULL,
+ (HINSTANCE) hInstance,
+ NULL);
+ if (window != NULL) {
+ SetWindowLongPtr(window, GWLP_USERDATA, (intptr_t) (*env)->NewGlobalRef(env, obj));
+ ShowWindow(window, SW_SHOWNORMAL);
+ }
+ return (jlong) (intptr_t) window;
+}
+
+/*
+ * Class: com_sun_javafx_newt_windows_WindowsWindow
+ * Method: DispatchMessages
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_DispatchMessages
+ (JNIEnv *env, jclass clazz, jlong window)
+{
+ int i = 0;
+ MSG msg;
+ BOOL gotOne;
+
+ // Periodically take a break
+ do {
+ gotOne = PeekMessage(&msg, (HWND) window, 0, 0, PM_REMOVE);
+ if (gotOne) {
+ ++i;
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ } while (gotOne && i < 100);
+}
+
+/*
+ * Class: com_sun_javafx_newt_windows_WindowsWindow
+ * Method: setSize0
+ * Signature: (JII)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setSize0
+ (JNIEnv *env, jobject obj, jlong window, jint width, jint height)
+{
+ RECT r;
+ HWND w = (HWND) window;
+ GetWindowRect(w, &r);
+ MoveWindow(w, r.left, r.top, width, height, TRUE);
+ (*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) width, (jint) height);
+}
+
+/*
+ * Class: com_sun_javafx_newt_windows_WindowsWindow
+ * Method: setFullScreen0
+ * Signature: (JZ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setFullScreen0
+ (JNIEnv *env, jobject obj, jlong window, jboolean fullscreen)
+{
+#ifdef UNDER_CE
+ int screenWidth;
+ int screenHeight;
+ HWND win = (HWND) window;
+
+ if (fullscreen) {
+ screenWidth = GetSystemMetrics(SM_CXSCREEN);
+ screenHeight = GetSystemMetrics(SM_CYSCREEN);
+ /* First, hide all of the shell parts */
+ SHFullScreen(win,
+ SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | SHFS_HIDESTARTICON);
+ MoveWindow(win, 0, 0, screenWidth, screenHeight, TRUE);
+ (*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) screenWidth, (jint) screenHeight);
+ } else {
+ RECT rc;
+ int width, height;
+
+ /* First, show all of the shell parts */
+ SHFullScreen(win,
+ SHFS_SHOWTASKBAR | SHFS_SHOWSIPBUTTON | SHFS_SHOWSTARTICON);
+ /* Now resize the window to the size of the work area */
+ SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, FALSE);
+ width = rc.right - rc.left;
+ height = rc.bottom - rc.top;
+ MoveWindow(win, rc.left, rc.top, width, height, TRUE);
+ (*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) width, (jint) height);
+ }
+ return JNI_TRUE;
+#else
+ /* For the time being, full-screen not supported on the desktop */
+ return JNI_FALSE;
+#endif
+}