summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-03-27 09:20:34 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-03-27 09:34:03 (GMT)
commite83fce3f50f646fa1d3daf6dabffa47045290a44 (patch)
tree3ce4b5b9ad04a78987e38679600093040f0a76ca
parent9508cfea4731f86664794455c4d3571e41e180fd (diff)
downloadQt-e83fce3f50f646fa1d3daf6dabffa47045290a44.zip
Qt-e83fce3f50f646fa1d3daf6dabffa47045290a44.tar.gz
Qt-e83fce3f50f646fa1d3daf6dabffa47045290a44.tar.bz2
Creating an instance of the QDesktopWidget breaks clipboard on X11.
On X11 when user manually creates a QDesktopWidget object it breaks notifications from the root window since we have several QDesktopWidgets that have the same native window id and the wid->qwidget mapper (QWidgetPrivate::mapper) goes crazy. So whenever we get x11 event from the root window we cannot find a qwidget that corresponds to the window id and discard these events. Reviewed-by: Brad
-rw-r--r--doc/src/qdesktopwidget.qdoc9
-rw-r--r--src/gui/kernel/qwidget.cpp11
2 files changed, 17 insertions, 3 deletions
diff --git a/doc/src/qdesktopwidget.qdoc b/doc/src/qdesktopwidget.qdoc
index 0361aae..5a27fb4 100644
--- a/doc/src/qdesktopwidget.qdoc
+++ b/doc/src/qdesktopwidget.qdoc
@@ -48,6 +48,9 @@
\ingroup environment
\mainclass
+ QApplication::desktop() function should be used to get an instance
+ of the QDesktopWidget.
+
Systems with more than one graphics card and monitor can manage the
physical screen space available either as multiple desktops, or as a
large virtual desktop, which usually has the size of the bounding
@@ -86,12 +89,14 @@
screens. The correct width and height values are obtained using
availableGeometry() or screenGeometry() for a particular screen.
- \sa QApplication, QX11Info::appRootWindow()
+ \sa QApplication, QApplication::desktop(), QX11Info::appRootWindow()
*/
/*!
\fn QDesktopWidget::QDesktopWidget()
+ \internal
+
Creates the desktop widget.
If the system supports a virtual desktop, this widget will have
@@ -104,6 +109,8 @@
/*!
\fn QDesktopWidget::~QDesktopWidget()
+ \internal
+
Destroys the desktop widget and frees any allocated resources.
*/
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 06810e0..dcb48cc 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -164,6 +164,7 @@ static inline bool bypassGraphicsProxyWidget(QWidget *p)
#endif
extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp
+extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
QWidgetPrivate::QWidgetPrivate(int version) :
QObjectPrivate(version), extra(0), focus_child(0)
@@ -1400,7 +1401,13 @@ int QWidgetPrivate::maxInstances = 0; // Maximum number of widget instances
void QWidgetPrivate::setWinId(WId id) // set widget identifier
{
Q_Q(QWidget);
- if (mapper && data.winid) {
+ // the user might create a widget with Qt::Desktop window
+ // attribute (or create another QDesktopWidget instance), which
+ // will have the same windowid (the root window id) as the
+ // qt_desktopWidget. We should not add the second desktop widget
+ // to the mapper.
+ bool userDesktopWidget = qt_desktopWidget != 0 && qt_desktopWidget != q && q->windowType() == Qt::Desktop;
+ if (mapper && data.winid && !userDesktopWidget) {
mapper->remove(data.winid);
uncreatedWidgets->insert(q);
}
@@ -1409,7 +1416,7 @@ void QWidgetPrivate::setWinId(WId id) // set widget identifier
#if defined(Q_WS_X11)
hd = id; // X11: hd == ident
#endif
- if (mapper && id) {
+ if (mapper && id && !userDesktopWidget) {
mapper->insert(data.winid, q);
uncreatedWidgets->remove(q);
}