From 20221c8e77824068d4a54885f5c57ace1c9660a2 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 28 Nov 2011 12:51:15 -0800
Subject: [PATCH] EXP-1485 FIX -- Viewer should have a minimum size moved min
 size logic into LLWindow

---
 indra/llwindow/llwindow.cpp                | 25 +++++++-
 indra/llwindow/llwindow.h                  |  8 ++-
 indra/llwindow/llwindowheadless.h          |  2 +-
 indra/llwindow/llwindowmacosx.cpp          |  2 +-
 indra/llwindow/llwindowmacosx.h            |  2 +-
 indra/llwindow/llwindowmesaheadless.h      |  2 +-
 indra/llwindow/llwindowsdl.cpp             |  2 +-
 indra/llwindow/llwindowsdl.h               |  2 +-
 indra/llwindow/llwindowwin32.cpp           |  2 +-
 indra/llwindow/llwindowwin32.h             |  2 +-
 indra/newview/llappviewer.cpp              | 30 +++++-----
 indra/newview/llfloaterwindowsize.cpp      | 35 +----------
 indra/newview/llfloaterwindowsize.h        | 22 +++++--
 indra/newview/llviewerfloaterreg.cpp       |  2 +-
 indra/newview/llviewerprecompiledheaders.h |  3 +
 indra/newview/llviewerwindow.cpp           | 70 ++++++++++------------
 indra/newview/llviewerwindow.h             | 19 +++++-
 17 files changed, 125 insertions(+), 105 deletions(-)

diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp
index a313885ca3b..4919605afdf 100644
--- a/indra/llwindow/llwindow.cpp
+++ b/indra/llwindow/llwindow.cpp
@@ -111,8 +111,8 @@ LLWindow::LLWindow(LLWindowCallbacks* callbacks, BOOL fullscreen, U32 flags)
 	  mCursorHidden(FALSE),
 	  mBusyCount(0),
 	  mIsMouseClipping(FALSE),
-	  mMinWindowWidth(1024),		// just a sanity check - actual minimum size is stored in settings.xml
-	  mMinWindowHeight(768),
+	  mMinWindowWidth(S32_MAX),		// just a sanity check - actual minimum size is stored in settings.xml
+	  mMinWindowHeight(S32_MAX),
 	  mSwapMethod(SWAP_METHOD_UNDEFINED),
 	  mHideCursorPermanent(FALSE),
 	  mFlags(flags),
@@ -181,11 +181,32 @@ void *LLWindow::getMediaWindow()
 	return getPlatformWindow();
 }
 
+BOOL LLWindow::setSize(LLCoordScreen size)
+{
+	if (!getMaximized())
+	{
+		size.mX = llmin(size.mX, mMinWindowWidth);
+		size.mY = llmin(size.mY, mMinWindowHeight);
+	}
+	return setSizeImpl(size);
+}
+
+
 // virtual
 void LLWindow::setMinSize(U32 min_width, U32 min_height)
 {
 	mMinWindowWidth = min_width;
 	mMinWindowHeight = min_height;
+
+	LLCoordScreen cur_size;
+	if (!getMaximized() && getSize(&cur_size))
+	{
+		if (cur_size.mX < mMinWindowWidth || cur_size.mY < mMinWindowHeight)
+		{
+			setSizeImpl(LLCoordScreen(llmin(cur_size.mX, mMinWindowWidth), llmin(cur_size.mY, mMinWindowHeight)));
+		}
+	}
+
 }
 
 //virtual
diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h
index b2c2628ec4f..77a9e88287d 100644
--- a/indra/llwindow/llwindow.h
+++ b/indra/llwindow/llwindow.h
@@ -72,7 +72,7 @@ class LLWindow
 	virtual BOOL getSize(LLCoordScreen *size) = 0;
 	virtual BOOL getSize(LLCoordWindow *size) = 0;
 	virtual BOOL setPosition(LLCoordScreen position) = 0;
