summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorGareth Stockwell <gareth.stockwell@sosco.com>2009-09-02 17:28:37 (GMT)
committerGareth Stockwell <gareth.stockwell@sosco.com>2009-09-07 10:26:48 (GMT)
commit6705f143db308fb10dfc09988bc15874eebb75a8 (patch)
tree016ba7c076ae8c352c51e3a81805a02f732c5779 /src/gui
parent3bcdd19ed5dc0328951c8cd917c4ae766a329f11 (diff)
downloadQt-6705f143db308fb10dfc09988bc15874eebb75a8.zip
Qt-6705f143db308fb10dfc09988bc15874eebb75a8.tar.gz
Qt-6705f143db308fb10dfc09988bc15874eebb75a8.tar.bz2
Added macros to QtGui for controlling whether widgets are window-owning
There are two macros defined in src/gui/kernel/window_owning_control.h: If this is defined, then calling QWidget::winId causes a native window to be created for the associated control If QWIDGET_OWNS_WINDOW is defined, defining this macro means that the parent window for the newly created window is the parent widget's winId. This in turn means that calling QWidget::winId causes native windows to be created for all ancestors of the target widget. If this macro is undefined, the parent window is the parent widget's effectiveWinId.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qapplication_s60.cpp25
-rw-r--r--src/gui/kernel/qwidget_s60.cpp18
-rw-r--r--src/gui/kernel/symbian.pri2
-rw-r--r--src/gui/kernel/window_owning_control.h57
4 files changed, 96 insertions, 6 deletions
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index 765a1c1..2a71073 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -75,6 +75,8 @@
#include <QDebug>
#endif
+#include "window_owning_control.h"
+
QT_BEGIN_NAMESPACE
#if defined(QT_DEBUG)
@@ -322,6 +324,7 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop)
{
if (!desktop)
{
+#ifdef QWIDGET_OWNS_WINDOW
if (topLevel or !qwidget->parentWidget())
CreateWindowL(S60->windowGroup());
else
@@ -333,18 +336,30 @@ void QSymbianControl::ConstructL(bool topLevel, bool desktop)
* this, then we need to take care of re-parenting when a window
* is created for a widget between this one and the root window.
*/
+ #ifdef QWIDGET_IMMEDIATE_WINDOW_PARENT
CreateWindowL(qwidget->parentWidget()->winId());
+ #else
+ CreateWindowL(qwidget->parentWidget()->effectiveWinId());
+ #endif // QWIDGET_IMMEDIATE_WINDOW_PARENT
+
+ // Necessary in order to be able to track the activation status of
+ // the control's window
+ qwidget->d_func()->createTLExtra();
+#else
+ if (topLevel)
+ CreateWindowL(S60->windowGroup());
+#endif // QWIDGET_OWNS_WINDOW
#ifdef DEBUG_QSYMBIANCONTROL
qDebug() << "QSymbianControl::ConstructL [" << this
<< "] widget" << qwidget
- << "control" << qwidget->winId();
+ << "topLevel" << topLevel
+ << "parentWidget" << qwidget->parentWidget()
+ << "OwnsWindow" << OwnsWindow()
+ << "Window.ClientHandle" << reinterpret_cast<const void*>(DrawableWindow()->ClientHandle())
+ << "WindowGroupId" << DrawableWindow()->WindowGroupId();
#endif
- // Necessary in order to be able to track the activation status of
- // the control's window
- qwidget->d_func()->createTLExtra();
-
SetFocusing(true);
m_longTapDetector = QLongTapTimer::NewL(this);
}
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index 210aff5..28ce90e 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -61,6 +61,8 @@
#include <QDebug>
#endif
+#include "window_owning_control.h"
+
QT_BEGIN_NAMESPACE
extern bool qt_nograb();
@@ -612,6 +614,11 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
}
QT_TRAP_THROWING(control->ControlEnv()->AppUi()->AddToStackL(control, ECoeStackPriorityDefault, stackingFlags));
+#ifndef QWIDGET_OWNS_WINDOW
+ WId parentw = parentWidget->effectiveWinId();
+ QT_TRAP_THROWING(control->SetContainerWindowL(*parentw));
+#endif
+
q->setAttribute(Qt::WA_WState_Created);
int x, y, w, h;
data.crect.getRect(&x, &y, &w, &h);
@@ -646,8 +653,12 @@ void QWidgetPrivate::show_sys()
return;
}
+#ifdef QWIDGET_OWNS_WINDOW
if (q->internalWinId()) {
-
+#else
+ if (q->isWindow() && q->internalWinId()) {
+#endif
+
WId id = q->internalWinId();
if (!extra->topextra->activated) {
@@ -688,7 +699,12 @@ void QWidgetPrivate::hide_sys()
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
deactivateWidgetCleanup();
WId id = q->internalWinId();
+
+#ifdef QWIDGET_OWNS_WINDOW
if (id) {
+#else
+ if (q->isWindow() && id) {
+#endif
#ifdef DEBUG_QWIDGET
qDebug() << "QWidgetPrivate::show_sys [" << this << "]"
diff --git a/src/gui/kernel/symbian.pri b/src/gui/kernel/symbian.pri
index d267a53..87d8492 100644
--- a/src/gui/kernel/symbian.pri
+++ b/src/gui/kernel/symbian.pri
@@ -1,3 +1,5 @@
symbian {
+ HEADERS += window_owning_control.h
+
contains(QT_CONFIG, s60): LIBS+= $$QMAKE_LIBS_S60
}
diff --git a/src/gui/kernel/window_owning_control.h b/src/gui/kernel/window_owning_control.h
new file mode 100644
index 0000000..af192f3
--- /dev/null
+++ b/src/gui/kernel/window_owning_control.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_OWNING_CONTROL_H
+#define WINDOW_OWNING_CONTROL_H
+
+// If this is defined, then calling QWidget::winId causes a native window to
+// be created for the associated control
+#define QWIDGET_OWNS_WINDOW
+
+// If QWIDGET_OWNS_WINDOW is defined, defining this macro means that the
+// parent window for the newly created window is the parent widget's winId.
+// This in turn means that calling QWidget::winId causes native windows to
+// be created for all ancestors of the target widget.
+// If this macro is undefined, the parent window is the parent widget's
+// effectiveWinId.
+#define QWIDGET_IMMEDIATE_WINDOW_PARENT
+
+#endif // WINDOW_OWNING_CONTROL_H