From 693d761e6908ffe30d7d18a48fd11ce2d565b8e3 Mon Sep 17 00:00:00 2001 From: Oleg Romashin Date: Sun, 25 Sep 2011 21:03:22 +0200 Subject: [PATCH] Bug 683085 - NativeParentWidget used incorrectly in Widget Qt port r=dougt --- widget/src/qt/nsWindow.cpp | 20 +++++++++++++++----- widget/src/qt/nsWindow.h | 4 +++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/widget/src/qt/nsWindow.cpp b/widget/src/qt/nsWindow.cpp index 980c253f035..8d056730a6e 100644 --- a/widget/src/qt/nsWindow.cpp +++ b/widget/src/qt/nsWindow.cpp @@ -142,6 +142,10 @@ static Atom sPluginIMEAtom; #include "Layers.h" #include "LayerManagerOGL.h" +// If embedding clients want to create widget without real parent window +// then nsIBaseWindow->Init() should have parent argument equal to PARENTLESS_WIDGET +#define PARENTLESS_WIDGET (void*)0x13579 + #include "nsShmImage.h" extern "C" { #include "pixman.h" @@ -2278,11 +2282,9 @@ nsWindow::Create(nsIWidget *aParent, if (aParent != nsnull) parent = static_cast(aParent->GetNativeData(NS_NATIVE_WIDGET)); - else - parent = static_cast(aNativeParent); // ok, create our QGraphicsWidget - mWidget = createQWidget(parent, aInitData); + mWidget = createQWidget(parent, aNativeParent, aInitData); if (!mWidget) return NS_ERROR_OUT_OF_MEMORY; @@ -2628,7 +2630,9 @@ nsPopupWindow::~nsPopupWindow() } MozQWidget* -nsWindow::createQWidget(MozQWidget *parent, nsWidgetInitData *aInitData) +nsWindow::createQWidget(MozQWidget *parent, + nsNativeWidget nativeParent, + nsWidgetInitData *aInitData) { const char *windowName = NULL; Qt::WindowFlags flags = Qt::Widget; @@ -2664,7 +2668,13 @@ nsWindow::createQWidget(MozQWidget *parent, nsWidgetInitData *aInitData) break; } - MozQWidget * widget = new MozQWidget(this, parent); + MozQWidget* parentQWidget = nsnull; + if (parent) { + parentQWidget = parent; + } else if (nativeParent && nativeParent != PARENTLESS_WIDGET) { + parentQWidget = static_cast(nativeParent); + } + MozQWidget * widget = new MozQWidget(this, parentQWidget); if (!widget) return nsnull; diff --git a/widget/src/qt/nsWindow.h b/widget/src/qt/nsWindow.h index ad9f5fbaab9..3bd64e796f7 100644 --- a/widget/src/qt/nsWindow.h +++ b/widget/src/qt/nsWindow.h @@ -347,7 +347,9 @@ private: void InitButtonEvent(nsMouseEvent &event, QGraphicsSceneMouseEvent *aEvent, int aClickCount = 1); nsEventStatus DispatchCommandEvent(nsIAtom* aCommand); nsEventStatus DispatchContentCommandEvent(PRInt32 aMsg); - MozQWidget* createQWidget(MozQWidget *parent, nsWidgetInitData *aInitData); + MozQWidget* createQWidget(MozQWidget* parent, + nsNativeWidget nativeParent, + nsWidgetInitData* aInitData); void SetSoftwareKeyboardState(PRBool aOpen); MozQWidget* mWidget;