diff options
author | Sven Gothel <[email protected]> | 2014-01-31 10:19:48 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-01-31 10:19:48 +0100 |
commit | f826663e9609b73783deea475872646242c8abb9 (patch) | |
tree | 64f60a686ffae66753bb62b7b135964e9b2fcc83 /plugin/icedteanp/java | |
parent | f5a0517ac704b36e3d94aa3d5547ddf95889ab95 (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 'plugin/icedteanp/java')
3 files changed, 109 insertions, 29 deletions
diff --git a/plugin/icedteanp/java/jogamp/plugin/applet/PluginApplet3PanelFactory.java b/plugin/icedteanp/java/jogamp/plugin/applet/PluginApplet3PanelFactory.java index 3d141a4..dc1098d 100644 --- a/plugin/icedteanp/java/jogamp/plugin/applet/PluginApplet3PanelFactory.java +++ b/plugin/icedteanp/java/jogamp/plugin/applet/PluginApplet3PanelFactory.java @@ -86,14 +86,16 @@ public class PluginApplet3PanelFactory { final long nativeWindowHandle, final URL doc, final PluginParameters params) { + final int xpos = params.getX(); + final int ypos = params.getY(); final int width = params.getWidth(); final int height = params.getHeight(); PluginDebug.debug("NativeWindow (Browser) Handle: 0x" + Long.toHexString(nativeWindowHandle)); - PluginDebug.debug("NativeWindow (Browser) Size: " + width + " x " + height); + PluginDebug.debug("NativeWindow (Browser) Pos: "+xpos+" / "+ypos+", size: " + width + " x " + height); final NetxApplet3Panel panel = AccessController.doPrivileged(new PrivilegedAction<NetxApplet3Panel>() { @Override public NetxApplet3Panel run() { - NetxApplet3Panel panel = new NetxApplet3Panel(nativeWindowHandle, width, height, doc, params); + NetxApplet3Panel panel = new NetxApplet3Panel(nativeWindowHandle, xpos, ypos, width, height, doc, params); NetxApplet3Panel.debug("Using NetX panel"); PluginDebug.debug(params.toString()); return panel; diff --git a/plugin/icedteanp/java/jogamp/plugin/applet/PluginApplet3Viewer.java b/plugin/icedteanp/java/jogamp/plugin/applet/PluginApplet3Viewer.java index a123baa..6db065d 100644 --- a/plugin/icedteanp/java/jogamp/plugin/applet/PluginApplet3Viewer.java +++ b/plugin/icedteanp/java/jogamp/plugin/applet/PluginApplet3Viewer.java @@ -360,7 +360,7 @@ public class PluginApplet3Viewer implements Applet3Context, SplashController { requestFactory = rf; } - private static void handleInitializationMessage(int identifier, String message) throws IOException, LaunchException { + private static void handleInitializationMessage(final int identifier, final String origMessage) throws IOException, LaunchException { /* The user has specified via a global setting that applets should not be run.*/ if (AppletStartupSecuritySettings.getInstance().getSecurityLevel() == AppletSecurityLevel.DENY_ALL) { @@ -374,9 +374,10 @@ public class PluginApplet3Viewer implements Applet3Context, SplashController { return; } + String message = origMessage; // Extract the information from the message - String[] msgParts = new String[4]; - for (int i = 0; i < 3; i++) { + String[] msgParts = new String[6]; + for (int i = 0; i < 5; i++) { int spaceLocation = message.indexOf(' '); int nextSpaceLocation = message.indexOf(' ', spaceLocation + 1); msgParts[i] = message.substring(spaceLocation + 1, nextSpaceLocation); @@ -384,14 +385,19 @@ public class PluginApplet3Viewer implements Applet3Context, SplashController { } final long nativeWindowHandle = Long.parseLong(msgParts[0]); - String width = msgParts[1]; - String height = msgParts[2]; + final String xpos = msgParts[1]; + final String ypos = msgParts[2]; + final String width = msgParts[3]; + final String height = msgParts[4]; int spaceLocation = message.indexOf(' ', "tag".length() + 1); String documentBase = message.substring("tag".length() + 1, spaceLocation); String paramString = message.substring(spaceLocation + 1); - PluginDebug.debug("Handle = 0x", Long.toHexString(nativeWindowHandle), "\n", + PluginDebug.debug("Message = <", origMessage, ">\n", + "handle = 0x", Long.toHexString(nativeWindowHandle), "\n", + "xpos = ", xpos, "\n", + "ypos = ", ypos, "\n", "Width = ", width, "\n", "Height = ", height, "\n", "DocumentBase = ", documentBase, "\n", @@ -406,7 +412,7 @@ public class PluginApplet3Viewer implements Applet3Context, SplashController { */ url = conn.getURL(); - PluginParameters params = new PluginParameterParser().parse(width, height, paramString); + PluginParameters params = new PluginParameterParser().parse(xpos, ypos, width, height, paramString); // Let user know we are starting up streamhandler.write("instance " + identifier + " status " + amh.getMessage("status.start")); @@ -612,28 +618,84 @@ public class PluginApplet3Viewer implements Applet3Context, SplashController { } public void handleMessage(int reference, String message) { - if (message.startsWith("width")) { + if (message.startsWith("set-sizepos")) { - // 0 => width, 1=> width_value, 2 => height, 3=> height_value - String[] dimMsg = message.split(" "); + // 0 => set-sizepos + // 1 => xpos, 2 => xpos_value, 3 => ypos, 4 => ypos_value + // 5 => width, 6 => width_value, 7 => height, 8 => height_value + final String[] dimMsg = message.split(" "); - final int width = Integer.parseInt(dimMsg[1]); - final int height = Integer.parseInt(dimMsg[3]); + final int xpos= Integer.parseInt(dimMsg[2]); + final int ypos= Integer.parseInt(dimMsg[4]); + final int width = Integer.parseInt(dimMsg[6]); + final int height = Integer.parseInt(dimMsg[8]); + + PluginDebug.debug("Applet panel ", panel, " set-sizepos ", xpos, " / ", ypos, width, " x ", height, " - ", message); + + /* Resize and reposition the applet asynchronously, to avoid the chance of + * deadlock while waiting for the applet to initialize. + * + * In general, worker threads should spawn new threads for any blocking operations. */ + final Thread resizeposAppletThread = new Thread("resizeposAppletThread") { + @Override + public void run() { + browserSizePosChanged(xpos, ypos, width, height); + } + }; + + /* Let it eventually complete */ + resizeposAppletThread.start(); + + } else if (message.startsWith("set-size")) { + + // 0 => set-size + // 1 => width, 2 => width_value, 3 => height, 4 => height_value + final String[] dimMsg = message.split(" "); + + final int width = Integer.parseInt(dimMsg[2]); + final int height = Integer.parseInt(dimMsg[4]); + + PluginDebug.debug("Applet panel ", panel, " set-size ", width, " x ", height, " - ", message); /* Resize the applet asynchronously, to avoid the chance of * deadlock while waiting for the applet to initialize. * * In general, worker threads should spawn new threads for any blocking operations. */ - Thread resizeAppletThread = new Thread("resizeAppletThread") { + final Thread resizeAppletThread = new Thread("resizeAppletThread") { @Override public void run() { - resize(width, height); + browserSizeChanged(width, height); } }; /* Let it eventually complete */ resizeAppletThread.start(); + } else if (message.startsWith("set-pos")) { + + // 0 => set-pos + // 1 => xpos, 2 => xpos_value, 3 => ypos, 4 => ypos_value + final String[] dimMsg = message.split(" "); + + final int xpos= Integer.parseInt(dimMsg[2]); + final int ypos= Integer.parseInt(dimMsg[4]); + + PluginDebug.debug("Applet panel ", panel, " set-size ", xpos, " / ", ypos, " - ", message); + + /* Reposition the applet asynchronously, to avoid the chance of + * deadlock while waiting for the applet to initialize. + * + * In general, worker threads should spawn new threads for any blocking operations. */ + final Thread reposAppletThread = new Thread("reposAppletThread") { + @Override + public void run() { + browserPositionChanged(xpos, ypos); + } + }; + + /* Let it eventually complete */ + reposAppletThread.start(); + } else if (message.startsWith("GetJavaObject")) { // FIXME: how do we determine what security context this @@ -765,19 +827,35 @@ public class PluginApplet3Viewer implements Applet3Context, SplashController { })); } */ - appletResize(width, height); + browserSizeChanged(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. + * Called when the applet needs to be resized. + */ + public void browserSizePosChanged(int x, int y, int width, int height) { + // Wait for panel to come alive + waitForAppletInit(panel); + panel.browserPositionChanged(x, y); + panel.browserSizeChanged(width, height); + } + + /** + * Called when the applet needs to be resized. + */ + public void browserSizeChanged(int width, int height) { + // Wait for panel to come alive + waitForAppletInit(panel); + panel.browserSizeChanged(width, height); + } + + /** + * Called when the applet needs to be informed about about position change. */ - public void appletResize(int width, int height) { + public void browserPositionChanged(int x, int y) { // Wait for panel to come alive waitForAppletInit(panel); - panel.appletResize(width, height); + panel.browserPositionChanged(x, y); } @Override diff --git a/plugin/icedteanp/java/sun/applet/PluginParameterParser.java b/plugin/icedteanp/java/sun/applet/PluginParameterParser.java index 56dabc9..51ffc9e 100644 --- a/plugin/icedteanp/java/sun/applet/PluginParameterParser.java +++ b/plugin/icedteanp/java/sun/applet/PluginParameterParser.java @@ -1,6 +1,5 @@ package sun.applet; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -69,16 +68,15 @@ public class PluginParameterParser { } /** - * Parsers parameters given a string containing + * Parsers parameters given a string containing * parameters in quotes. - * * @param width default applet width * @param height default applet height - * @param parameterString the parameters + * @param parameterString the parameters + * * @return the attributes in a hash table */ - public PluginParameters parse(String width, - String height, String parameterString) { + public PluginParameters parse(String xpos, String ypos, String width, String height, String parameterString) { Map<String, String> params = parseEscapedKeyValuePairs(parameterString); if (params.get("width") == null || !isInt(params.get("width"))) { @@ -88,6 +86,8 @@ public class PluginParameterParser { if (params.get("height") == null || !isInt(params.get("height"))) { params.put("height", height); } + params.put("xpos", xpos); + params.put("ypos", ypos); return new PluginParameters(params); } |