diff options
author | Sven Gothel <[email protected]> | 2010-11-17 10:38:19 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-11-17 10:38:19 +0100 |
commit | dd0038a68a9aa99646549644c3338266546b05f8 (patch) | |
tree | 4af6467b23aa30a5897a609f51c5e3cba0b5ece7 /src | |
parent | db4d7d198cc826bba871fea39461c3c8a2a3b1c6 (diff) |
Move GDI GlueGen wrapping from JOGL -> NativeWindow (following X11). Moving NEWT WindowsWindow GetRelativeLocation() native implementation to GDI as well.
Diffstat (limited to 'src')
13 files changed, 296 insertions, 98 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java index 9a86f7d08..3f7028d56 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java @@ -40,9 +40,14 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.opengl.*; -import com.jogamp.opengl.impl.*; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLProfile; + import com.jogamp.nativewindow.impl.ProxySurface; +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR; public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { private long hwnd, hdc; diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java index 5ac937be8..f50b1a716 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java @@ -40,10 +40,19 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.opengl.*; -import javax.media.nativewindow.*; -import com.jogamp.opengl.impl.*; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; + import com.jogamp.nativewindow.impl.ProxySurface; +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.opengl.impl.GLContextShareSet; + public class WindowsExternalWGLContext extends WindowsWGLContext { private boolean firstMakeCurrent = true; diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java index ec0bd7c7a..8f41db365 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java @@ -40,10 +40,17 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.nativewindow.*; -import javax.media.opengl.*; -import com.jogamp.opengl.impl.*; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; + import com.jogamp.nativewindow.impl.ProxySurface; +import com.jogamp.nativewindow.impl.windows.GDI; public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java index f58d2f4bc..8bb781a45 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java @@ -40,9 +40,16 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.opengl.*; -import javax.media.nativewindow.*; -import com.jogamp.opengl.impl.*; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.SurfaceChangeable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; + +import com.jogamp.nativewindow.impl.windows.BITMAPINFO; +import com.jogamp.nativewindow.impl.windows.BITMAPINFOHEADER; +import com.jogamp.nativewindow.impl.windows.GDI; public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable { private long origbitmap; diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java index 0198f334c..a5631aded 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -40,12 +40,20 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.opengl.*; -import javax.media.nativewindow.*; -import com.jogamp.opengl.impl.*; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.SurfaceChangeable; +import javax.media.opengl.GL; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; +import javax.media.opengl.GLPbuffer; +import javax.media.opengl.GLProfile; + +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR; public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { - private long cachedParentHdc; private WGLExt cachedWGLExt; // cached WGLExt instance from parent GLCanvas, // needed to destroy pbuffer private long buffer; // pbuffer handle @@ -270,8 +278,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { // Set up instance variables buffer = tmpBuffer; ((SurfaceChangeable)ns).setSurfaceHandle(tmpHdc); - cachedWGLExt = wglExt; - cachedParentHdc = parentHdc; + cachedWGLExt = wglExt; // Re-query chosen pixel format { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java index 7be597dcc..529fda2c9 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java @@ -40,13 +40,23 @@ package com.jogamp.opengl.impl.windows.wgl; -import java.nio.*; -import java.util.*; -import javax.media.opengl.*; -import javax.media.nativewindow.*; -import com.jogamp.opengl.impl.*; +import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLException; + import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.opengl.impl.GLContextImpl; +import com.jogamp.opengl.impl.GLContextShareSet; +import com.jogamp.opengl.impl.GLDrawableImpl; + public class WindowsWGLContext extends GLContextImpl { private static final Map/*<String, String>*/ functionNameMap; @@ -86,7 +96,7 @@ public class WindowsWGLContext extends GLContextImpl { wglGetExtensionsStringEXTAvailable=false; wglMakeContextCurrentInitialized=false; wglMakeContextCurrentAvailable=false; - // no inner state wglExt=null; + // no inner state _wglExt=null; wglExtProcAddressTable=null; } @@ -102,7 +112,7 @@ public class WindowsWGLContext extends GLContextImpl { } public boolean wglMakeContextCurrent(long hDrawDC, long hReadDC, long ctx) { - WGLExt wglExt = getWGLExt(); + WGLExt _wglExt = getWGLExt(); if (!wglMakeContextCurrentInitialized) { wglMakeContextCurrentAvailable = isFunctionAvailable("wglMakeContextCurrent"); wglMakeContextCurrentInitialized = true; @@ -111,7 +121,7 @@ public class WindowsWGLContext extends GLContextImpl { } } if(wglMakeContextCurrentAvailable) { - return wglExt.wglMakeContextCurrent(hDrawDC, hReadDC, ctx); + return _wglExt.wglMakeContextCurrent(hDrawDC, hReadDC, ctx); } return WGL.wglMakeCurrent(hDrawDC, ctx); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java index 984708f52..bbbd93435 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java @@ -40,23 +40,23 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.nativewindow.*; -import javax.media.opengl.*; -import com.jogamp.opengl.impl.*; -import java.security.*; +import java.security.AccessController; +import javax.media.nativewindow.NativeSurface; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; + +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.opengl.impl.Debug; +import com.jogamp.opengl.impl.GLDrawableImpl; +import com.jogamp.opengl.impl.GLDynamicLookupHelper; + public abstract class WindowsWGLDrawable extends GLDrawableImpl { - private static final int MAX_SET_PIXEL_FORMAT_FAIL_COUNT = 5; private static final boolean PROFILING = Debug.isPropertyDefined("jogl.debug.GLDrawable.profiling", true, AccessController.getContext()); private static final int PROFILING_TICKS = 200; - private int profilingLockSurfaceTicks; - private long profilingLockSurfaceTime; - private int profilingUnlockSurfaceTicks; - private long profilingUnlockSurfaceTime; private int profilingSwapBuffersTicks; private long profilingSwapBuffersTime; - public WindowsWGLDrawable(GLDrawableFactory factory, NativeSurface comp, boolean realized) { super(factory, comp, realized); } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java index 64dd0eb46..462079913 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java @@ -40,19 +40,39 @@ package com.jogamp.opengl.impl.windows.wgl; -import java.nio.*; -import java.util.*; -import javax.media.nativewindow.*; -import javax.media.opengl.*; +import java.nio.Buffer; +import java.nio.ShortBuffer; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.windows.WindowsGraphicsDevice; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; + import com.jogamp.common.JogampRuntimeException; -import com.jogamp.common.util.*; -import com.jogamp.opengl.impl.*; +import com.jogamp.common.util.ReflectionUtil; import com.jogamp.nativewindow.impl.ProxySurface; -import javax.media.nativewindow.windows.WindowsGraphicsDevice; +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.opengl.impl.Debug; +import com.jogamp.opengl.impl.DesktopGLDynamicLookupHelper; +import com.jogamp.opengl.impl.GLDrawableFactoryImpl; +import com.jogamp.opengl.impl.GLDrawableImpl; +import com.jogamp.opengl.impl.GLDynamicLookupHelper; public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { - private static final boolean VERBOSE = Debug.verbose(); - private static final DesktopGLDynamicLookupHelper windowsWGLDynamicLookupHelper; static { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java index 619034da4..6c006577e 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java @@ -33,9 +33,22 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.nativewindow.*; -import javax.media.opengl.*; -import com.jogamp.opengl.impl.*; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.DefaultGraphicsConfiguration; +import javax.media.nativewindow.NativeSurface; +import javax.media.opengl.DefaultGLCapabilitiesChooser; +import javax.media.opengl.GL; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; +import javax.media.opengl.GLPbuffer; +import javax.media.opengl.GLProfile; + +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR; +import com.jogamp.opengl.impl.GLContextImpl; public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable { // Keep this under the same debug flag as the drawable factory for convenience diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java index 372630446..1d8f14d94 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java @@ -33,12 +33,24 @@ package com.jogamp.opengl.impl.windows.wgl; -import javax.media.nativewindow.*; -import javax.media.nativewindow.windows.*; -import com.jogamp.nativewindow.impl.*; +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.Capabilities; +import javax.media.nativewindow.CapabilitiesChooser; +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; -import javax.media.opengl.*; -import com.jogamp.opengl.impl.*; +import com.jogamp.nativewindow.impl.windows.GDI; +import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR; /** Subclass of GraphicsConfigurationFactory used when non-AWT tookits are used on Windows platforms. Toolkits will likely need to delegate diff --git a/src/nativewindow/native/windows/GDImisc.c b/src/nativewindow/native/windows/GDImisc.c new file mode 100644 index 000000000..3c1001115 --- /dev/null +++ b/src/nativewindow/native/windows/GDImisc.c @@ -0,0 +1,152 @@ +#include <jni.h> +#include <stdlib.h> +#include <assert.h> + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#undef WIN32_LEAN_AND_MEAN + +#include <wingdi.h> +#include <stddef.h> + +#ifdef _WIN32 + #ifdef _MSC_VER + /* This typedef is apparently needed for Microsoft compilers before VC8, + and on Windows CE */ + #if (_MSC_VER < 1400) || defined(UNDER_CE) + #ifdef _WIN64 + typedef long long intptr_t; + #else + typedef int intptr_t; + #endif + #endif + #else + #include <inttypes.h> + #endif +#else + #include <inttypes.h> +#endif + +#include <stdio.h> + +#include "com_jogamp_nativewindow_impl_windows_GDI.h" + +// #define VERBOSE_ON 1 + +#ifdef VERBOSE_ON + #define DBG_PRINT(args...) fprintf(stderr, args); +#else + #define DBG_PRINT(args...) +#endif + +static void _FatalError(JNIEnv *env, const char* msg, ...) +{ + char buffer[512]; + va_list ap; + + va_start(ap, msg); + vsnprintf(buffer, sizeof(buffer), msg, ap); + va_end(ap); + + fprintf(stderr, "%s\n", buffer); + (*env)->FatalError(env, buffer); +} + +static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point"; +static const char * const ClazzAnyCstrName = "<init>"; +static const char * const ClazzNamePointCstrSignature = "(II)V"; + +static jclass pointClz = NULL; +static jmethodID pointCstr = NULL; + +#define NATIVEWINDOW_DUMMY_WINDOW_NAME "__nativewindow_dummy_window" +static ATOM nativewindowClass = 0; + +LRESULT CALLBACK DummyWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + return DefWindowProc(hWnd,uMsg,wParam,lParam); +} + +HWND CreateDummyWindow(HINSTANCE hInstance, int x, int y, int width, int height ) { + DWORD dwExStyle; + DWORD dwStyle; + HWND hWnd; + + dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; + dwStyle = WS_OVERLAPPEDWINDOW; + if( !(hWnd=CreateWindowEx( dwExStyle, + NATIVEWINDOW_DUMMY_WINDOW_NAME, + NATIVEWINDOW_DUMMY_WINDOW_NAME, + dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + x, y, width, height, + NULL, NULL, hInstance, NULL ) ) ) { + return( 0 ); + } + return( hWnd ); +} + +/* + * Class: com_jogamp_nativewindow_impl_windows_GDI + * Method: initIDs0 + * Signature: ()Z + */ +JNIEXPORT jlong JNICALL Java_com_jogamp_nativewindow_impl_windows_GDI_initIDs0 + (JNIEnv *env, jclass clazz) +{ + if(NULL==pointClz) { + jclass c = (*env)->FindClass(env, ClazzNamePoint); + if(NULL==c) { + _FatalError(env, "FatalError com_jogamp_nativewindow_impl_windows_GDI: can't find %s", ClazzNamePoint); + } + pointClz = (jclass)(*env)->NewGlobalRef(env, c); + (*env)->DeleteLocalRef(env, c); + if(NULL==pointClz) { + _FatalError(env, "FatalError com_jogamp_nativewindow_impl_windows_GDI: can't use %s", ClazzNamePoint); + } + pointCstr = (*env)->GetMethodID(env, pointClz, ClazzAnyCstrName, ClazzNamePointCstrSignature); + if(NULL==pointCstr) { + _FatalError(env, "FatalError com_jogamp_nativewindow_impl_windows_GDI: can't fetch %s.%s %s", + ClazzNamePoint, ClazzAnyCstrName, ClazzNamePointCstrSignature); + } + } + HINSTANCE hInstance = GetModuleHandle(NULL); + if( !nativewindowClass ) { + WNDCLASS wc; + ZeroMemory( &wc, sizeof( wc ) ); + wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wc.lpfnWndProc = (WNDPROC) DummyWndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hIcon = NULL; + wc.hCursor = NULL; + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = NATIVEWINDOW_DUMMY_WINDOW_NAME; + if( !(nativewindowClass = RegisterClass( &wc )) ) { + _FatalError(env, "FatalError com_jogamp_nativewindow_impl_windows_GDI: RegisterClass Failed: %d", GetLastError() ); + } + } + return (jlong) hInstance; +} + +/* + * Class: com_jogamp_nativewindow_impl_windows_GDI + * Method: GetRelativeLocation0 + * Signature: (JJII)Ljavax/media/nativewindow/util/Point; + */ +JNIEXPORT jobject JNICALL Java_com_jogamp_nativewindow_impl_windows_GDI_GetRelativeLocation0 + (JNIEnv *env, jclass unused, jlong jsrc_win, jlong jdest_win, jint src_x, jint src_y) +{ + HWND src_win = (HWND) (intptr_t) jsrc_win; + HWND dest_win = (HWND) (intptr_t) jdest_win; + POINT dest = { src_x, src_y } ; + int res; + + res = MapWindowPoints(src_win, dest_win, &dest, 1); + + DBG_PRINT("*** WindowsWindow: getRelativeLocation0: %p %d/%d -> %p %d/%d - ok: %d\n", + (void*)src_win, src_x, src_y, (void*)dest_win, (int)dest.x, (int)dest.y, res); + + return (*env)->NewObject(env, pointClz, pointCstr, (jint)dest.x, (jint)dest.y); +} + diff --git a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java index daa09b034..1691e4bf0 100644 --- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java +++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java @@ -34,6 +34,7 @@ package com.jogamp.newt.impl.windows; +import com.jogamp.nativewindow.impl.windows.GDI; import javax.media.nativewindow.*; import com.jogamp.newt.impl.WindowImpl; import javax.media.nativewindow.util.Insets; @@ -168,7 +169,7 @@ public class WindowsWindow extends WindowImpl { } protected Point getLocationOnScreenImpl(int x, int y) { - return (Point) getRelativeLocation0( getWindowHandle(), 0 /*root win*/, x, y); + return (Point) GDI.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y); } //---------------------------------------------------------------------- @@ -190,7 +191,6 @@ public class WindowsWindow extends WindowImpl { boolean parentChange, int fullScreenChange, int decorationChange); private static native void setTitle0(long windowHandle, String title); private native void requestFocus0(long windowHandle, boolean force); - private native Object getRelativeLocation0(long src_win, long dest_win, int src_x, int src_y); private void insetsChanged(int left, int top, int right, int bottom) { if (left != -1 && top != -1 && right != -1 && bottom != -1) { diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 46d710eda..b282ec9b2 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -118,13 +118,6 @@ #define STD_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr) -static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point"; -static const char * const ClazzAnyCstrName = "<init>"; -static const char * const ClazzNamePointCstrSignature = "(II)V"; - -static jclass pointClz = NULL; -static jmethodID pointCstr = NULL; - static jmethodID insetsChangedID = NULL; static jmethodID sizeChangedID = NULL; static jmethodID positionChangedID = NULL; @@ -1333,23 +1326,6 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initI { NewtCommon_init(env); - if(NULL==pointClz) { - jclass c = (*env)->FindClass(env, ClazzNamePoint); - if(NULL==c) { - NewtCommon_FatalError(env, "NEWT WindowsWindows: can't find %s", ClazzNamePoint); - } - pointClz = (jclass)(*env)->NewGlobalRef(env, c); - (*env)->DeleteLocalRef(env, c); - if(NULL==pointClz) { - NewtCommon_FatalError(env, "NEWT WindowsWindows: can't use %s", ClazzNamePoint); - } - pointCstr = (*env)->GetMethodID(env, pointClz, ClazzAnyCstrName, ClazzNamePointCstrSignature); - if(NULL==pointCstr) { - NewtCommon_FatalError(env, "NEWT WindowsWindows: can't fetch %s.%s %s", - ClazzNamePoint, ClazzAnyCstrName, ClazzNamePointCstrSignature); - } - } - insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(IIII)V"); sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(IIZ)V"); positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(II)V"); @@ -1708,24 +1684,4 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_requestFo NewtWindows_requestFocus ( env, obj, (HWND) (intptr_t) window, force) ; } -/* - * Class: com_jogamp_newt_impl_windows_WindowsWindows - * Method: getRelativeLocation0 - * Signature: (JJII)Ljavax/media/nativewindow/util/Point; - */ -JNIEXPORT jobject JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_getRelativeLocation0 - (JNIEnv *env, jobject obj, jlong jsrc_win, jlong jdest_win, jint src_x, jint src_y) -{ - HWND src_win = (HWND) (intptr_t) jsrc_win; - HWND dest_win = (HWND) (intptr_t) jdest_win; - POINT dest = { src_x, src_y } ; - int res; - - res = MapWindowPoints(src_win, dest_win, &dest, 1); - - DBG_PRINT("*** WindowsWindow: getRelativeLocation0: %p %d/%d -> %p %d/%d - ok: %d\n", - (void*)src_win, src_x, src_y, (void*)dest_win, (int)dest.x, (int)dest.y, res); - - return (*env)->NewObject(env, pointClz, pointCstr, (jint)dest.x, (jint)dest.y); -} |