aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt/native')
-rw-r--r--src/newt/native/KDWindow.c5
-rw-r--r--src/newt/native/NewtMacWindow.m5
-rw-r--r--src/newt/native/WindowEvent.h13
-rw-r--r--src/newt/native/WindowsWindow.c134
-rw-r--r--src/newt/native/X11Window.c6
5 files changed, 31 insertions, 132 deletions
diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c
index 33af4d963..50ad22b5a 100644
--- a/src/newt/native/KDWindow.c
+++ b/src/newt/native/KDWindow.c
@@ -94,7 +94,6 @@ static jmethodID windowCreatedID = NULL;
static jmethodID sizeChangedID = NULL;
static jmethodID visibleChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
-static jmethodID windowDestroyedID = NULL;
static jmethodID sendMouseEventID = NULL;
static jmethodID sendKeyEventID = NULL;
@@ -137,8 +136,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_opengl_kd_KDDisplay_DispatchMes
{
DBG_PRINT( "event window close : src: %p\n", userData);
(*env)->CallVoidMethod(env, javaWindow, windowDestroyNotifyID);
- // Called by Window.java: DestroyWindow(wnd);
- // (*env)->CallVoidMethod(env, javaWindow, windowDestroyedID);
}
break;
case KD_EVENT_WINDOWPROPERTY_CHANGE:
@@ -213,14 +210,12 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_opengl_kd_KDWindow_initIDs
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(IIZ)V");
visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
- windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
if (windowCreatedID == NULL ||
sizeChangedID == NULL ||
visibleChangedID == NULL ||
windowDestroyNotifyID == NULL ||
- windowDestroyedID == NULL ||
sendMouseEventID == NULL ||
sendKeyEventID == NULL) {
DBG_PRINT( "initIDs failed\n" );
diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m
index 2d8a84b4b..cba69498a 100644
--- a/src/newt/native/NewtMacWindow.m
+++ b/src/newt/native/NewtMacWindow.m
@@ -80,7 +80,6 @@ static jmethodID visibleChangedID = NULL;
static jmethodID positionChangedID = NULL;
static jmethodID focusChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
-static jmethodID windowDestroyedID = NULL;
@implementation NewtView
- (void) setJNIEnv: (JNIEnv*) theEnv
@@ -142,9 +141,8 @@ static jmethodID windowDestroyedID = NULL;
positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(II)V");
focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(Z)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
- windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
if (sendMouseEventID && sendKeyEventID && sizeChangedID && visibleChangedID && insetsChangedID &&
- positionChangedID && focusChangedID && windowDestroyedID && windowDestroyNotifyID)
+ positionChangedID && focusChangedID && windowDestroyNotifyID)
{
return YES;
}
@@ -456,7 +454,6 @@ static jint mods2JavaMods(NSUInteger mods)
(*env)->CallVoidMethod(env, javaWindowObject, windowDestroyNotifyID);
// Can't issue call here - locked window state, done from Java method
- // (*env)->CallVoidMethod(env, javaWindowObject, windowDestroyedID); // No OSX hook for DidClose, so do it here
// EOL ..
(*env)->DeleteGlobalRef(env, javaWindowObject);
diff --git a/src/newt/native/WindowEvent.h b/src/newt/native/WindowEvent.h
index 6274f9443..05491b43c 100644
--- a/src/newt/native/WindowEvent.h
+++ b/src/newt/native/WindowEvent.h
@@ -2,11 +2,12 @@
#ifndef _WINDOW_EVENT_H_
#define _WINDOW_EVENT_H_
-#define EVENT_WINDOW_RESIZED = 100;
-#define EVENT_WINDOW_MOVED = 101;
-#define EVENT_WINDOW_DESTROY_NOTIFY = 102;
-#define EVENT_WINDOW_GAINED_FOCUS = 103;
-#define EVENT_WINDOW_LOST_FOCUS = 104;
-#define EVENT_WINDOW_REPAINT = 105; // TODO
+#define EVENT_WINDOW_RESIZED 100
+#define EVENT_WINDOW_MOVED 101
+#define EVENT_WINDOW_DESTROY_NOTIFY 102
+#define EVENT_WINDOW_GAINED_FOCUS 103
+#define EVENT_WINDOW_LOST_FOCUS 104
+#define EVENT_WINDOW_REPAINT 105
+#define EVENT_WINDOW_DESTROYED 106
#endif
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index b282ec9b2..998743e75 100644
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -124,7 +124,6 @@ static jmethodID positionChangedID = NULL;
static jmethodID focusChangedID = NULL;
static jmethodID visibleChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
-static jmethodID windowDestroyedID = NULL;
static jmethodID windowRepaintID = NULL;
static jmethodID enqueueMouseEventID = NULL;
static jmethodID sendMouseEventID = NULL;
@@ -820,8 +819,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
//
// The signal pipeline for destruction is:
// Java::DestroyWindow(wnd) _or_ window-close-button ->
- // WM_CLOSE -> Java::windowDestroyNotify -> W_DESTROY -> Java::windowDestroyed ->
- // Java::CleanupWindowResources()
+ // WM_CLOSE -> Java::windowDestroyNotify -> W_DESTROY
case WM_CLOSE:
(*env)->CallVoidMethod(env, window, windowDestroyNotifyID);
break;
@@ -834,7 +832,6 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
SetWindowLongPtr(wnd, GWLP_USERDATA, (intptr_t) NULL);
#endif
free(wud); wud=NULL;
- (*env)->CallVoidMethod(env, window, windowDestroyedID);
(*env)->DeleteGlobalRef(env, window);
}
break;
@@ -1047,71 +1044,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_Dispatch
}
/*
- * Class: com_jogamp_newt_impl_windows_WindowsDisplay
- * Method: LoadLibraryW
- * Signature: (Ljava/lang/String;)J
- */
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_LoadLibraryW0
- (JNIEnv *env, jclass clazz, jstring dllName)
-{
- jchar* _dllName = NewtCommon_GetNullTerminatedStringChars(env, dllName);
- HMODULE lib = LoadLibraryW(_dllName);
- free(_dllName);
- return (jlong) (intptr_t) lib;
-}
-
-/*
- * Class: com_jogamp_newt_impl_windows_WindowsDisplay
- * Method: RegisterWindowClass
- * Signature: (Ljava/lang/String;J)I
- */
-JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_RegisterWindowClass0
- (JNIEnv *env, jclass clazz, jstring wndClassName, jlong hInstance)
-{
- ATOM res;
- WNDCLASS wc;
-#ifndef UNICODE
- const char* _wndClassName = NULL;
-#endif
-
- /* 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) (intptr_t) hInstance;
- wc.hIcon = NULL;
- wc.hCursor = LoadCursor( NULL, IDC_ARROW);
- wc.hbrBackground = GetStockObject(BLACK_BRUSH);
- wc.lpszMenuName = NULL;
-#ifdef UNICODE
- wc.lpszClassName = NewtCommon_GetNullTerminatedStringChars(env, wndClassName);
-#else
- _wndClassName = (*env)->GetStringUTFChars(env, wndClassName, NULL);
- wc.lpszClassName = strdup(_wndClassName);
- (*env)->ReleaseStringUTFChars(env, wndClassName, _wndClassName);
-#endif
- res = RegisterClass(&wc);
-
- free((void *)wc.lpszClassName);
-
- return (jint)res;
-}
-
-/*
- * Class: com_jogamp_newt_impl_windows_WindowsDisplay
- * Method: CleanupWindowResources
- * Signature: (java/lang/String;J)V
- */
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_UnregisterWindowClass0
- (JNIEnv *env, jclass clazz, jint wndClassAtom, jlong hInstance)
-{
- UnregisterClass(MAKEINTATOM(wndClassAtom), (HINSTANCE) (intptr_t) hInstance);
-}
-
-/*
* Class: com_jogamp_newt_impl_windows_WindowsScreen
* Method: getWidthImpl
* Signature: (I)I
@@ -1332,7 +1264,6 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initI
focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(Z)V");
visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
- windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(IIII)V");
enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V");
sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
@@ -1347,7 +1278,6 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initI
focusChangedID == NULL ||
visibleChangedID == NULL ||
windowDestroyNotifyID == NULL ||
- windowDestroyedID == NULL ||
windowRepaintID == NULL ||
enqueueMouseEventID == NULL ||
sendMouseEventID == NULL ||
@@ -1363,15 +1293,27 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initI
/*
* Class: com_jogamp_newt_impl_windows_WindowsWindow
+ * Method: getNewtWndProc0
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_getNewtWndProc0
+ (JNIEnv *env, jclass clazz)
+{
+ return (jlong) (intptr_t) wndProc;
+}
+
+/*
+ * Class: com_jogamp_newt_impl_windows_WindowsWindow
* Method: CreateWindow
- * Signature: (JILjava/lang/String;JJZIIII)J
*/
JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWindow0
- (JNIEnv *env, jobject obj, jlong parent, jint wndClassAtom, jstring jWndName, jlong hInstance, jlong visualID,
- jboolean bIsUndecorated,
- jint jx, jint jy, jint defaultWidth, jint defaultHeight)
+ (JNIEnv *env, jobject obj,
+ jlong hInstance, jstring jWndClassName, jstring jWndName,
+ jlong parent, jlong visualID, jboolean bIsUndecorated,
+ jint jx, jint jy, jint defaultWidth, jint defaultHeight)
{
HWND parentWindow = (HWND) (intptr_t) parent;
+ const TCHAR* wndClassName = NULL;
const TCHAR* wndName = NULL;
DWORD windowStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE | WS_TABSTOP;
int x=(int)jx, y=(int)jy;
@@ -1379,8 +1321,10 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWi
HWND window = NULL;
#ifdef UNICODE
+ wndClassName = NewtCommon_GetNullTerminatedStringChars(env, jWndClassName);
wndName = NewtCommon_GetNullTerminatedStringChars(env, jWndName);
#else
+ wndClassName = (*env)->GetStringUTFChars(env, jWndClassName, NULL);
wndName = (*env)->GetStringUTFChars(env, jWndName, NULL);
#endif
@@ -1400,13 +1344,13 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWi
(void) visualID; // FIXME: use the visualID ..
- window = CreateWindow(MAKEINTATOM(wndClassAtom), wndName, windowStyle,
+ window = CreateWindow(wndClassName, wndName, windowStyle,
x, y, width, height,
parentWindow, NULL,
(HINSTANCE) (intptr_t) hInstance,
NULL);
- DBG_PRINT("*** WindowsWindow: CreateWindow thread 0xX, parent %p, window %p, %d/%d %dx%d\n",
+ DBG_PRINT("*** WindowsWindow: CreateWindow thread 0x%X, parent %p, window %p, %d/%d %dx%d\n",
(int)GetCurrentThreadId(), parentWindow, window, x, y, width, height);
if (NULL == window) {
@@ -1427,8 +1371,10 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWi
}
#ifdef UNICODE
+ free((void*) wndClassName);
free((void*) wndName);
#else
+ (*env)->ReleaseStringUTFChars(env, jWndClassName, wndClassName);
(*env)->ReleaseStringUTFChars(env, jWndName, wndName);
#endif
@@ -1437,40 +1383,6 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWi
/*
* Class: com_jogamp_newt_impl_windows_WindowsWindow
- * Method: DestroyWindow
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_DestroyWindow0
- (JNIEnv *env, jobject obj, jlong window)
-{
- DBG_PRINT("*** WindowsWindow: DestroyWindow thread 0x%X, window %p\n", (int)GetCurrentThreadId(), window);
- DestroyWindow((HWND) (intptr_t) window);
-}
-
-/*
- * Class: com_jogamp_newt_impl_windows_WindowsWindow
- * Method: GetDC
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_GetDC0
- (JNIEnv *env, jobject obj, jlong window)
-{
- return (jlong) (intptr_t) GetDC((HWND) (intptr_t) window);
-}
-
-/*
- * Class: com_jogamp_newt_impl_windows_WindowsWindow
- * Method: ReleaseDC
- * Signature: (JJ)V
- */
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_ReleaseDC0
- (JNIEnv *env, jobject obj, jlong window, jlong dc)
-{
- ReleaseDC((HWND) (intptr_t) window, (HDC) (intptr_t) dc);
-}
-
-/*
- * Class: com_jogamp_newt_impl_windows_WindowsWindow
* Method: MonitorFromWindow
* Signature: (J)J
*/
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index 15418269e..d30e5de59 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -147,7 +147,6 @@ static jmethodID positionChangedID = NULL;
static jmethodID focusChangedID = NULL;
static jmethodID visibleChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
-static jmethodID windowDestroyedID = NULL;
static jmethodID windowRepaintID = NULL;
static jmethodID windowReparentedID = NULL;
static jmethodID enqueueMouseEventID = NULL;
@@ -624,7 +623,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages
(void*)evt.xdestroywindow.window, (void*)evt.xdestroywindow.event, evt.xdestroywindow.window != evt.xdestroywindow.event);
if ( evt.xdestroywindow.window == evt.xdestroywindow.event ) {
// ignore child destroy notification
- (*env)->CallVoidMethod(env, jwindow, windowDestroyedID);
}
break;
case CreateNotify:
@@ -1191,7 +1189,6 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs0
focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(Z)V");
visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
- windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(IIII)V");
windowReparentedID = (*env)->GetMethodID(env, clazz, "windowReparented", "(J)V");
enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V");
@@ -1206,7 +1203,6 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs0
focusChangedID == NULL ||
visibleChangedID == NULL ||
windowDestroyNotifyID == NULL ||
- windowDestroyedID == NULL ||
windowRepaintID == NULL ||
windowReparentedID == NULL ||
enqueueMouseEventID == NULL ||
@@ -1394,8 +1390,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CloseWindow0
(*env)->DeleteGlobalRef(env, jwindow);
DBG_PRINT( "X11: CloseWindow END\n");
-
- (*env)->CallVoidMethod(env, obj, windowDestroyedID);
}
static void NewtWindows_setPosSize(Display *dpy, Window w, jint x, jint y, jint width, jint height)