-	virtual BOOL setSize(LLCoordScreen size) = 0;
+	BOOL setSize(LLCoordScreen size);
 	virtual void setMinSize(U32 min_width, U32 min_height);
 	virtual BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL) = 0;
 	virtual BOOL setCursorPosition(LLCoordWindow position) = 0;
@@ -170,6 +170,8 @@ class LLWindow
 	// Defaults to true
 	virtual BOOL canDelete();
 
+	virtual BOOL setSizeImpl(LLCoordScreen size) = 0;
+
 protected:
 	LLWindowCallbacks*	mCallbacks;
 
@@ -189,8 +191,8 @@ class LLWindow
 	BOOL		mHideCursorPermanent;
 	U32			mFlags;
 	U16			mHighSurrogate;
-	U32			mMinWindowWidth;
-	U32			mMinWindowHeight;
+	S32			mMinWindowWidth;
+	S32			mMinWindowHeight;
 
  	// Handle a UTF-16 encoding unit received from keyboard.
  	// Converting the series of UTF-16 encoding units to UTF-32 data,
diff --git a/indra/llwindow/llwindowheadless.h b/indra/llwindow/llwindowheadless.h
index ac53e6a86ee..01f1d4fcd34 100644
--- a/indra/llwindow/llwindowheadless.h
+++ b/indra/llwindow/llwindowheadless.h
@@ -46,7 +46,7 @@ class LLWindowHeadless : public LLWindow
 	/*virtual*/ BOOL getSize(LLCoordScreen *size) {return FALSE;};
 	/*virtual*/ BOOL getSize(LLCoordWindow *size) {return FALSE;};
 	/*virtual*/ BOOL setPosition(LLCoordScreen position) {return FALSE;};
-	/*virtual*/ BOOL setSize(LLCoordScreen size) {return FALSE;};
+	/*virtual*/ BOOL setSizeImpl(LLCoordScreen size) {return FALSE;};
 	/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL) {return FALSE;};
 	/*virtual*/ BOOL setCursorPosition(LLCoordWindow position) {return FALSE;};
 	/*virtual*/ BOOL getCursorPosition(LLCoordWindow *position) {return FALSE;};
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index c48c3564b2a..505e20278d1 100644
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -1254,7 +1254,7 @@ BOOL LLWindowMacOSX::setPosition(const LLCoordScreen position)
 	return TRUE;
 }
 
-BOOL LLWindowMacOSX::setSize(const LLCoordScreen size)
+BOOL LLWindowMacOSX::setSizeImpl(const LLCoordScreen size)
 {
 	if(mWindow)
 	{
diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h
index 6c9e075a219..b3010cee24c 100644
--- a/indra/llwindow/llwindowmacosx.h
+++ b/indra/llwindow/llwindowmacosx.h
@@ -58,7 +58,7 @@ class LLWindowMacOSX : public LLWindow
 	/*virtual*/ BOOL getSize(LLCoordScreen *size);
 	/*virtual*/ BOOL getSize(LLCoordWindow *size);
 	/*virtual*/ BOOL setPosition(LLCoordScreen position);
-	/*virtual*/ BOOL setSize(LLCoordScreen size);
+	/*virtual*/ BOOL setSizeImpl(LLCoordScreen size);
 	/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL);
 	/*virtual*/ BOOL setCursorPosition(LLCoordWindow position);
 	/*virtual*/ BOOL getCursorPosition(LLCoordWindow *position);
diff --git a/indra/llwindow/llwindowmesaheadless.h b/indra/llwindow/llwindowmesaheadless.h
index fd4bd635e2e..45f96d2a0cc 100644
--- a/indra/llwindow/llwindowmesaheadless.h
+++ b/indra/llwindow/llwindowmesaheadless.h
@@ -50,7 +50,7 @@ class LLWindowMesaHeadless : public LLWindow
 	/*virtual*/ BOOL getSize(LLCoordScreen *size) {return FALSE;};
 	/*virtual*/ BOOL getSize(LLCoordWindow *size) {return FALSE;};
 	/*virtual*/ BOOL setPosition(LLCoordScreen position) {return FALSE;};
-	/*virtual*/ BOOL setSize(LLCoordScreen size) {return FALSE;};
+	/*virtual*/ BOOL setSizeImpl(LLCoordScreen size) {return FALSE;};
 	/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL) {return FALSE;};
 	/*virtual*/ BOOL setCursorPosition(LLCoordWindow position) {return FALSE;};
 	/*virtual*/ BOOL getCursorPosition(LLCoordWindow *position) {return FALSE;};
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index da2222ad512..c75b6c2dce2 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -966,7 +966,7 @@ BOOL LLWindowSDL::setPosition(const LLCoordScreen position)
 	return TRUE;
 }
 
