aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/NWJNILibLoader.java5
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java68
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java5
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java17
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java24
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java10
-rw-r--r--src/nativewindow/native/windows/GDImisc.c152
-rw-r--r--src/nativewindow/native/x11/Xmisc.c76
8 files changed, 307 insertions, 50 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/NWJNILibLoader.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/NWJNILibLoader.java
index b1cd71386..3b2a728e5 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/NWJNILibLoader.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/NWJNILibLoader.java
@@ -29,13 +29,8 @@
package com.jogamp.nativewindow.impl;
-// FIXME: refactor Java SE dependencies
-//import java.awt.Toolkit;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.util.HashSet;
import com.jogamp.common.jvm.JNILibLoaderBase;
public class NWJNILibLoader extends JNILibLoaderBase {
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java
index 8ef2ba227..de6360212 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/JAWTWindow.java
@@ -41,7 +41,10 @@ import com.jogamp.common.util.locks.RecursiveLock;
import java.awt.Component;
import java.awt.Window;
-import javax.media.nativewindow.*;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.NativeWindow;
+import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.util.Point;
import javax.media.nativewindow.util.Rectangle;
@@ -64,12 +67,11 @@ public abstract class JAWTWindow implements NativeWindow {
init((Component)comp);
}
- protected void init(Component windowObject) throws NativeWindowException {
+ private final void init(Component windowObject) throws NativeWindowException {
invalidate();
this.component = windowObject;
validateNative();
}
-
protected abstract void validateNative() throws NativeWindowException;
protected synchronized void invalidate() {
@@ -78,7 +80,7 @@ public abstract class JAWTWindow implements NativeWindow {
bounds = new Rectangle();
}
- protected void updateBounds(JAWT_Rectangle jawtBounds) {
+ protected final void updateBounds(JAWT_Rectangle jawtBounds) {
bounds.setX(jawtBounds.getX());
bounds.setY(jawtBounds.getY());
bounds.setWidth(jawtBounds.getWidth());
@@ -86,9 +88,9 @@ public abstract class JAWTWindow implements NativeWindow {
}
/** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock */
- public Rectangle getBounds() { return bounds; }
+ public final Rectangle getBounds() { return bounds; }
- public Component getAWTComponent() {
+ public final Component getAWTComponent() {
return component;
}
@@ -96,7 +98,7 @@ public abstract class JAWTWindow implements NativeWindow {
// SurfaceUpdateListener
//
- public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+ public final void surfaceUpdated(Object updater, NativeSurface ns, long when) {
// nop
}
@@ -158,36 +160,36 @@ public abstract class JAWTWindow implements NativeWindow {
return recurLock.getOwner();
}
- public boolean surfaceSwap() {
+ public final boolean surfaceSwap() {
return false;
}
- public void surfaceUpdated(Object updater, NativeWindow window, long when) { }
+ public final void surfaceUpdated(Object updater, NativeWindow window, long when) { }
- public long getSurfaceHandle() {
+ public final long getSurfaceHandle() {
return drawable;
}
- public AbstractGraphicsConfiguration getGraphicsConfiguration() {
+ public final AbstractGraphicsConfiguration getGraphicsConfiguration() {
return config;
}
- public long getDisplayHandle() {
+ public final long getDisplayHandle() {
return config.getScreen().getDevice().getHandle();
}
- public int getScreenIndex() {
+ public final int getScreenIndex() {
return config.getScreen().getIndex();
}
- public void setSize(int width, int height) {
+ public final void setSize(int width, int height) {
component.setSize(width, height);
}
- public int getWidth() {
+ public final int getWidth() {
return component.getWidth();
}
- public int getHeight() {
+ public final int getHeight() {
return component.getHeight();
}
@@ -204,7 +206,7 @@ public abstract class JAWTWindow implements NativeWindow {
invalidate();
}
- public NativeWindow getParent() {
+ public final NativeWindow getParent() {
return null;
}
@@ -212,23 +214,45 @@ public abstract class JAWTWindow implements NativeWindow {
return drawable;
}
- public int getX() {
+ public final int getX() {
return component.getX();
}
- public int getY() {
+ public final int getY() {
return component.getY();
}
- public Point getLocationOnScreen(Point point) {
+ public Point getLocationOnScreen(Point storage) {
+ if( 0 != getWindowHandle() ) {
+ Point d;
+ // windowLock.lock();
+ try {
+ d = getLocationOnScreenImpl(0, 0);
+ } finally {
+ // windowLock.unlock();
+ }
+ if(null!=d) {
+ if(null!=storage) {
+ storage.translate(d.getX(),d.getY());
+ return storage;
+ }
+ return d;
+ }
+ // fall through intended ..
+ }
+
+ if(!Thread.holdsLock(component.getTreeLock())) {
+ return null; // avoid deadlock ..
+ }
java.awt.Point awtLOS = component.getLocationOnScreen();
int dx = (int) ( awtLOS.getX() + .5 ) ;
int dy = (int) ( awtLOS.getY() + .5 ) ;
- if(null!=point) {
- return point.translate(dx, dy);
+ if(null!=storage) {
+ return storage.translate(dx, dy);
}
return new Point(dx, dy);
}
+ protected abstract Point getLocationOnScreenImpl(int x, int y);
public String toString() {
StringBuffer sb = new StringBuffer();
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java
index bcaa66847..f511c7082 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java
@@ -47,6 +47,7 @@ import java.awt.GraphicsEnvironment;
import javax.media.nativewindow.*;
import java.security.*;
+import javax.media.nativewindow.util.Point;
public class MacOSXJAWTWindow extends JAWTWindow {
@@ -125,6 +126,10 @@ public class MacOSXJAWTWindow extends JAWTWindow {
macosxdsi = null;
}
+ protected Point getLocationOnScreenImpl(int x, int y) {
+ return null; // FIXME
+ }
+
// Variables for lockSurface/unlockSurface
private JAWT_DrawingSurface ds;
private boolean dsLocked;
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java
index d19a11f66..14d6eebcd 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java
@@ -40,10 +40,17 @@
package com.jogamp.nativewindow.impl.jawt.windows;
-import com.jogamp.nativewindow.impl.*;
-import com.jogamp.nativewindow.impl.jawt.*;
+import com.jogamp.nativewindow.impl.jawt.JAWT;
+import com.jogamp.nativewindow.impl.jawt.JAWTFactory;
+import com.jogamp.nativewindow.impl.jawt.JAWTWindow;
+import com.jogamp.nativewindow.impl.jawt.JAWT_DrawingSurface;
+import com.jogamp.nativewindow.impl.jawt.JAWT_DrawingSurfaceInfo;
+import com.jogamp.nativewindow.impl.windows.GDI;
-import javax.media.nativewindow.*;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.NativeWindow;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.util.Point;
public class WindowsJAWTWindow extends JAWTWindow {
@@ -152,6 +159,10 @@ public class WindowsJAWTWindow extends JAWTWindow {
return windowHandle;
}
+ protected Point getLocationOnScreenImpl(int x, int y) {
+ return GDI.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y);
+ }
+
// Variables for lockSurface/unlockSurface
private JAWT_DrawingSurface ds;
private boolean dsLocked;
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java
index a5d36b6dd..1324bd199 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/jawt/x11/X11JAWTWindow.java
@@ -37,12 +37,20 @@
package com.jogamp.nativewindow.impl.jawt.x11;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.awt.*;
-
-import com.jogamp.nativewindow.impl.x11.*;
-import com.jogamp.nativewindow.impl.jawt.*;
-
+import com.jogamp.nativewindow.impl.jawt.JAWT;
+import com.jogamp.nativewindow.impl.jawt.JAWTFactory;
+import com.jogamp.nativewindow.impl.jawt.JAWTWindow;
+import com.jogamp.nativewindow.impl.jawt.JAWT_DrawingSurface;
+import com.jogamp.nativewindow.impl.jawt.JAWT_DrawingSurfaceInfo;
+import com.jogamp.nativewindow.impl.x11.X11Util;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.NativeWindow;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.awt.AWTGraphicsDevice;
+import javax.media.nativewindow.util.Point;
public class X11JAWTWindow extends JAWTWindow {
@@ -134,6 +142,10 @@ public class X11JAWTWindow extends JAWTWindow {
x11dsi = null;
}
+ protected Point getLocationOnScreenImpl(int x, int y) {
+ return X11Util.GetRelativeLocation( getDisplayHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y);
+ }
+
// Variables for lockSurface/unlockSurface
private JAWT_DrawingSurface ds;
private boolean dsLocked;
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java
index f7f4828ca..bd76908a1 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java
@@ -44,6 +44,7 @@ import java.nio.ShortBuffer;
import java.security.AccessController;
import java.util.ArrayList;
import java.util.List;
+import javax.media.nativewindow.util.Point;
/**
* Contains a thread safe X11 utility to retrieve display connections.
@@ -517,6 +518,15 @@ public class X11Util {
}
}
+ public static Point GetRelativeLocation(long display, int screen_index, long src_win, long dest_win, int src_x, int src_y) {
+ lockDefaultToolkit(display);
+ try {
+ return X11Lib.GetRelativeLocation(display, screen_index, src_win, dest_win, src_x, src_y);
+ } finally {
+ unlockDefaultToolkit(display);
+ }
+ }
+
public static XVisualInfo[] XGetVisualInfo(long display, long arg1, XVisualInfo arg2, int[] arg3, int arg3_offset) {
lockDefaultToolkit(display);
try {
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/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c
index 0e91ae831..91292fd37 100644
--- a/src/nativewindow/native/x11/Xmisc.c
+++ b/src/nativewindow/native/x11/Xmisc.c
@@ -85,14 +85,9 @@ Bool XF86VidModeSetGammaRamp(
// #define VERBOSE_ON 1
#ifdef VERBOSE_ON
- // Workaround for ancient compiler on Solaris/SPARC
#define DBG_PRINT(args...) fprintf(stderr, args);
-
#else
-
- // Workaround for ancient compiler on Solaris/SPARC
#define DBG_PRINT(args...)
-
#endif
/* Need to pull this in as we don't have a stub header for it */
@@ -116,10 +111,15 @@ static const char * const ClazzNameBuffersStaticCstrName = "copyByteBuffer";
static const char * const ClazzNameBuffersStaticCstrSignature = "(Ljava/nio/ByteBuffer;)Ljava/nio/ByteBuffer;";
static const char * const ClazzNameByteBuffer = "java/nio/ByteBuffer";
static const char * const ClazzNameRuntimeException = "java/lang/RuntimeException";
+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 clazzBuffers = NULL;
static jmethodID cstrBuffers = NULL;
static jclass clazzByteBuffer = NULL;
static jclass clazzRuntimeException=NULL;
+static jclass pointClz = NULL;
+static jmethodID pointCstr = NULL;
static void _initClazzAccess(JNIEnv *env) {
jclass c;
@@ -128,39 +128,54 @@ static void _initClazzAccess(JNIEnv *env) {
c = (*env)->FindClass(env, ClazzNameRuntimeException);
if(NULL==c) {
- _FatalError(env, "Nativewindow X11Lib: can't find %s", ClazzNameRuntimeException);
+ _FatalError(env, "FatalError Java_com_jogamp_nativewindow_impl_x11_X11Lib: can't find %s", ClazzNameRuntimeException);
}
clazzRuntimeException = (jclass)(*env)->NewGlobalRef(env, c);
(*env)->DeleteLocalRef(env, c);
if(NULL==clazzRuntimeException) {
- _FatalError(env, "FatalError: NEWT X11Window: can't use %s", ClazzNameRuntimeException);
+ _FatalError(env, "FatalError Java_com_jogamp_nativewindow_impl_x11_X11Lib: can't use %s", ClazzNameRuntimeException);
}
c = (*env)->FindClass(env, ClazzNameBuffers);
if(NULL==c) {
- _FatalError(env, "FatalError: Java_com_jogamp_nativewindow_impl_x11_X11Lib: can't find %s", ClazzNameBuffers);
+ _FatalError(env, "FatalError Java_com_jogamp_nativewindow_impl_x11_X11Lib: can't find %s", ClazzNameBuffers);
}
clazzBuffers = (jclass)(*env)->NewGlobalRef(env, c);
(*env)->DeleteLocalRef(env, c);
if(NULL==clazzBuffers) {
- _FatalError(env, "FatalError: Java_com_jogamp_nativewindow_impl_x11_X11Lib: can't use %s", ClazzNameBuffers);
+ _FatalError(env, "FatalError Java_com_jogamp_nativewindow_impl_x11_X11Lib: can't use %s", ClazzNameBuffers);
}
c = (*env)->FindClass(env, ClazzNameByteBuffer);
if(NULL==c) {
- _FatalError(env, "FatalError: Java_com_jogamp_nativewindow_impl_x11_X11Lib: can't find %s", ClazzNameByteBuffer);
+ _FatalError(env, "FatalError Java_com_jogamp_nativewindow_impl_x11_X11Lib: can't find %s", ClazzNameByteBuffer);
}
clazzByteBuffer = (jclass)(*env)->NewGlobalRef(env, c);
(*env)->DeleteLocalRef(env, c);
if(NULL==c) {
- _FatalError(env, "FatalError: Java_com_jogamp_nativewindow_impl_x11_X11Lib: can't use %s", ClazzNameByteBuffer);
+ _FatalError(env, "FatalError Java_com_jogamp_nativewindow_impl_x11_X11Lib: can't use %s", ClazzNameByteBuffer);
}
cstrBuffers = (*env)->GetStaticMethodID(env, clazzBuffers,
ClazzNameBuffersStaticCstrName, ClazzNameBuffersStaticCstrSignature);
if(NULL==cstrBuffers) {
- _FatalError(env, "FatalError: Java_com_jogamp_nativewindow_impl_x11_X11Lib:: can't create %s.%s %s",
+ _FatalError(env, "FatalError Java_com_jogamp_nativewindow_impl_x11_X11Lib: can't create %s.%s %s",
ClazzNameBuffers, ClazzNameBuffersStaticCstrName, ClazzNameBuffersStaticCstrSignature);
}
+
+ c = (*env)->FindClass(env, ClazzNamePoint);
+ if(NULL==c) {
+ _FatalError(env, "FatalError Java_com_jogamp_nativewindow_impl_x11_X11Lib: can't find %s", ClazzNamePoint);
+ }
+ pointClz = (jclass)(*env)->NewGlobalRef(env, c);
+ (*env)->DeleteLocalRef(env, c);
+ if(NULL==pointClz) {
+ _FatalError(env, "FatalError Java_com_jogamp_nativewindow_impl_x11_X11Lib: can't use %s", ClazzNamePoint);
+ }
+ pointCstr = (*env)->GetMethodID(env, pointClz, ClazzAnyCstrName, ClazzNamePointCstrSignature);
+ if(NULL==pointCstr) {
+ _FatalError(env, "FatalError Java_com_jogamp_nativewindow_impl_x11_X11Lib: can't fetch %s.%s %s",
+ ClazzNamePoint, ClazzAnyCstrName, ClazzNamePointCstrSignature);
+ }
}
static void _throwNewRuntimeException(Display * unlockDisplay, JNIEnv *env, const char* msg, ...)
@@ -386,7 +401,7 @@ Java_com_jogamp_nativewindow_impl_x11_X11Lib_XCloseDisplay__J(JNIEnv *env, jclas
* Signature: (JIJ)J
*/
JNIEXPORT jlong JNICALL Java_com_jogamp_nativewindow_impl_x11_X11Lib_CreateDummyWindow
- (JNIEnv *env, jobject obj, jlong display, jint screen_index, jlong visualID)
+ (JNIEnv *env, jclass unused, jlong display, jint screen_index, jlong visualID)
{
Display * dpy = (Display *)(intptr_t)display;
int scrn_idx = (int)screen_index;
@@ -495,7 +510,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_nativewindow_impl_x11_X11Lib_CreateDummy
* Signature: (JJ)V
*/
JNIEXPORT void JNICALL Java_com_jogamp_nativewindow_impl_x11_X11Lib_DestroyDummyWindow
- (JNIEnv *env, jobject obj, jlong display, jlong window)
+ (JNIEnv *env, jclass unused, jlong display, jlong window)
{
Display * dpy = (Display *)(intptr_t)display;
Window w = (Window) window;
@@ -512,3 +527,36 @@ JNIEXPORT void JNICALL Java_com_jogamp_nativewindow_impl_x11_X11Lib_DestroyDummy
x11ErrorHandlerEnable(dpy, 0, env);
}
+/*
+ * Class: com_jogamp_nativewindow_impl_x11_X11Lib
+ * Method: GetRelativeLocation
+ * Signature: (JIJJII)Ljavax/media/nativewindow/util/Point;
+ */
+JNIEXPORT jobject JNICALL Java_com_jogamp_nativewindow_impl_x11_X11Lib_GetRelativeLocation0
+ (JNIEnv *env, jclass unused, jlong jdisplay, jint screen_index, jlong jsrc_win, jlong jdest_win, jint src_x, jint src_y)
+{
+ Display * dpy = (Display *) (intptr_t) jdisplay;
+ Screen * scrn = ScreenOfDisplay(dpy, (int)screen_index);
+ Window root = XRootWindowOfScreen(scrn);
+ Window src_win = (Window)jsrc_win;
+ Window dest_win = (Window)jdest_win;
+ int dest_x=-1;
+ int dest_y=-1;
+ Window child;
+ Bool res;
+
+ if( 0 == jdest_win ) { dest_win = root; }
+ if( 0 == jsrc_win ) { src_win = root; }
+
+ x11ErrorHandlerEnable(dpy, 1, env);
+
+ res = XTranslateCoordinates(dpy, src_win, dest_win, src_x, src_y, &dest_x, &dest_y, &child);
+
+ x11ErrorHandlerEnable(dpy, 0, env);
+
+ DBG_PRINT( "X11: GetRelativeLocation0: %p %d/%d -> %p %d/%d - ok: %d\n",
+ (void*)src_win, src_x, src_y, (void*)dest_win, dest_x, dest_y, (int)res);
+
+ return (*env)->NewObject(env, pointClz, pointCstr, (jint)dest_x, (jint)dest_y);
+}
+