summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGareth Stockwell <gareth.stockwell@sosco.com>2009-10-07 16:56:23 (GMT)
committerGareth Stockwell <gareth.stockwell@sosco.com>2009-10-09 07:10:20 (GMT)
commita8e2a457bb7d2fc377c1c65b6a4172974919e055 (patch)
treeb7d52a0bc06c4b098ec36125d623deccd6c7e373 /src
parent9371ae3ff036a622f578023377cfcacbc733b804 (diff)
downloadQt-a8e2a457bb7d2fc377c1c65b6a4172974919e055.zip
Qt-a8e2a457bb7d2fc377c1c65b6a4172974919e055.tar.gz
Qt-a8e2a457bb7d2fc377c1c65b6a4172974919e055.tar.bz2
Added a new event type, WinIdChange.
This is sent to a native widget when its window system identifer has changed. This is motivated by the fact that, on Symbian, the native window system identifier may change in situations other than a change of parent widget. Specifically, calling QWidget::setParent, passing in the widget's existing parent, but OR-in Qt::Window into the window flags, causes a new native window handle to be created. Furthermore, because of the fact that Symbian does not allow existing windows to be reparented, any descendents of the original widget which are also native, must also be given new window system handles. Note that setWinId does not send a WinIdChange event if the incoming winId is zero. This is because setWinId(0) is only called in two situations: 1. During native widget destruction 2. During re-creation of the winId for a native widget Task-number: QTBUG-4664 Reviewed-by: Bjoern Erik Nilsen
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qcoreevent.cpp1
-rw-r--r--src/corelib/kernel/qcoreevent.h2
-rw-r--r--src/gui/kernel/qwidget.cpp16
3 files changed, 17 insertions, 2 deletions
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index 744e6a9..44a354b 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -228,6 +228,7 @@ QT_BEGIN_NAMESPACE
\value TouchBegin Beginning of a sequence of touch-screen and/or track-pad events (QTouchEvent)
\value TouchUpdate Touch-screen event (QTouchEvent)
\value TouchEnd End of touch-event sequence (QTouchEvent)
+ \value WinIdChange The window system identifer for this native widget has changed
User events should have values between \c User and \c{MaxUser}:
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index d66cead..99280d3 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -283,6 +283,8 @@ public:
UpdateSoftKeys = 201, // Internal for compressing soft key updates
+ WinIdChange = 203,
+
// 512 reserved for Qt Jambi's MetaCall event
// 513 reserved for Qt Jambi's DeleteOnMainThread event
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 4cbf762..7c11c00 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -1502,6 +1502,8 @@ void QWidgetPrivate::setWinId(WId id) // set widget identifier
mapper->remove(data.winid);
}
+ const WId oldWinId = data.winid;
+
data.winid = id;
#if defined(Q_WS_X11)
hd = id; // X11: hd == ident
@@ -1509,6 +1511,16 @@ void QWidgetPrivate::setWinId(WId id) // set widget identifier
if (mapper && id && !userDesktopWidget) {
mapper->insert(data.winid, q);
}
+
+ if(oldWinId != id) {
+ // Do not emit an event when the old winId is destroyed. This only
+ // happens (a) during widget destruction, and (b) immediately prior
+ // to creation of a new winId, for example as a result of re-parenting.
+ if(id != 0) {
+ QEvent e(QEvent::WinIdChange);
+ QCoreApplication::sendEvent(q, &e);
+ }
+ }
}
void QWidgetPrivate::createTLExtra()
@@ -2227,8 +2239,8 @@ QWidget *QWidget::find(WId id)
against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt
is using Cocoa, {WId} is a pointer to an NSView.
- \note We recommend that you do not store this value as it is likely to
- change at run-time.
+ This value may change at run-time. An event with type QEvent::WinIdChange
+ will be sent to the widget following a change in window system identifier.
\sa find()
*/