-BOOL LLWindowSDL::setSize(const LLCoordScreen size)
+BOOL LLWindowSDL::setSizeImpl(const LLCoordScreen size)
 {
 	if(mWindow)
 	{
diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h
index fa544b16cef..03dbfc22e01 100644
--- a/indra/llwindow/llwindowsdl.h
+++ b/indra/llwindow/llwindowsdl.h
@@ -63,7 +63,7 @@ class LLWindowSDL : public LLWindow
 	/*virtual*/ BOOL getSize(LLCoordScreen *size);
 	/*virtual*/ BOOL getSize(LLCoordWindow *size);
 	/*virtual*/ BOOL setPosition(LLCoordScreen position);
-	/*virtual*/ BOOL setSize(LLCoordScreen size);
+	/*virtual*/ BOOL setSizeImpl(LLCoordScreen size);
 	/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL);
 	/*virtual*/ BOOL setCursorPosition(LLCoordWindow position);
 	/*virtual*/ BOOL getCursorPosition(LLCoordWindow *position);
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index 06360d261fc..34b1184cee8 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -861,7 +861,7 @@ BOOL LLWindowWin32::setPosition(const LLCoordScreen position)
 	return TRUE;
 }
 
-BOOL LLWindowWin32::setSize(const LLCoordScreen size)
+BOOL LLWindowWin32::setSizeImpl(const LLCoordScreen size)
 {
 	LLCoordScreen position;
 
diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h
index 387e4cbdb65..fa4a0ec1d35 100644
--- a/indra/llwindow/llwindowwin32.h
+++ b/indra/llwindow/llwindowwin32.h
@@ -57,7 +57,7 @@ class LLWindowWin32 : public LLWindow
 	/*virtual*/ BOOL getSize(LLCoordScreen *size);
 	/*virtual*/ BOOL getSize(LLCoordWindow *size);
 	/*virtual*/ BOOL setPosition(LLCoordScreen position);
-	/*virtual*/ BOOL setSize(LLCoordScreen size);
+	/*virtual*/ BOOL setSizeImpl(LLCoordScreen size);
 	/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL);
 	/*virtual*/ BOOL setCursorPosition(LLCoordWindow position);
 	/*virtual*/ BOOL getCursorPosition(LLCoordWindow *position);
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 9b8f5c59612..106b2727674 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -2861,22 +2861,20 @@ bool LLAppViewer::initWindow()
 	// always start windowed
 	BOOL ignorePixelDepth = gSavedSettings.getBOOL("IgnorePixelDepth");
 
