public class VView extends SimplePanel implements Container, ResizeHandler,
Window.ClosingHandler, ShortcutActionHandlerOwner, Focusable {
+ public static final String BROWSER_HEIGHT_VAR = "browserHeight";
+
+ public static final String BROWSER_WIDTH_VAR = "browserWidth";
+
private static final String CLASSNAME = "v-view";
public static final String NOTIFICATION_HTML_CONTENT_NOT_ALLOWED = "useplain";
private int windowWidth;
private int windowHeight;
- /*
- * Last know view size used to detect whether new dimensions should be sent
- * to the server.
- */
- private int viewWidth;
- private int viewHeight;
-
private ApplicationConnection connection;
/**
*/
private void sendClientResized() {
Element parentElement = getElement().getParentElement();
- int newViewHeight = parentElement.getClientHeight();
- int newViewWidth = parentElement.getClientWidth();
+ int viewHeight = parentElement.getClientHeight();
+ int viewWidth = parentElement.getClientWidth();
- // Send the view dimensions if they have changed
- if (newViewHeight != viewHeight || newViewWidth != viewWidth) {
- viewHeight = newViewHeight;
- viewWidth = newViewWidth;
- connection.updateVariable(id, "height", newViewHeight, false);
- connection.updateVariable(id, "width", newViewWidth, immediate);
- }
+ connection.updateVariable(id, "height", viewHeight, false);
+ connection.updateVariable(id, "width", viewWidth, false);
+
+ int windowWidth = Window.getClientWidth();
+ int windowHeight = Window.getClientHeight();
+
+ connection.updateVariable(id, BROWSER_WIDTH_VAR, windowWidth, false);
+ connection.updateVariable(id, BROWSER_HEIGHT_VAR, windowHeight,
+ immediate);
}
public native static void goTo(String url)
*/
private Component scrollIntoView;
+ private int browserWindowWidth = -1;
+
+ private int browserWindowHeight = -1;
+
/**
* Creates a new unnamed window with a default layout.
*/
.get("width") != getWidth())) {
sizeHasChanged = true;
}
+ Integer browserHeightVar = (Integer) variables
+ .get(VView.BROWSER_HEIGHT_VAR);
+ if (browserHeightVar != null
+ && browserHeightVar.intValue() != browserWindowHeight) {
+ browserWindowHeight = browserHeightVar.intValue();
+ sizeHasChanged = true;
+ }
+ Integer browserWidthVar = (Integer) variables
+ .get(VView.BROWSER_WIDTH_VAR);
+ if (browserWidthVar != null
+ && browserWidthVar.intValue() != browserWindowWidth) {
+ browserWindowWidth = browserWidthVar.intValue();
+ sizeHasChanged = true;
+ }
super.changeVariables(source, variables);
}
}
+ /**
+ * Gets the height of the viewport area of the browser window where this
+ * window is displayed.
+ *
+ * @return the browser viewport height in pixels
+ */
+ public int getBrowserWindowHeight() {
+ // Size only reported by VView -> data only available from application
+ // level window
+ if (getParent() != null) {
+ return (getParent()).getBrowserWindowHeight();
+ }
+
+ return browserWindowHeight;
+ }
+
+ /**
+ * Gets the width of the viewport area of the browser window where this
+ * window is displayed.
+ *
+ * @return the browser viewport width in pixels
+ */
+ public int getBrowserWindowWidth() {
+ // Size only reported by VView -> data only available from application
+ // level window
+ if (getParent() != null) {
+ return (getParent()).getBrowserWindowWidth();
+ }
+
+ return browserWindowWidth;
+ }
}
mainWindow.addListener(new Window.ResizeListener() {
public void windowResized(ResizeEvent e) {
Window window = e.getWindow();
- log.log("Resize event: " + window.getWidth() + " x "
- + window.getHeight());
+ log.log("App: " + window.getWidth() + " x "
+ + window.getHeight() + ", Browser window: "
+ + window.getBrowserWindowWidth() + " x "
+ + window.getBrowserWindowHeight());
}
});
}