Clamp window width to twice the X screen width (ditto for height). b=409006 r+sr=roc

This commit is contained in:
Mats Palmgren 2008-07-02 13:09:15 +02:00
Родитель 45e2122519
Коммит fab38680f3
4 изменённых файлов: 31 добавлений и 4 удалений

Просмотреть файл

@ -204,8 +204,7 @@ nsCommonWidget::Show(PRBool aState)
NS_IMETHODIMP
nsCommonWidget::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
{
mBounds.width = aWidth;
mBounds.height = aHeight;
mBounds.SizeTo(GetSafeWindowSize(nsSize(aWidth, aHeight)));
if (!mCreated)
return NS_OK;
@ -278,8 +277,7 @@ nsCommonWidget::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight,
{
mBounds.x = aX;
mBounds.y = aY;
mBounds.width = aWidth;
mBounds.height = aHeight;
mBounds.SizeTo(GetSafeWindowSize(nsSize(aWidth, aHeight)));
mPlaced = PR_TRUE;

Просмотреть файл

@ -102,6 +102,8 @@ public:
virtual void NativeShow (PRBool aAction) = 0;
virtual nsSize GetSafeWindowSize(nsSize aSize) = 0;
// Some of the nsIWidget methods
NS_IMETHOD Show (PRBool aState);
NS_IMETHOD Resize (PRInt32 aWidth,

Просмотреть файл

@ -3572,6 +3572,32 @@ nsWindow::NativeShow (PRBool aAction)
}
}
nsSize
nsWindow::GetSafeWindowSize(nsSize aSize)
{
GdkScreen* screen = NULL;
if (mContainer) {
screen = gdk_drawable_get_screen(GTK_WIDGET(mContainer)->window);
}
else if (mDrawingarea) {
screen = gdk_drawable_get_screen(mDrawingarea->inner_window);
}
if (!screen)
return aSize;
nsSize result = aSize;
if (aSize.width > 2 * gdk_screen_get_width(screen)) {
NS_WARNING("Clamping huge window width");
result.width = 2 * gdk_screen_get_width(screen);
}
if (aSize.height > 2 * gdk_screen_get_height(screen)) {
NS_WARNING("Clamping huge window height");
result.height = 2 * gdk_screen_get_height(screen);
}
return result;
}
void
nsWindow::EnsureGrabs(void)
{

Просмотреть файл

@ -246,6 +246,7 @@ public:
PRBool aRepaint);
void NativeShow (PRBool aAction);
virtual nsSize GetSafeWindowSize(nsSize aSize);
void EnsureGrabs (void);
void GrabPointer (void);