From 67f912918be7a018f1cd7c6aa293e11973ce347e Mon Sep 17 00:00:00 2001 From: Miika Jarvinen Date: Thu, 19 Aug 2010 11:40:47 -0700 Subject: [PATCH] Bug 584454 - Support MeegoTouch status bar in Fennec browser. r=romaxa,doug.turner a=npodb --- widget/src/qt/mozqwidget.h | 54 +++++++++++++++++++++++++++++++++----- widget/src/qt/nsWindow.cpp | 17 +++++++----- 2 files changed, 58 insertions(+), 13 deletions(-) diff --git a/widget/src/qt/mozqwidget.h b/widget/src/qt/mozqwidget.h index 67b270be00a7..a1267d8dbad6 100644 --- a/widget/src/qt/mozqwidget.h +++ b/widget/src/qt/mozqwidget.h @@ -8,6 +8,8 @@ #ifdef MOZ_ENABLE_MEEGOTOUCH #include #include +#include +#include #endif #include "nsIWidget.h" @@ -186,26 +188,66 @@ private: #ifdef MOZ_ENABLE_MEEGOTOUCH class MozMSceneWindow : public MSceneWindow { + Q_OBJECT public: MozMSceneWindow(MozQWidget* aTopLevel) : MSceneWindow(aTopLevel->parentItem()) , mTopLevelWidget(aTopLevel) + , mStatusBar(nsnull) { mTopLevelWidget->setParentItem(this); + mTopLevelWidget->installEventFilter(this); + mStatusBar = new MStatusBar(); + mStatusBar->appear(); + connect(mStatusBar, SIGNAL(appeared()), this, SLOT(CheckTopLevelSize())); + connect(mStatusBar, SIGNAL(disappeared()), this, SLOT(CheckTopLevelSize())); } protected: virtual void resizeEvent(QGraphicsSceneResizeEvent* aEvent) { - if (mTopLevelWidget) { - // transfer new size to graphics widget - mTopLevelWidget->setGeometry(0.0, 0.0, - static_cast(aEvent->newSize().width()), - static_cast(aEvent->newSize().height())); - } + mCurrentSize = aEvent->newSize(); MSceneWindow::resizeEvent(aEvent); + CheckTopLevelSize(); } + + virtual bool eventFilter(QObject* watched, QEvent* e) + { + if (e->type() == QEvent::GraphicsSceneResize || + e->type() == QEvent::GraphicsSceneMove) { + + //Do this in next event loop, or we are in recursion! + QTimer::singleShot(0, this, SLOT(CheckTopLevelSize())); + } + + //false == let event processing continue + return false; + } + +private slots: + void CheckTopLevelSize() { + if (mTopLevelWidget) { + qreal xpos = 0; + qreal ypos = 0; + qreal width = mCurrentSize.width(); + qreal height = mCurrentSize.height(); + + //If statusbar is visible, move toplevel widget down + if (mStatusBar->isVisible()) { + ypos = mStatusBar->size().height(); + height -= ypos; + } + + // transfer new size to graphics widget if changed + QRectF r = mTopLevelWidget->geometry(); + if (r != QRectF(xpos, ypos, width, height)) + mTopLevelWidget->setGeometry(xpos, ypos, width, height); + } + } + private: MozQWidget* mTopLevelWidget; + MStatusBar* mStatusBar; + QSizeF mCurrentSize; }; /** diff --git a/widget/src/qt/nsWindow.cpp b/widget/src/qt/nsWindow.cpp index e68f4d3c5e9a..278ecdd39c4c 100644 --- a/widget/src/qt/nsWindow.cpp +++ b/widget/src/qt/nsWindow.cpp @@ -1738,9 +1738,11 @@ nsWindow::NativeResize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) mNeedsResize = PR_FALSE; - if (mIsTopLevel) { - GetViewWidget()->resize( aWidth, aHeight); - } +#ifndef MOZ_ENABLE_MEEGOTOUCH + if (mIsTopLevel && XRE_GetProcessType() == GeckoProcessType_Default) + GetViewWidget()->resize(aWidth, aHeight); +#endif + mWidget->resize( aWidth, aHeight); if (aRepaint) @@ -1758,12 +1760,13 @@ nsWindow::NativeResize(PRInt32 aX, PRInt32 aY, mNeedsResize = PR_FALSE; mNeedsMove = PR_FALSE; +#ifndef MOZ_ENABLE_MEEGOTOUCH if (mIsTopLevel) { -#ifdef MOZ_ENABLE_MEEGOTOUCH - if (XRE_GetProcessType() != GeckoProcessType_Default) -#endif - GetViewWidget()->setGeometry(aX, aY, aWidth, aHeight); + if (XRE_GetProcessType() == GeckoProcessType_Default) + GetViewWidget()->setGeometry(aX, aY, aWidth, aHeight); } +#endif + mWidget->setGeometry(aX, aY, aWidth, aHeight); if (aRepaint)