aboutsummaryrefslogtreecommitdiffstats
path: root/netx
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-01-31 10:19:48 +0100
committerSven Gothel <[email protected]>2014-01-31 10:19:48 +0100
commitf826663e9609b73783deea475872646242c8abb9 (patch)
tree64f60a686ffae66753bb62b7b135964e9b2fcc83 /netx
parentf5a0517ac704b36e3d94aa3d5547ddf95889ab95 (diff)
ITW NPP: Pass window position through all layers, added as 'xpos' and 'ypos' in message and parameters ; ...
- Relative position of window maybe important in regards to overlapping applet windows as well as for an upcoming OSX support. However, client may still need to calculate the location on screen. - Applet3Panel added toString() - Applet3Panel, PluginApplet3Viewer: Better naming for browser notification - appletResize -> browserSizeChanged, etc
Diffstat (limited to 'netx')
-rw-r--r--netx/com/jogamp/plugin/ui/NativeWindowDownstream.java5
-rw-r--r--netx/com/jogamp/plugin/ui/NativeWindowUpstream.java14
-rw-r--r--netx/jogamp/applet/Applet3Panel.java103
-rw-r--r--netx/jogamp/plugin/jnlp/NetxApplet3Panel.java4
-rw-r--r--netx/net/sourceforge/jnlp/PluginParameters.java31
5 files changed, 121 insertions, 36 deletions
diff --git a/netx/com/jogamp/plugin/ui/NativeWindowDownstream.java b/netx/com/jogamp/plugin/ui/NativeWindowDownstream.java
index 0846505..bed433b 100644
--- a/netx/com/jogamp/plugin/ui/NativeWindowDownstream.java
+++ b/netx/com/jogamp/plugin/ui/NativeWindowDownstream.java
@@ -78,4 +78,9 @@ public interface NativeWindowDownstream {
* </p>
*/
public void display();
+
+ /**
+ * Notify applet that the plugin's window has changed it's position.
+ */
+ void notifyPositionChanged(NativeWindowUpstream nw);
}
diff --git a/netx/com/jogamp/plugin/ui/NativeWindowUpstream.java b/netx/com/jogamp/plugin/ui/NativeWindowUpstream.java
index ccd42e0..942b509 100644
--- a/netx/com/jogamp/plugin/ui/NativeWindowUpstream.java
+++ b/netx/com/jogamp/plugin/ui/NativeWindowUpstream.java
@@ -57,6 +57,20 @@ public interface NativeWindowUpstream {
public long getWindowHandle();
/**
+ * @return the current x position of the top-left corner
+ * of the client area relative to it's parent.
+ * Since the position reflects the client area, it does not include the insets.
+ */
+ int getX();
+
+ /**
+ * @return the current y position of the top-left corner
+ * of the client area relative to it's parent.
+ * Since the position reflects the client area, it does not include the insets.
+ */
+ int getY();
+
+ /**
* Returns the width of the client area excluding insets (window decorations).
* @return width of the client area
*/
diff --git a/netx/jogamp/applet/Applet3Panel.java b/netx/jogamp/applet/Applet3Panel.java
index 5acad4d..27bb305 100644
--- a/netx/jogamp/applet/Applet3Panel.java
+++ b/netx/jogamp/applet/Applet3Panel.java
@@ -97,7 +97,7 @@ public abstract class Applet3Panel implements Applet3Context, Runnable {
*/
private NativeWindowDownstream appletWindow;
- private final MyNativeWindow parentWindow;
+ private final MyNativeWindow browserWindow;
/**
* Applet will allow initialization. Should be
@@ -172,6 +172,11 @@ public abstract class Applet3Panel implements Applet3Context, Runnable {
*/
int[] currentAppletSize = { 10, 10 };
+ /**
+ * The current applet position.
+ */
+ int[] currentAppletPos = { 0, 0 };
+
MessageUtils mu = new MessageUtils();
/**
@@ -214,10 +219,12 @@ public abstract class Applet3Panel implements Applet3Context, Runnable {
public abstract ClassLoader getAppletClassLoader();
- public Applet3Panel(long nativeWindowHandle, int width, int height, URL documentURL, Hashtable<String, String> parameters) {
+ public Applet3Panel(long nativeWindowHandle, int xpos, int ypos, int width, int height, URL documentURL, Hashtable<String, String> parameters) {
this.documentURL = documentURL;
this.parameters = parameters;
this.updateSizeInParameters(width, height);
+ this.currentAppletPos[0] = xpos;
+ this.currentAppletPos[1] = ypos;
this.currentAppletSize[0] = width;
this.currentAppletSize[1] = height;
{
@@ -249,7 +256,7 @@ public abstract class Applet3Panel implements Applet3Context, Runnable {
}
baseURL = _baseURL;
}
- this.parentWindow = new MyNativeWindow(nativeWindowHandle);
+ this.browserWindow = new MyNativeWindow(nativeWindowHandle);
}
class MyNativeWindow implements NativeWindowUpstream {
final long handle;
@@ -269,6 +276,16 @@ public abstract class Applet3Panel implements Applet3Context, Runnable {
}
@Override
+ public final int getX() {
+ return Applet3Panel.this.getX();
+ }
+
+ @Override
+ public final int getY() {
+ return Applet3Panel.this.getY();
+ }
+
+ @Override
public final long getWindowHandle() {
return this.handle;
}
@@ -287,6 +304,10 @@ public abstract class Applet3Panel implements Applet3Context, Runnable {
public final void notifySurfaceUpdated(NativeWindowDownstream swappedWin) {
// TODO: May hook for composite extension
}
+ @Override
+ public final String toString() {
+ return "PluginWin[0x"+Long.toHexString(handle)+", "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+"]";
+ }
};
public void destroy(boolean notifyApplet, boolean notifyUser) throws java.security.AccessControlException {
@@ -320,7 +341,7 @@ public abstract class Applet3Panel implements Applet3Context, Runnable {
return appletWindow;
}
public MyNativeWindow getBrowserWindow() {
- return parentWindow;
+ return browserWindow;
}
public int getStatus() { return status; }
@@ -355,7 +376,7 @@ public abstract class Applet3Panel implements Applet3Context, Runnable {
}
@Override
- public final URL getDocumentBase() { // TODO
+ public final URL getDocumentBase() {
return documentURL;
}
@@ -364,29 +385,17 @@ public abstract class Applet3Panel implements Applet3Context, Runnable {
return baseURL;
}
- public void updateSizeInParameters(int width, int height) {
+ private void updateSizeInParameters(int width, int height) {
parameters.put("width", Integer.toString(width));
parameters.put("height", Integer.toString(height));
}
+ private void updatePosInParameters(int x, int y) {
+ parameters.put("xpos", Integer.toString(x));
+ parameters.put("ypos", Integer.toString(y));
+ }
@Override
public void resize(int width, int height) {
- appletResize(width, height);
- }
-
- /**
- * Called when the applet wants to be resized.
- *
- * @param width the new requested width for the applet.
- * @param height the new requested height for the applet.
- */
- public void appletResize(int width, int height) {
- updateSizeInParameters(width, height);
- currentAppletSize[0] = width;
- currentAppletSize[1] = height;
- if( null != appletWindow ) {
- appletWindow.setSize(width, height);
- }
/** FIXME
if(loader != null) {
App3Context appCtxt = loader.getAppContext();
@@ -406,6 +415,31 @@ public abstract class Applet3Panel implements Applet3Context, Runnable {
}
}));
} */
+ browserSizeChanged(width, height);
+ }
+
+ /**
+ * Called when the applet needs to be resized.
+ */
+ public void browserSizeChanged(int width, int height) {
+ updateSizeInParameters(width, height);
+ currentAppletSize[0] = width;
+ currentAppletSize[1] = height;
+ if( null != appletWindow ) {
+ appletWindow.setSize(width, height);
+ }
+ }
+
+ /**
+ * Called when the applet needs to be informed about about position change.
+ */
+ public void browserPositionChanged(int x, int y) {
+ updatePosInParameters(x, y);
+ currentAppletPos[0] = y;
+ currentAppletPos[1] = y;
+ if( null != appletWindow ) {
+ appletWindow.notifyPositionChanged(browserWindow);
+ }
}
@Override
@@ -451,6 +485,12 @@ public abstract class Applet3Panel implements Applet3Context, Runnable {
//
// Internal Impl.
//
+ @Override
+ public String toString() {
+ return getClass().getSimpleName()+"@"+Integer.toHexString(hashCode())+
+ "["+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+
+ ", "+getCode()+" @ "+getCodeBase()+", doc "+getDocumentBase()+"]";
+ }
/**
* Get the code parameter
@@ -492,6 +532,21 @@ public abstract class Applet3Panel implements Applet3Context, Runnable {
}
/**
+ * Get the x-pos.
+ */
+ public final int getX() {
+ return currentAppletPos[0];
+ }
+
+
+ /**
+ * Get the y-pos.
+ */
+ public final int getY() {
+ return currentAppletPos[1];
+ }
+
+ /**
* Get the width.
*/
public final int getWidth() {
@@ -812,8 +867,8 @@ public abstract class Applet3Panel implements Applet3Context, Runnable {
break;
}
if( null == appletWindow ) {
- appletWindow = applet.createNativeWindow(this, parentWindow);
- if( parentWindow != appletWindow.getParent() ) {
+ appletWindow = applet.createNativeWindow(this, browserWindow);
+ if( browserWindow != appletWindow.getParent() ) {
throw new IllegalArgumentException("Applet's parent doesn't match!");
}
// FIXME loader.getAppContext().registerAppletWindow(appletWindow);
diff --git a/netx/jogamp/plugin/jnlp/NetxApplet3Panel.java b/netx/jogamp/plugin/jnlp/NetxApplet3Panel.java
index 0d79911..c9f0dd1 100644
--- a/netx/jogamp/plugin/jnlp/NetxApplet3Panel.java
+++ b/netx/jogamp/plugin/jnlp/NetxApplet3Panel.java
@@ -73,8 +73,8 @@ public class NetxApplet3Panel extends Applet3Panel implements SplashController {
private static final ConcurrentMap<String, Boolean> appContextCreated =
new ConcurrentHashMap<String, Boolean>();
- public NetxApplet3Panel(long nativeWindowHandle, int width, int height, URL documentURL, PluginParameters params) {
- super(nativeWindowHandle, width, height, documentURL, params.getUnderlyingHashtable());
+ public NetxApplet3Panel(long nativeWindowHandle, int xpos, int ypos, int width, int height, URL documentURL, PluginParameters params) {
+ super(nativeWindowHandle, xpos, ypos, width, height, documentURL, params.getUnderlyingHashtable());
this.pluginParameters = params;
this.initialized = false;
diff --git a/netx/net/sourceforge/jnlp/PluginParameters.java b/netx/net/sourceforge/jnlp/PluginParameters.java
index c3a958c..99e01c4 100644
--- a/netx/net/sourceforge/jnlp/PluginParameters.java
+++ b/netx/net/sourceforge/jnlp/PluginParameters.java
@@ -37,13 +37,13 @@ exception statement from your version. */
package net.sourceforge.jnlp;
+import static net.sourceforge.jnlp.runtime.Translator.R;
+
import java.net.URL;
import java.util.Collections;
import java.util.Hashtable;
import java.util.Map;
-import static net.sourceforge.jnlp.runtime.Translator.R;
-
/**
* Represents plugin applet parameters, backed by a Hashtable.
*/
@@ -77,7 +77,7 @@ public class PluginParameters {
/**
* Used for compatibility with Hashtable-expecting classes.
- *
+ *
* @return the underlying hashtable.
*/
public Hashtable<String, String> getUnderlyingHashtable() {
@@ -150,13 +150,23 @@ public class PluginParameters {
return getDefaulted("archive", "");
}
+ public int getX() {
+ final String yposStr = getDefaulted("xpos", "0");
+ return Integer.valueOf(yposStr);
+ }
+
+ public int getY() {
+ final String xposStr = getDefaulted("ypos", "0");
+ return Integer.valueOf(xposStr);
+ }
+
public int getWidth() {
- String widthStr = getDefaulted("width", "0");
+ final String widthStr = getDefaulted("width", "0");
return Integer.valueOf(widthStr);
}
public int getHeight() {
- String heightStr = getDefaulted("height", "0");
+ final String heightStr = getDefaulted("height", "0");
return Integer.valueOf(heightStr);
}
@@ -166,12 +176,12 @@ public class PluginParameters {
}
public String getUniqueKey(URL codebase) {
- /* According to http://download.oracle.com/javase/6/docs/technotes/guides/deployment/deployment-guide/applet-compatibility.html,
+ /* According to http://download.oracle.com/javase/6/docs/technotes/guides/deployment/deployment-guide/applet-compatibility.html,
* classloaders are shared iff these properties match:
* codebase, cache_archive, java_archive, archive
- *
+ *
* To achieve this, we create the uniquekey based on those 4 values,
- * always in the same order. The initial "<NAME>=" parts ensure a
+ * always in the same order. The initial "<NAME>=" parts ensure a
* bad tag cannot trick the loader into getting shared with another.
*/
return "codebase=" + codebase.toExternalForm() + "cache_archive="
@@ -180,7 +190,7 @@ public class PluginParameters {
}
/**
- * Replace an attribute with its 'java_'-prefixed version.
+ * Replace an attribute with its 'java_'-prefixed version.
* Note that java_* aliases override older names:
* http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/using_tags.html#in-nav
*/
@@ -195,7 +205,7 @@ public class PluginParameters {
/**
* Creates the underlying hash table with the proper overrides. Ensure all
* keys are lowercase consistently.
- *
+ *
* @param params
* the properties, before parameter aliasing rules.
* @return the resulting parameter table
@@ -236,6 +246,7 @@ public class PluginParameters {
return params;
}
+ @Override
public String toString() {
return parameters.toString();
}