-	// clamp to minimum window size
-	U32 min_window_width=gSavedSettings.getU32("MinWindowWidth");
-	U32 window_width=gSavedSettings.getU32("WindowWidth");
-	if ( window_width < min_window_width )
-		window_width=min_window_width;
-
-	U32 min_window_height=gSavedSettings.getU32("MinWindowHeight");
-	U32 window_height=gSavedSettings.getU32("WindowHeight");
-	if ( window_height < min_window_height )
-		window_height=min_window_height;
-
-	gViewerWindow = new LLViewerWindow(gWindowTitle, 
-		VIEWER_WINDOW_CLASSNAME,
-		gSavedSettings.getS32("WindowX"), gSavedSettings.getS32("WindowY"),
-		window_width, window_height,
-		gSavedSettings.getBOOL("WindowFullScreen"), ignorePixelDepth);
+	LLViewerWindow::Params window_params;
+	window_params
+		.title(gWindowTitle)
+		.name(VIEWER_WINDOW_CLASSNAME)
+		.x(gSavedSettings.getS32("WindowX"))
+		.y(gSavedSettings.getS32("WindowY"))
+		.width(gSavedSettings.getU32("WindowWidth"))
+		.height(gSavedSettings.getU32("WindowHeight"))
+		.min_width(gSavedSettings.getU32("MinWindowWidth"))
+		.min_height(gSavedSettings.getU32("MinWindowHeight"))
+		.fullscreen(gSavedSettings.getBOOL("WindowFullScreen"))
+		.ignore_pixel_depth(ignorePixelDepth);
+
+	gViewerWindow = new LLViewerWindow(window_params);
 
 	LL_INFOS("AppInit") << "gViewerwindow created." << LL_ENDL;
 
diff --git a/indra/newview/llfloaterwindowsize.cpp b/indra/newview/llfloaterwindowsize.cpp
index a70f2af11a1..ec161018b84 100644
--- a/indra/newview/llfloaterwindowsize.cpp
+++ b/indra/newview/llfloaterwindowsize.cpp
@@ -58,33 +58,12 @@ bool extractWindowSizeFromString(const std::string& instr, U32 *width, U32 *heig
 }
 
 
-///----------------------------------------------------------------------------
-/// Class LLFloaterWindowSize
-///----------------------------------------------------------------------------
-class LLFloaterWindowSize
-:	public LLFloater
-{
-	friend class LLFloaterReg;
-private:
-	LLFloaterWindowSize(const LLSD& key);
-	virtual ~LLFloaterWindowSize();
-
-public:
-	/*virtual*/ BOOL postBuild();
-	void initWindowSizeControls();
-	void onClickSet();
-	void onClickCancel();
-};
-
-
 LLFloaterWindowSize::LLFloaterWindowSize(const LLSD& key) 
 :	LLFloater(key)
-{
-}
+{}
 
 LLFloaterWindowSize::~LLFloaterWindowSize()
