summaryrefslogtreecommitdiff
path: root/indra/llwindow
diff options
context:
space:
mode:
authorLeslie Linden <leslie@lindenlab.com>2011-11-29 10:40:45 -0800
committerLeslie Linden <leslie@lindenlab.com>2011-11-29 10:40:45 -0800
commite919349054c8ae80a054f047756e6596b58a3e13 (patch)
tree4d2abc589c448fe2b54f7be09385e644fd5b87af /indra/llwindow
parentec6893db5099b1e95802254277de0cc2e9bea83c (diff)
parentadeb71d98279fc4e8af7859cd36114be9f95e6da (diff)
Merge with viewer-experience
Diffstat (limited to 'indra/llwindow')
-rw-r--r--indra/llwindow/llwindow.cpp25
-rw-r--r--indra/llwindow/llwindow.h8
-rw-r--r--indra/llwindow/llwindowheadless.h2
-rw-r--r--indra/llwindow/llwindowmacosx.cpp2
-rw-r--r--indra/llwindow/llwindowmacosx.h2
-rw-r--r--indra/llwindow/llwindowmesaheadless.h2
-rw-r--r--indra/llwindow/llwindowsdl.cpp31
-rw-r--r--indra/llwindow/llwindowsdl.h3
-rw-r--r--indra/llwindow/llwindowwin32.cpp2
-rw-r--r--indra/llwindow/llwindowwin32.h2
10 files changed, 61 insertions, 18 deletions
diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp
index a313885ca3..4919605afd 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 b2c2628ec4..77a9e88287 100644
--- a/indra/llwindow/llwindow.h
+++ b/indra/llwindow/llwindow.h
@@ -72,7 +72,7 @@ public:
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 @@ protected:
// Defaults to true
virtual BOOL canDelete();
+ virtual BOOL setSizeImpl(LLCoordScreen size) = 0;
+
protected:
LLWindowCallbacks* mCallbacks;
@@ -189,8 +191,8 @@ protected:
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 ac53e6a86e..01f1d4fcd3 100644
--- a/indra/llwindow/llwindowheadless.h
+++ b/indra/llwindow/llwindowheadless.h
@@ -46,7 +46,7 @@ public:
/*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 c48c3564b2..505e20278d 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 6c9e075a21..b3010cee24 100644
--- a/indra/llwindow/llwindowmacosx.h
+++ b/indra/llwindow/llwindowmacosx.h
@@ -58,7 +58,7 @@ public:
/*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 fd4bd635e2..45f96d2a0c 100644
--- a/indra/llwindow/llwindowmesaheadless.h
+++ b/indra/llwindow/llwindowmesaheadless.h
@@ -50,7 +50,7 @@ public:
/*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 da2222ad51..a70791d39f 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -63,9 +63,6 @@ extern BOOL gDebugWindowProc;
const S32 MAX_NUM_RESOLUTIONS = 200;
-const S32 MIN_WINDOW_WIDTH = 1024;
-const S32 MIN_WINDOW_HEIGHT = 768;
-
// static variable for ATI mouse cursor crash work-around:
static bool ATIbug = false;
@@ -182,6 +179,20 @@ Display* LLWindowSDL::get_SDL_Display(void)
}
return NULL;
}
+
+void LLWindowSDL::setXWindowMinSize()
+{
+ // Set the minimum size limits for X11 window
+ // so the window manager doesn't allow resizing below those limits.
+ XSizeHints* hints = XAllocSizeHints();
+ hints->flags |= PMinSize;
+ hints->min_width = mMinWindowWidth;
+ hints->min_height = mMinWindowHeight;
+
+ XSetWMNormalHints(mSDL_Display, mSDL_XWindowID, hints);
+
+ XFree(hints);
+}
#endif // LL_X11
@@ -741,6 +752,8 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
mSDL_XWindowID = info.info.x11.wmwindow;
Lock_Display = info.info.x11.lock_func;
Unlock_Display = info.info.x11.unlock_func;
+
+ setXWindowMinSize();
}
else
{
@@ -966,7 +979,7 @@ BOOL LLWindowSDL::setPosition(const LLCoordScreen position)
return TRUE;
}
-BOOL LLWindowSDL::setSize(const LLCoordScreen size)
+BOOL LLWindowSDL::setSizeImpl(const LLCoordScreen size)
{
if(mWindow)
{
@@ -1850,8 +1863,8 @@ void LLWindowSDL::gatherInput()
llinfos << "Handling a resize event: " << event.resize.w <<
"x" << event.resize.h << llendl;
- S32 width = llmax(event.resize.w, MIN_WINDOW_WIDTH);
- S32 height = llmax(event.resize.h, MIN_WINDOW_HEIGHT);
+ S32 width = llmax(event.resize.w, (S32)mMinWindowWidth);
+ S32 height = llmax(event.resize.h, (S32)mMinWindowHeight);
// *FIX: I'm not sure this is necessary!
mWindow = SDL_SetVideoMode(width, height, 32, mSDLFlags);
@@ -1868,6 +1881,12 @@ void LLWindowSDL::gatherInput()
break;
}
+#if LL_X11
+ // The minimum size limits should be reset after
+ // each successful SDL_SetVideoMode() call.
+ setXWindowMinSize();
+#endif
+
mCallbacks->handleResize(this, width, height);
break;
}
diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h
index fa544b16ce..a98b1b74bd 100644
--- a/indra/llwindow/llwindowsdl.h
+++ b/indra/llwindow/llwindowsdl.h
@@ -63,7 +63,7 @@ public:
/*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);
@@ -140,6 +140,7 @@ public:
#if LL_X11
static Window get_SDL_XWindowID(void);
static Display* get_SDL_Display(void);
+ void setXWindowMinSize();
#endif // LL_X11
protected:
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index 06360d261f..34b1184cee 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 387e4cbdb6..fa4a0ec1d3 100644
--- a/indra/llwindow/llwindowwin32.h
+++ b/indra/llwindow/llwindowwin32.h
@@ -57,7 +57,7 @@ public:
/*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);