diff options
author | Gareth Stockwell <gareth.stockwell@sosco.com> | 2009-10-07 16:56:23 (GMT) |
---|---|---|
committer | Gareth Stockwell <gareth.stockwell@sosco.com> | 2009-10-09 07:10:20 (GMT) |
commit | a8e2a457bb7d2fc377c1c65b6a4172974919e055 (patch) | |
tree | b7d52a0bc06c4b098ec36125d623deccd6c7e373 /src/gui/kernel/qwidget.cpp | |
parent | 9371ae3ff036a622f578023377cfcacbc733b804 (diff) | |
download | Qt-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/gui/kernel/qwidget.cpp')
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
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() */ |