summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java36
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/NewtFactory.java29
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Window.java21
-rw-r--r--src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java29
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/x11/X11Window.java10
-rwxr-xr-xsrc/newt/native/X11Window.c21
6 files changed, 115 insertions, 31 deletions
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java
index b13cf4317..d86fbdc55 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java
@@ -66,10 +66,23 @@ public final class NWReflection {
if (factoryClass == null) {
throw new NativeWindowException(clazzName + " not available");
}
+ return getConstructor(factoryClass, cstrArgTypes);
+ } catch (Throwable e) {
+ if (DEBUG) {
+ e.printStackTrace();
+ }
+ throw new NativeWindowException(e);
+ }
+ }
+
+ public static final Constructor getConstructor(Class clazz, Class[] cstrArgTypes) {
+ Constructor factory = null;
+
+ try {
try {
- factory = factoryClass.getDeclaredConstructor( cstrArgTypes );
+ factory = clazz.getDeclaredConstructor( cstrArgTypes );
} catch(NoSuchMethodException nsme) {
- throw new NativeWindowException("Constructor: '" + clazzName + "("+cstrArgTypes+")' not found");
+ throw new NativeWindowException("Constructor: '" + clazz + "("+cstrArgTypes+")' not found");
}
return factory;
} catch (Throwable e) {
@@ -84,6 +97,25 @@ public final class NWReflection {
return getConstructor(clazzName, new Class[0]);
}
+ public static final Object createInstance(Class clazz, Class[] cstrArgTypes, Object[] cstrArgs) {
+ Constructor factory = null;
+
+ try {
+ factory = getConstructor(clazz, cstrArgTypes);
+ return factory.newInstance( cstrArgs ) ;
+ } catch (Exception e) {
+ throw new NativeWindowException(e);
+ }
+ }
+
+ public static final Object createInstance(Class clazz, Object[] cstrArgs) {
+ Class[] cstrArgTypes = new Class[cstrArgs.length];
+ for(int i=0; i<cstrArgs.length; i++) {
+ cstrArgTypes[i] = cstrArgs[i].getClass();
+ }
+ return createInstance(clazz, cstrArgTypes, cstrArgs);
+ }
+
public static final Object createInstance(String clazzName, Class[] cstrArgTypes, Object[] cstrArgs) {
Constructor factory = null;
diff --git a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java b/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
index 8665aff6f..2f719110d 100755
--- a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
+++ b/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
@@ -80,26 +80,43 @@ public abstract class NewtFactory {
* Create a Window entity, incl native creation
*/
public static Window createWindow(Screen screen, Capabilities caps) {
- return Window.create(0, NativeWindowFactory.getNativeWindowType(true), screen, caps, false);
+ return Window.create(NativeWindowFactory.getNativeWindowType(true), 0, screen, caps, false);
}
public static Window createWindow(Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(0, NativeWindowFactory.getNativeWindowType(true), screen, caps, undecorated);
+ return Window.create(NativeWindowFactory.getNativeWindowType(true), 0, screen, caps, undecorated);
}
public static Window createWindow(long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(parentWindowHandle, NativeWindowFactory.getNativeWindowType(true), screen, caps, undecorated);
+ return Window.create(NativeWindowFactory.getNativeWindowType(true), parentWindowHandle, screen, caps, undecorated);
+ }
+
+ /**
+ * Ability to try a Window type with a construnctor argument, if supported ..<p>
+ * Currently only valid is <code> AWTWindow(Frame frame) </code>,
+ * to support an external created AWT Frame, ie the browsers embedded frame.
+ */
+ public static Window createWindow(Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(NativeWindowFactory.getNativeWindowType(true), cstrArguments, screen, caps, undecorated);
}
/**
* Create a Window entity using the given implementation type, incl native creation
*/
public static Window createWindow(String type, Screen screen, Capabilities caps) {
- return Window.create(0, type, screen, caps, false);
+ return Window.create(type, 0, screen, caps, false);
+ }
+
+ public static Window createWindow(String type, Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(type, 0, screen, caps, undecorated);
+ }
+
+ public static Window createWindow(String type, long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(type, parentWindowHandle, screen, caps, undecorated);
}
- public static Window createWindow(long parentWindowHandle, String type, Screen screen, Capabilities caps, boolean undecorated) {
- return Window.create(parentWindowHandle, type, screen, caps, undecorated);
+ public static Window createWindow(String type, Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) {
+ return Window.create(type, cstrArguments, screen, caps, undecorated);
}
/**
diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java
index 3321715c3..918e54e1f 100755
--- a/src/newt/classes/com/sun/javafx/newt/Window.java
+++ b/src/newt/classes/com/sun/javafx/newt/Window.java
@@ -34,7 +34,9 @@
package com.sun.javafx.newt;
import com.sun.javafx.newt.impl.Debug;
+
import javax.media.nativewindow.*;
+import com.sun.nativewindow.impl.NWReflection;
import java.util.ArrayList;
import java.util.Iterator;
@@ -82,7 +84,7 @@ public abstract class Window implements NativeWindow
return windowClass;
}
- protected static Window create(long parentWindowHandle, String type, Screen screen, Capabilities caps, boolean undecorated) {
+ protected static Window create(String type, long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) {
try {
Class windowClass = getWindowClass(type);
Window window = (Window) windowClass.newInstance();
@@ -97,6 +99,21 @@ public abstract class Window implements NativeWindow
}
}
+ protected static Window create(String type, Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) {
+ try {
+ Class windowClass = getWindowClass(type);
+ Window window = (Window) NWReflection.createInstance( windowClass, cstrArguments ) ;
+ window.invalidate();
+ window.screen = screen;
+ window.setUndecorated(undecorated);
+ window.createNative(0, caps);
+ return window;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw new NativeWindowException(t);
+ }
+ }
+
protected static Window wrapHandle(String type, Screen screen, AbstractGraphicsConfiguration config,
long windowHandle, boolean fullscreen, boolean visible,
int x, int y, int width, int height)
@@ -146,6 +163,8 @@ public abstract class Window implements NativeWindow
", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+
", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
", visible "+isVisible()+
+ ", undecorated "+undecorated+
+ ", fullscreen "+fullscreen+
", "+screen+
", wrappedWindow "+getWrappedWindow());
diff --git a/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java b/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java
index 1682181f5..c7f4d5e5d 100644
--- a/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java
@@ -58,11 +58,17 @@ import javax.media.nativewindow.awt.*;
public class AWTWindow extends Window {
public AWTWindow() {
+ this(null);
+ }
+
+ public AWTWindow(Frame frame) {
super();
title = "AWT NewtWindow";
+ this.frame = frame;
}
- private Frame frame;
+ private boolean owningFrame;
+ private Frame frame = null;
private AWTCanvas canvas;
// non fullscreen dimensions ..
private int nfs_width, nfs_height, nfs_x, nfs_y;
@@ -80,12 +86,21 @@ public class AWTWindow extends Window {
protected void createNative(long parentWindowHandle, final Capabilities caps) {
+ if(0!=parentWindowHandle) {
+ throw new RuntimeException("Window parenting not supported in AWT, use AWTWindow(Frame) cstr for wrapping instead");
+ }
+
final AWTWindow awtWindow = this;
runOnEDT(true, new Runnable() {
public void run() {
- frame = new Frame(getTitle());
- frame.setUndecorated(isUndecorated());
+ if(null==frame) {
+ frame = new Frame();
+ owningFrame=true;
+ } else {
+ owningFrame=false;
+ }
+ frame.setTitle(getTitle());
frame.setLayout(new BorderLayout());
canvas = new AWTCanvas(caps);
Listener listener = new Listener(awtWindow);
@@ -96,6 +111,7 @@ public class AWTWindow extends Window {
frame.add(canvas, BorderLayout.CENTER);
frame.setSize(width, height);
frame.setLocation(x, y);
+ frame.setUndecorated(undecorated||fullscreen);
frame.addComponentListener(new MoveListener(awtWindow));
frame.addWindowListener(new WindowEventListener(awtWindow));
}
@@ -105,7 +121,10 @@ public class AWTWindow extends Window {
protected void closeNative() {
runOnEDT(true, new Runnable() {
public void run() {
- frame.dispose();
+ if(owningFrame) {
+ frame.dispose();
+ owningFrame=false;
+ }
frame = null;
}
});
@@ -217,7 +236,7 @@ public class AWTWindow extends Window {
runOnEDT(false, new Runnable() {
public void run() {
if(!frame.isDisplayable()) {
- frame.setUndecorated(fullscreen);
+ frame.setUndecorated(undecorated||fullscreen);
} else {
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
System.err.println("AWTWindow can't undecorate already created frame");
diff --git a/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java b/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java
index 3d6104789..aaea78589 100755
--- a/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java
+++ b/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java
@@ -65,6 +65,7 @@ public class X11Window extends Window {
if (w == 0 || w!=windowHandle) {
throw new NativeWindowException("Error creating window: "+w);
}
+ this.parentWindowHandle = parentWindowHandle;
windowHandleClose = windowHandle;
displayHandleClose = display.getHandle();
}
@@ -102,7 +103,7 @@ public class X11Window extends Window {
nfs_width=width;
nfs_height=height;
}
- setSize0(getDisplayHandle(), getScreenIndex(), windowHandle, x, y, width, height, 0, visible);
+ setSize0(parentWindowHandle, getDisplayHandle(), getScreenIndex(), windowHandle, x, y, width, height, (undecorated||fullscreen)?-1:1, false);
}
public void setPosition(int x, int y) {
@@ -131,7 +132,7 @@ public class X11Window extends Window {
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
System.err.println("X11Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h);
}
- setSize0(getDisplayHandle(), getScreenIndex(), windowHandle, x, y, w, h, fullscreen?-1:1, visible);
+ setSize0(parentWindowHandle, getDisplayHandle(), getScreenIndex(), windowHandle, x, y, w, h, (undecorated||fullscreen)?-1:1, false);
}
return fullscreen;
}
@@ -145,8 +146,8 @@ public class X11Window extends Window {
long visualID, long javaObjectAtom, long windowDeleteAtom, int x, int y, int width, int height);
private native void CloseWindow(long display, long windowHandle, long javaObjectAtom);
private native void setVisible0(long display, long windowHandle, boolean visible);
- private native void setSize0(long display, int screen_index, long windowHandle,
- int x, int y, int width, int height, int decorationToggle, boolean isVisible);
+ private native void setSize0(long parentWindowHandle, long display, int screen_index, long windowHandle,
+ int x, int y, int width, int height, int decorationToggle, boolean setVisible);
private native void setPosition0(long display, long windowHandle, int x, int y);
private void sizeChanged(int newWidth, int newHeight) {
@@ -175,4 +176,5 @@ public class X11Window extends Window {
private long windowHandleClose;
private long displayHandleClose;
+ private long parentWindowHandle;
}
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index 1e7cd3bba..79457031f 100755
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -578,7 +578,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow
pVisualQuery=NULL;
}
- if(NULL==windowParent) {
+ if(0==windowParent) {
windowParent = XRootWindowOfScreen(scrn);
}
@@ -710,12 +710,12 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setVisible0
* Signature: (JIJIIIIIZ)V
*/
JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setSize0
- (JNIEnv *env, jobject obj, jlong display, jint screen_index, jlong window, jint x, jint y, jint width, jint height, jint decorationToggle, jboolean isVisible)
+ (JNIEnv *env, jobject obj, jlong jparent, jlong display, jint screen_index, jlong window, jint x, jint y, jint width, jint height, jint decorationToggle, jboolean setVisible)
{
Display * dpy = (Display *) (intptr_t) display;
Window w = (Window)window;
Screen * scrn = ScreenOfDisplay(dpy, (int)screen_index);
- Window parent = XRootWindowOfScreen(scrn);
+ Window parent = (0!=jparent)?(Window)jparent:XRootWindowOfScreen(scrn);
XWindowChanges xwc;
@@ -723,6 +723,11 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setSize0
XSync(dpy, False);
+ if(setVisible==JNI_TRUE) {
+ XMapRaised(dpy, w);
+ XSync(dpy, False);
+ }
+
if(0!=decorationToggle) {
#ifdef MWM_FULLSCREEN
unsigned long mwmhints[PROP_MWM_HINTS_ELEMENTS] = { 0, 0, 0, 0, 0 }; // flags, functions, decorations, input_mode, status
@@ -756,16 +761,6 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setSize0
XSync(dpy, False);
- /** if(isVisible==JNI_TRUE) {
- // this ..
- XSetInputFocus(dpy, w, RevertToNone, CurrentTime);
-
- // or this ..
- unsigned long wmleader[1] = { (unsigned long) w};
- Atom prop = XInternAtom( dpy, "WM_CLIENT_LEADER", False );
- XChangeProperty( dpy, w, prop, prop, 32, PropModeReplace, (unsigned char *)&wmleader, 1);
- } */
-
DBG_PRINT0( "setSize0 . sizeChangedID call\n");
(*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) width, (jint) height);
}