aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/make.jogl.all.win32.bat2
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java17
-rwxr-xr-xsrc/newt/native/WindowsWindow.c114
3 files changed, 89 insertions, 44 deletions
diff --git a/make/make.jogl.all.win32.bat b/make/make.jogl.all.win32.bat
index 9ab77b051..8525b5a45 100644
--- a/make/make.jogl.all.win32.bat
+++ b/make/make.jogl.all.win32.bat
@@ -9,4 +9,4 @@ REM -DuseOpenMAX=true
REM -DuseKD=true
REM -Djogl.cg=1 -D-Dwindows.cg.lib=C:\Cg-2.2
-ant -Dbuild.noarchives=true -Dc.compiler.debug=true -Drootrel.build=build-win32 -Djogl.cg=1 -Dwindows.cg.lib=C:\Cg-2.2\lib > make.jogl.all.win32.log 2>&1
+ant -Dbuild.noarchives=true -Dc.compiler.debug=true -Drootrel.build=build-win32 -Djogl.cg=1 -Dwindows.cg.lib=C:\Cg-2.2\lib %1 %2 %3 %4 %5 %6 %7 %8 %9 > make.jogl.all.win32.log 2>&1
diff --git a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
index 749c67313..928e8e05a 100755
--- a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
@@ -41,6 +41,7 @@ public class WindowsWindow extends Window {
private long hmon;
private long hdc;
private long windowHandleClose;
+ private long parentWindowHandle;
// non fullscreen dimensions ..
private int nfs_width, nfs_height, nfs_x, nfs_y;
private final Insets insets = new Insets(0, 0, 0, 0);
@@ -105,6 +106,7 @@ public class WindowsWindow extends Window {
if (windowHandle == 0) {
throw new NativeWindowException("Error creating window");
}
+ this.parentWindowHandle = parentWindowHandle;
windowHandleClose = windowHandle;
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
Exception e = new Exception("!!! Window new window handle "+Thread.currentThread().getName()+
@@ -135,6 +137,9 @@ public class WindowsWindow extends Window {
if(this.visible!=visible && 0!=windowHandle) {
this.visible=visible;
setVisible0(windowHandle, visible);
+ if(visible) {
+ setPosition(x, y);
+ }
}
}
@@ -147,7 +152,7 @@ public class WindowsWindow extends Window {
}
this.width = width;
this.height = height;
- setSize0(windowHandle, width, height);
+ setSize0(parentWindowHandle, windowHandle, x, y, width, height);
}
}
@@ -160,7 +165,7 @@ public class WindowsWindow extends Window {
}
this.x = x;
this.y = y;
- setPosition(windowHandle, x , y);
+ setPosition(parentWindowHandle, windowHandle, x , y);
}
}
@@ -181,7 +186,7 @@ public class WindowsWindow extends Window {
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
System.err.println("WindowsWindow fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h);
}
- setFullscreen0(windowHandle, x, y, w, h, undecorated, fullscreen);
+ setFullscreen0(parentWindowHandle, windowHandle, x, y, w, h, undecorated, fullscreen);
}
return fullscreen;
}
@@ -223,9 +228,9 @@ public class WindowsWindow extends Window {
private native void ReleaseDC(long windowHandle, long hdc);
private native long MonitorFromWindow(long windowHandle);
private static native void setVisible0(long windowHandle, boolean visible);
- private native void setSize0(long windowHandle, int width, int height);
- private native void setPosition(long windowHandle, int x, int y);
- private native void setFullscreen0(long windowHandle, int x, int y, int width, int height, boolean isUndecorated, boolean on);
+ private native void setSize0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height);
+ private native void setPosition(long parentWindowHandle, long windowHandle, int x, int y);
+ private native void setFullscreen0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height, boolean isUndecorated, boolean on);
private static native void setTitle(long windowHandle, String title);
private static native void requestFocus(long windowHandle);
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index a171f34b2..9d3d76bde 100755
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -96,6 +96,14 @@
#include "InputEvent.h"
#include "KeyEvent.h"
+// #define VERBOSE_ON 1
+
+#ifdef VERBOSE_ON
+ #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
+#else
+ #define DBG_PRINT(...)
+#endif
+
static jmethodID sizeChangedID = NULL;
static jmethodID insetsChangedID = NULL;
static jmethodID positionChangedID = NULL;
@@ -624,7 +632,8 @@ static RECT * UpdateInsets(JNIEnv *env, HWND hwnd, jobject window)
{
LONG style = GetWindowLong(hwnd, GWL_STYLE);
// TODO: TDV: better undecorated checking needed
- BOOL bIsUndecorated = (style & (WS_POPUP|WS_SYSMENU)) != 0;
+
+ BOOL bIsUndecorated = (style & (WS_CHILD|WS_POPUP|WS_SYSMENU)) != 0;
if (!bIsUndecorated) {
/* Get outer frame sizes. */
if (style & WS_THICKFRAME) {
@@ -647,6 +656,9 @@ static RECT * UpdateInsets(JNIEnv *env, HWND hwnd, jobject window)
}
}
+ DBG_PRINT("*** WindowsWindow: UpdateInsets window %p, %d/%d %dx%d\n", hwnd,
+ m_insets.left, m_insets.top, m_insets.right-m_insets.left, m_insets.top-m_insets.bottom);
+
(*env)->CallVoidMethod(env, window, insetsChangedID,
m_insets.left, m_insets.top,
m_insets.right, m_insets.bottom);
@@ -851,6 +863,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
break;
case WM_MOVE:
+ DBG_PRINT("*** WindowsWindow: WM_MOVE window %p, %d/%d\n", wnd, (int)LOWORD(lParam), (int)HIWORD(lParam));
(*env)->CallVoidMethod(env, window, positionChangedID,
(jint)LOWORD(lParam), (jint)HIWORD(lParam));
useDefWindowProc = 1;
@@ -944,7 +957,7 @@ JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_windows_WindowsDisplay_RegisterW
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.hInstance = (HINSTANCE) (intptr_t) hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
wc.hbrBackground = GetStockObject(BLACK_BRUSH);
@@ -971,7 +984,7 @@ JNIEXPORT jint JNICALL Java_com_sun_javafx_newt_windows_WindowsDisplay_RegisterW
JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsDisplay_UnregisterWindowClass
(JNIEnv *env, jclass clazz, jint wndClassAtom, jlong hInstance)
{
- UnregisterClass(MAKEINTATOM(wndClassAtom), (HINSTANCE) hInstance);
+ UnregisterClass(MAKEINTATOM(wndClassAtom), (HINSTANCE) (intptr_t) hInstance);
}
/*
@@ -1039,6 +1052,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_CreateWin
jboolean bIsUndecorated,
jint jx, jint jy, jint defaultWidth, jint defaultHeight)
{
+ HWND parentWindow = (HWND) (intptr_t) parent;
const TCHAR* wndName = NULL;
DWORD windowStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
int x=(int)jx, y=(int)jy;
@@ -1051,23 +1065,27 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_CreateWin
wndName = (*env)->GetStringUTFChars(env, jWndName, NULL);
#endif
- x = CW_USEDEFAULT;
- y = 0;
- if (bIsUndecorated) {
+ if(NULL!=parentWindow) {
+ windowStyle |= WS_CHILD ;
+ } else if (bIsUndecorated) {
windowStyle |= WS_POPUP | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;
} else {
windowStyle |= WS_OVERLAPPEDWINDOW;
+ x = CW_USEDEFAULT;
+ y = 0;
}
(void) visualID; // FIXME: use the visualID ..
window = CreateWindow(MAKEINTATOM(wndClassAtom), wndName, windowStyle,
x, y, width, height,
- (HWND)parent, NULL,
- (HINSTANCE) hInstance,
+ parentWindow, NULL,
+ (HINSTANCE) (intptr_t) hInstance,
NULL);
- if (window != NULL) {
+ DBG_PRINT("*** WindowsWindow: CreateWindow parent %p, window %p, %d/%d %dx%d\n", parentWindow, window, x, y, width, height);
+
+ if (NULL != window) {
WindowUserData * wud = (WindowUserData *) malloc(sizeof(WindowUserData));
wud->jinstance = (*env)->NewGlobalRef(env, obj);
wud->jenv = env;
@@ -1100,7 +1118,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_CreateWin
JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_DestroyWindow
(JNIEnv *env, jobject obj, jlong window)
{
- DestroyWindow((HWND) window);
+ DestroyWindow((HWND) (intptr_t) window);
}
/*
@@ -1111,7 +1129,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_DestroyWin
JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_GetDC
(JNIEnv *env, jobject obj, jlong window)
{
- return (jlong) GetDC((HWND) window);
+ return (jlong) (intptr_t) GetDC((HWND) (intptr_t) window);
}
/*
@@ -1122,7 +1140,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_GetDC
JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_ReleaseDC
(JNIEnv *env, jobject obj, jlong window, jlong dc)
{
- ReleaseDC((HWND) window, (HDC) dc);
+ ReleaseDC((HWND) (intptr_t) window, (HDC) (intptr_t) dc);
}
/*
@@ -1134,7 +1152,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_MonitorFr
(JNIEnv *env, jobject obj, jlong window)
{
#if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410 || WINVER >= 0x0500) && !defined(_WIN32_WCE)
- return (jlong)MonitorFromWindow((HWND)window, MONITOR_DEFAULTTOPRIMARY);
+ return (jlong) (intptr_t) MonitorFromWindow((HWND) (intptr_t) window, MONITOR_DEFAULTTOPRIMARY);
#else
return 0;
#endif
@@ -1149,6 +1167,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setVisible
(JNIEnv *_env, jclass clazz, jlong window, jboolean visible)
{
HWND hWnd = (HWND) (intptr_t) window;
+ DBG_PRINT("*** WindowsWindow: setVisible window %p, visible: %d\n", hWnd, (int)visible);
if (visible) {
ShowWindow(hWnd, SW_SHOW);
} else {
@@ -1162,20 +1181,33 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setVisible
* Signature: (JII)V
*/
JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setSize0
- (JNIEnv *env, jobject obj, jlong window, jint width, jint height)
+ (JNIEnv *env, jobject obj, jlong parent, jlong window, jint x, jint y, jint width, jint height)
{
- RECT r;
- HWND w = (HWND) window;
- // since width, height are the size of the client area, we need to add
- // insets
- RECT *pInsets = UpdateInsets(env, w, obj);
- int nWidth, nHeight;
-
- GetWindowRect(w, &r);
-
- nWidth = width + pInsets->left + pInsets->right;
- nHeight = height + pInsets->top + pInsets->bottom;
- MoveWindow(w, r.left, r.top, nWidth, nHeight, TRUE);
+ HWND hwndP = (HWND) (intptr_t) parent;
+ HWND hwnd = (HWND) (intptr_t) window;
+ int nWidth=width, nHeight=height;
+ int nX=x, nY=y;
+
+ if(NULL==hwndP) {
+ // since width, height are the size of the client area, we need to add
+ // insets
+ RECT *pInsets = UpdateInsets(env, hwnd, obj);
+
+ RECT r;
+ GetWindowRect(hwnd, &r);
+
+ nWidth = width + pInsets->left + pInsets->right;
+ nHeight = height + pInsets->top + pInsets->bottom;
+ nX=r.left; nY=r.top; // FIXME: really ?
+ }
+
+ DBG_PRINT("*** WindowsWindow: setSize parent %p, window %p, %d/%d %dx%d -> %d/%d %dx%d\n",
+ hwndP, hwnd,
+ x, y, width, height,
+ nX, nY, nWidth, nHeight);
+
+ MoveWindow(hwnd, nX, nY, nWidth, nHeight, TRUE);
+
// we report back the size of client area
(*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) width, (jint) height);
}
@@ -1186,14 +1218,19 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setSize0
* Signature: (JII)V
*/
JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setPosition
- (JNIEnv *env, jobject obj, jlong window, jint x, jint y)
+ (JNIEnv *env, jobject obj, jlong parent, jlong window, jint x, jint y)
{
- UINT flags = SWP_NOACTIVATE | SWP_NOZORDER;
- HWND hwnd = (HWND)window;
- RECT r;
+ UINT flags = SWP_NOACTIVATE | SWP_NOSIZE;
+ HWND hwndP = (HWND) (intptr_t) parent;
+ HWND hwnd = (HWND) (intptr_t) window;
+
+ if(NULL==hwndP) {
+ flags |= SWP_NOZORDER;
+ }
+
+ DBG_PRINT("*** WindowsWindow: setPosition parent %p, window %p, %d/%d\n", hwndP, hwnd, x, y);
- GetWindowRect(hwnd, &r);
- SetWindowPos(hwnd, 0, x, y, (r.right-r.left), (r.bottom-r.top), flags);
+ SetWindowPos(hwnd, hwndP, x, y, 0, 0, flags);
}
/*
@@ -1202,14 +1239,17 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setPositio
* Signature: (JIIIIZZ)V
*/
JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setFullscreen0
- (JNIEnv *env, jobject obj, jlong window, jint x, jint y, jint width, jint height, jboolean bIsUndecorated, jboolean on)
+ (JNIEnv *env, jobject obj, jlong parent, jlong window, jint x, jint y, jint width, jint height, jboolean bIsUndecorated, jboolean on)
{
UINT flags;
- HWND hwnd = (HWND)window;
+ HWND hwndP = (HWND) (intptr_t) parent;
+ HWND hwnd = (HWND) (intptr_t) window;
HWND hWndInsertAfter;
DWORD windowStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
- if (bIsUndecorated || on) {
+ if(NULL!=hwndP) {
+ windowStyle |= WS_CHILD ;
+ } else if (bIsUndecorated || on) {
windowStyle |= WS_POPUP | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;
} else {
windowStyle |= WS_OVERLAPPEDWINDOW;
@@ -1237,7 +1277,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setFullscr
JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setTitle
(JNIEnv *env, jclass clazz, jlong window, jstring title)
{
- HWND hwnd = (HWND)window;
+ HWND hwnd = (HWND) (intptr_t) window;
if (title != NULL) {
jchar *titleString = GetNullTerminatedStringChars(env, title);
if (titleString != NULL) {
@@ -1255,7 +1295,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_setTitle
JNIEXPORT void JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_requestFocus
(JNIEnv *env, jclass clazz, jlong window)
{
- HWND hwnd = (HWND)window;
+ HWND hwnd = (HWND) (intptr_t) window;
if (IsWindow(hwnd)) {
SetFocus(hwnd);