diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java | 26 | ||||
-rw-r--r-- | src/com/vaadin/ui/Window.java | 49 |
2 files changed, 65 insertions, 10 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java b/src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java index 5f08f92cf0..31e09660fe 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java +++ b/src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java @@ -39,6 +39,10 @@ public class VRoot extends SimplePanel implements ResizeHandler, public static final String FRAGMENT_VARIABLE = "fragment"; + 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"; @@ -306,16 +310,18 @@ public class VRoot extends SimplePanel implements ResizeHandler, */ private void sendClientResized() { Element parentElement = getElement().getParentElement(); - int newViewHeight = parentElement.getClientHeight(); - int newViewWidth = 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); - } + int viewHeight = parentElement.getClientHeight(); + int viewWidth = parentElement.getClientWidth(); + + 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) diff --git a/src/com/vaadin/ui/Window.java b/src/com/vaadin/ui/Window.java index 3c17baf414..807b801155 100644 --- a/src/com/vaadin/ui/Window.java +++ b/src/com/vaadin/ui/Window.java @@ -83,6 +83,10 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, } }; + private int browserWindowWidth = -1; + + private int browserWindowHeight = -1; + /** * Creates a new unnamed window with a default layout. */ @@ -170,6 +174,20 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, .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); @@ -835,4 +853,35 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, return (WindowState) super.getState(); } + /** + * 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; + } } |