зеркало из https://github.com/mozilla/pjs.git
Bug 552315 - Improve Qt show functionality. r=dougt
This commit is contained in:
Родитель
dcfb1bc6b8
Коммит
5975e1fa49
|
@ -538,20 +538,23 @@ nsWindow::SetSizeMode(PRInt32 aMode)
|
|||
return rv;
|
||||
}
|
||||
|
||||
QWidget *widget = GetViewWidget();
|
||||
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
|
||||
|
||||
switch (aMode) {
|
||||
case nsSizeMode_Maximized:
|
||||
GetViewWidget()->showMaximized();
|
||||
widget->showMaximized();
|
||||
break;
|
||||
case nsSizeMode_Minimized:
|
||||
GetViewWidget()->showMinimized();
|
||||
widget->showMinimized();
|
||||
break;
|
||||
case nsSizeMode_Fullscreen:
|
||||
GetViewWidget()->showFullScreen();
|
||||
widget->showFullScreen();
|
||||
break;
|
||||
|
||||
default:
|
||||
// nsSizeMode_Normal, really.
|
||||
GetViewWidget()->showNormal();
|
||||
widget->showNormal();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -598,7 +601,9 @@ nsWindow::SetFocus(PRBool aRaise)
|
|||
|
||||
if (aRaise) {
|
||||
// the raising has to happen on the view widget
|
||||
GetViewWidget()->raise();
|
||||
QWidget *widget = GetViewWidget();
|
||||
if (widget)
|
||||
widget->raise();
|
||||
realFocusItem->setFocus(Qt::ActiveWindowFocusReason);
|
||||
}
|
||||
else
|
||||
|
@ -661,8 +666,11 @@ nsWindow::Invalidate(const nsIntRect &aRect,
|
|||
mWidget->update(aRect.x, aRect.y, aRect.width, aRect.height);
|
||||
|
||||
// QGraphicsItems cannot trigger a repaint themselves, so we start it on the view
|
||||
if (aIsSynchronous)
|
||||
GetViewWidget()->repaint();
|
||||
if (aIsSynchronous) {
|
||||
QWidget *widget = GetViewWidget();
|
||||
if (widget)
|
||||
widget->repaint();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -734,7 +742,7 @@ nsWindow::Scroll(const nsIntPoint& aDelta,
|
|||
QWidget* nsWindow::GetViewWidget()
|
||||
{
|
||||
NS_ASSERTION(mWidget, "Calling GetViewWidget without mWidget created");
|
||||
if (!mWidget)
|
||||
if (!mWidget || !mWidget->scene())
|
||||
return nsnull;
|
||||
|
||||
NS_ASSERTION(mWidget->scene()->views().size() == 1, "Not exactly one view for our scene!");
|
||||
|
@ -760,7 +768,8 @@ nsWindow::GetNativeData(PRUint32 aDataType)
|
|||
|
||||
#ifdef Q_WS_X11
|
||||
case NS_NATIVE_DISPLAY:
|
||||
return GetViewWidget()->x11Info().display();
|
||||
QWidget *widget = GetViewWidget();
|
||||
return widget ? widget->x11Info().display() : nsnull;
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
@ -783,8 +792,11 @@ NS_IMETHODIMP
|
|||
nsWindow::SetTitle(const nsAString& aTitle)
|
||||
{
|
||||
QString qStr(QString::fromUtf16(aTitle.BeginReading(), aTitle.Length()));
|
||||
if (mIsTopLevel)
|
||||
GetViewWidget()->setWindowTitle(qStr);
|
||||
if (mIsTopLevel) {
|
||||
QWidget *widget = GetViewWidget();
|
||||
if (widget)
|
||||
widget->setWindowTitle(qStr);
|
||||
}
|
||||
else if (mWidget)
|
||||
mWidget->setWindowTitle(qStr);
|
||||
|
||||
|
@ -855,10 +867,14 @@ nsWindow::CaptureMouse(PRBool aCapture)
|
|||
|
||||
if (!mWidget)
|
||||
return NS_OK;
|
||||
|
||||
QWidget *widget = GetViewWidget();
|
||||
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
|
||||
|
||||
if (aCapture)
|
||||
GetViewWidget()->grabMouse();
|
||||
widget->grabMouse();
|
||||
else
|
||||
GetViewWidget()->releaseMouse();
|
||||
widget->releaseMouse();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1829,8 +1845,12 @@ nsWindow::NativeResize(PRInt32 aX, PRInt32 aY,
|
|||
void
|
||||
nsWindow::NativeShow(PRBool aAction)
|
||||
{
|
||||
if (aAction == PR_TRUE)
|
||||
if (aAction) {
|
||||
QWidget *widget = GetViewWidget();
|
||||
if (widget && !widget->isVisible())
|
||||
MakeFullScreen(mSizeMode == nsSizeMode_Fullscreen);
|
||||
mWidget->show();
|
||||
}
|
||||
else
|
||||
mWidget->hide();
|
||||
}
|
||||
|
@ -1876,7 +1896,9 @@ nsWindow::SetWindowIconList(const nsTArray<nsCString> &aIconList)
|
|||
icon.addFile(path);
|
||||
}
|
||||
|
||||
GetViewWidget()->setWindowIcon(icon);
|
||||
QWidget *widget = GetViewWidget();
|
||||
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
|
||||
widget->setWindowIcon(icon);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1895,25 +1917,30 @@ void nsWindow::QWidgetDestroyed()
|
|||
NS_IMETHODIMP
|
||||
nsWindow::MakeFullScreen(PRBool aFullScreen)
|
||||
{
|
||||
QWidget *widget = GetViewWidget();
|
||||
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
|
||||
if (aFullScreen) {
|
||||
if (mSizeMode != nsSizeMode_Fullscreen)
|
||||
mLastSizeMode = mSizeMode;
|
||||
|
||||
mSizeMode = nsSizeMode_Fullscreen;
|
||||
GetViewWidget()->showFullScreen();
|
||||
widget->showFullScreen();
|
||||
}
|
||||
else {
|
||||
mSizeMode = mLastSizeMode;
|
||||
|
||||
switch (mSizeMode) {
|
||||
case nsSizeMode_Maximized:
|
||||
GetViewWidget()->showMaximized();
|
||||
widget->showMaximized();
|
||||
break;
|
||||
case nsSizeMode_Minimized:
|
||||
GetViewWidget()->showMinimized();
|
||||
widget->showMinimized();
|
||||
break;
|
||||
case nsSizeMode_Normal:
|
||||
GetViewWidget()->showNormal();
|
||||
widget->showNormal();
|
||||
break;
|
||||
default:
|
||||
widget->showNormal();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1953,7 +1980,9 @@ nsWindow::HideWindowChrome(PRBool aShouldHide)
|
|||
// error later when this happens (when the persistence timer fires
|
||||
// and GetWindowPos is called)
|
||||
#ifdef Q_WS_X11
|
||||
XSync(GetViewWidget()->x11Info().display(), False);
|
||||
QWidget *widget = GetViewWidget();
|
||||
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
|
||||
XSync(widget->x11Info().display(), False);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
|
@ -2091,7 +2120,6 @@ nsWindow::createQWidget(MozQWidget *parent, nsWidgetInitData *aInitData)
|
|||
#endif
|
||||
newView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
newView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
newView->showNormal();
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0))
|
||||
// Top level widget is just container, and should not be painted
|
||||
|
@ -2268,7 +2296,9 @@ nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
|
|||
mWidget->resize(aWidth, aHeight);
|
||||
|
||||
if (mIsTopLevel) {
|
||||
GetViewWidget()->resize(aWidth,aHeight);
|
||||
QWidget *widget = GetViewWidget();
|
||||
if (widget)
|
||||
widget->resize(aWidth, aHeight);
|
||||
}
|
||||
|
||||
if (aRepaint)
|
||||
|
@ -2294,7 +2324,9 @@ nsWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight,
|
|||
mWidget->setGeometry(aX, aY, aWidth, aHeight);
|
||||
|
||||
if (mIsTopLevel) {
|
||||
GetViewWidget()->resize(aWidth,aHeight);
|
||||
QWidget *widget = GetViewWidget();
|
||||
if (widget)
|
||||
widget->resize(aWidth, aHeight);
|
||||
}
|
||||
|
||||
if (aRepaint)
|
||||
|
|
Загрузка…
Ссылка в новой задаче