-{
-}
+{}
 
 BOOL LLFloaterWindowSize::postBuild()
 {
@@ -145,13 +124,3 @@ void LLFloaterWindowSize::onClickCancel()
 {
 	closeFloater();
 }
-
-///----------------------------------------------------------------------------
-/// LLFloaterWindowSizeUtil
-///----------------------------------------------------------------------------
-void LLFloaterWindowSizeUtil::registerFloater()
-{
-	LLFloaterReg::add("window_size", "floater_window_size.xml",
-		&LLFloaterReg::build<LLFloaterWindowSize>);
-
-}
diff --git a/indra/newview/llfloaterwindowsize.h b/indra/newview/llfloaterwindowsize.h
index 40f1a25bb3a..a71e5e273c9 100644
--- a/indra/newview/llfloaterwindowsize.h
+++ b/indra/newview/llfloaterwindowsize.h
@@ -26,10 +26,24 @@
 #ifndef LLFLOATERWINDOWSIZE_H
 #define LLFLOATERWINDOWSIZE_H
 
-// Allow user to set the window size for filming tutorials, machinima, etc
-namespace LLFloaterWindowSizeUtil
+#include "llfloater.h"
+
+///----------------------------------------------------------------------------
+/// Class LLFloaterWindowSize
+///----------------------------------------------------------------------------
+class LLFloaterWindowSize
+	:	public LLFloater
 {
-	void registerFloater();
-}
+	friend class LLFloaterReg;
+private:
+	LLFloaterWindowSize(const LLSD& key);
+	virtual ~LLFloaterWindowSize();
+
+public:
+	/*virtual*/ BOOL postBuild();
+	void initWindowSizeControls();
+	void onClickSet();
+	void onClickCancel();
+};
 
 #endif
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 0ec8cc1d4ea..acbc5f8fb6f 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -302,7 +302,7 @@ void LLViewerFloaterReg::registerFloaters()
 
 	LLFloaterReg::add("web_content", "floater_web_content.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);	
 	LLFloaterReg::add("whitelist_entry", "floater_whitelist_entry.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWhiteListEntry>);	
-	LLFloaterWindowSizeUtil::registerFloater();
+	LLFloaterReg::add("window_size", "floater_window_size.xml", &LLFloaterReg::build<LLFloaterWindowSize>);
 	LLFloaterReg::add("world_map", "floater_world_map.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWorldMap>);	
 
 	// *NOTE: Please keep these alphabetized for easier merges
diff --git a/indra/newview/llviewerprecompiledheaders.h b/indra/newview/llviewerprecompiledheaders.h
index 12f6a0dd1c6..f738b84bb9a 100644
--- a/indra/newview/llviewerprecompiledheaders.h
+++ b/indra/newview/llviewerprecompiledheaders.h
@@ -124,4 +124,7 @@
 // Library includes from llmessage project
 #include "llcachename.h"
 
+// Library includes from llxuixml
+#include "llinitparam.h"
+
 #endif
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 140cbb4e040..f24bab29a6d 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -838,6 +838,20 @@ void LLViewerWindow::updateDebugText()
 // LLViewerWindow
 //
 
+LLViewerWindow::Params::Params()
+:	title("title"),
+	name("name"),
+	x("x"),
+	y("y"),
+	width("width"),
+	height("height"),
+	min_width("min_width"),
+	min_height("min_height"),
+	fullscreen("fullscreen", false),
+	ignore_pixel_depth("ignore_pixel_depth", false)
+{}
+
+
 BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK mask, LLMouseHandler::EClickType clicktype, BOOL down)
 {
 	const char* buttonname = "";
@@ -1531,18 +1545,13 @@ std::string LLViewerWindow::translateString(const char* tag,
 //
 // Classes
 //
-LLViewerWindow::LLViewerWindow(
-	const std::string& title, const std::string& name,
-	S32 x, S32 y,
-	S32 width, S32 height,
-	BOOL fullscreen, BOOL ignore_pixel_depth) // fullscreen is no longer used
-	:
-	mWindow(NULL),
+LLViewerWindow::LLViewerWindow(const Params& p)
+:	mWindow(NULL),
 	mActive(true),
 	mUIVisible(true),
-	mWindowRectRaw(0, height, width, 0),
-	mWindowRectScaled(0, height, width, 0),
-	mWorldViewRectRaw(0, height, width, 0),
+	mWindowRectRaw(0, p.height, p.width, 0),
+	mWindowRectScaled(0, p.height, p.width, 0),
+	mWorldViewRectRaw(0, p.height, p.width, 0),
 	mLeftMouseDown(FALSE),
 	mMiddleMouseDown(FALSE),
 	mRightMouseDown(FALSE),
@@ -1578,12 +1587,12 @@ LLViewerWindow::LLViewerWindow(
 
 	// create window
 	mWindow = LLWindowManager::createWindow(this,
-		title, name, x, y, width, height, 0,
-		fullscreen, 
+		p.title, p.name, p.x, p.y, p.width, p.height, 0,
+		p.fullscreen, 
 		gHeadlessClient,
 		gSavedSettings.getBOOL("DisableVerticalSync"),
 		!gHeadlessClient,
-		ignore_pixel_depth,
+		p.ignore_pixel_depth,
 		gSavedSettings.getBOOL("RenderDeferred") ? 0 : gSavedSettings.getU32("RenderFSAASamples")); //don't use window level anti-aliasing if FBOs are enabled
 
 	if (NULL == mWindow)
@@ -1610,10 +1619,11 @@ LLViewerWindow::LLViewerWindow(
 		LL_WARNS("Window") << " Someone took over my signal/exception handler (post createWindow)!" << LL_ENDL;
 	}
 
+	mWindow->setMinSize(p.min_width, p.min_height);
 	LLCoordScreen scr;
     mWindow->getSize(&scr);
 
-    if(fullscreen && ( scr.mX!=width || scr.mY!=height))
+    if(p.fullscreen && ( scr.mX!=p.width || scr.mY!=p.height))
     {
 		llwarns << "Fullscreen has forced us in to a different resolution now using "<<scr.mX<<" x "<<scr.mY<<llendl;
 		gSavedSettings.setS32("FullScreenWidth",scr.mX);
@@ -2157,21 +2167,11 @@ void LLViewerWindow::reshape(S32 width, S32 height)
 		BOOL maximized = mWindow->getMaximized();
 		gSavedSettings.setBOOL("WindowMaximized", maximized);
 
-		LLCoordScreen window_size;
-		if (!maximized
-			&& mWindow->getSize(&window_size))
+		if (!maximized)
 		{
 			U32 min_window_width=gSavedSettings.getU32("MinWindowWidth");
-			if ( window_size.mX < min_window_width )
-				window_size.mX=min_window_width;
-			gSavedSettings.setU32("WindowWidth", window_size.mX);
-
 			U32 min_window_height=gSavedSettings.getU32("MinWindowHeight");
-			if ( window_size.mY < min_window_height )
-				window_size.mY=min_window_height;
-			gSavedSettings.setU32("WindowHeight", window_size.mY);
-
-			// tell the OS specific window code about min windoow size
+			// tell the OS specific window code about min window size
 			mWindow->setMinSize(min_window_width, min_window_height);
 		}
 
@@ -4099,25 +4099,21 @@ void LLViewerWindow::resetSnapshotLoc()
 	sSnapshotDir.clear();
 }
 
-static S32 BORDERHEIGHT = 0;
-static S32 BORDERWIDTH = 0;
-
 // static
 void LLViewerWindow::movieSize(S32 new_width, S32 new_height)
 {
-	LLCoordScreen size;
+	LLCoordWindow size;
 	gViewerWindow->getWindow()->getSize(&size);
-	if (  (size.mX != new_width + BORDERWIDTH)
-		||(size.mY != new_height + BORDERHEIGHT))
+	if ( size.mX != new_width
+		|| size.mY != new_height)
 	{
 		// use actual display dimensions, not virtual UI dimensions
 		S32 x = gViewerWindow->getWindowWidthRaw();
 		S32 y = gViewerWindow->getWindowHeightRaw();
-		BORDERWIDTH = size.mX - x;
-		BORDERHEIGHT = size.mY- y;
-		LLCoordScreen new_size(new_width + BORDERWIDTH, 
-							   new_height + BORDERHEIGHT);
-		gViewerWindow->getWindow()->setSize(new_size);
+		LLCoordWindow new_size(new_width, new_height);
+		LLCoordScreen screen_size;
+		gViewerWindow->getWindow()->convertCoords(new_size, &screen_size);
+		gViewerWindow->getWindow()->setSize(screen_size);
 	}
 }
 
diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h
index 0cb7f82b585..6efcaeaf18a 100644
--- a/indra/newview/llviewerwindow.h
+++ b/indra/newview/llviewerwindow.h
@@ -44,6 +44,7 @@
 #include "llstat.h"
 #include "llmousehandler.h"
 #include "llhandle.h"
+#include "llinitparam.h"
 
 #include <boost/function.hpp>
 #include <boost/signals2.hpp>
@@ -133,7 +134,23 @@ class LLViewerWindow : public LLWindowCallbacks
 	//
 	// CREATORS
 	//
-	LLViewerWindow(const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, BOOL fullscreen, BOOL ignore_pixel_depth);
+	struct Params : public LLInitParam::Block<Params>
+	{
+		Mandatory<std::string>		title,
+									name;
+		Mandatory<S32>				x,
+									y,
+									width,
+									height,
+									min_width,
+									min_height;
+		Optional<bool>				fullscreen,
+									ignore_pixel_depth;
+
+		Params();
+	};
+
+	LLViewerWindow(const Params& p);
 	virtual ~LLViewerWindow();
 
 	void			shutdownViews();
-- 
GitLab