diff options
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 77 |
1 files changed, 49 insertions, 28 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index cf90df6b9b..dc55c2d5d9 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1477,12 +1477,16 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO qt_window_private(win)->positionPolicy = topData()->posIncludesFrame ? QWindowPrivate::WindowFrameInclusive : QWindowPrivate::WindowFrameExclusive; - win->create(); - // Enable nonclient-area events for QDockWidget and other NonClientArea-mouse event processing. - if ((flags & Qt::Desktop) == Qt::Window) + + if (q->windowType() != Qt::Desktop || q->testAttribute(Qt::WA_NativeWindow)) { + win->create(); + // Enable nonclient-area events for QDockWidget and other NonClientArea-mouse event processing. win->handle()->setFrameStrutEventsEnabled(true); + } data.window_flags = win->flags(); + if (!win->isTopLevel()) // In a Widget world foreign windows can only be top level + data.window_flags &= ~Qt::ForeignWindow; if (!topData()->role.isNull()) QXcbWindowFunctions::setWmWindowRole(win, topData()->role.toLatin1()); @@ -1499,10 +1503,13 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO } setWindowModified_helper(); - WId id = win->winId(); - // See the QPlatformWindow::winId() documentation - Q_ASSERT(id != WId(0)); - setWinId(id); + + if (win->handle()) { + WId id = win->winId(); + // See the QPlatformWindow::winId() documentation + Q_ASSERT(id != WId(0)); + setWinId(id); + } // Check children and create windows for them if necessary q_createNativeChildrenAndSetParent(q); @@ -5246,8 +5253,6 @@ static void sendResizeEvents(QWidget *target) \sa render(), QPixmap */ - -/* INVOKABLE since used by QPixmap::grabWidget(). */ QPixmap QWidget::grab(const QRect &rectangle) { Q_D(QWidget); @@ -6593,11 +6598,6 @@ void QWidget::setFocus(Qt::FocusReason reason) } else { f->d_func()->updateFocusChild(); } - - if (QTLWExtra *extra = f->window()->d_func()->maybeTopData()) { - if (extra->window) - emit extra->window->focusObjectChanged(f); - } } void QWidgetPrivate::setFocus_sys() @@ -6632,6 +6632,11 @@ void QWidgetPrivate::updateFocusChild() w = w->isWindow() ? 0 : w->parentWidget(); } } + + if (QTLWExtra *extra = q->window()->d_func()->maybeTopData()) { + if (extra->window) + emit extra->window->focusObjectChanged(q); + } } /*! @@ -6673,9 +6678,15 @@ void QWidget::clearFocus() w->d_func()->focus_child = 0; w = w->parentWidget(); } - // Since focus_child is the basis for the top level QWidgetWindow's focusObject() - // we need to report this change to the rest of Qt, but we match setFocus() and - // do it at the end of the function. + + // Since we've unconditionally cleared the focus_child of our parents, we need + // to report this to the rest of Qt. Note that the focus_child is not the same + // thing as the application's focusWidget, which is why this piece of code is + // not inside the hasFocus() block below. + if (QTLWExtra *extra = window()->d_func()->maybeTopData()) { + if (extra->window) + emit extra->window->focusObjectChanged(extra->window->focusObject()); + } #ifndef QT_NO_GRAPHICSVIEW QWExtra *topData = d_func()->extra; @@ -6698,15 +6709,6 @@ void QWidget::clearFocus() #endif } } - - // Since we've unconditionally cleared the focus_child of our parents, we need - // to report this to the rest of Qt. Note that the focus_child is not the same - // thing as the application's focusWidget, which is why this piece of code is - // not inside the hasFocus() block above. - if (QTLWExtra *extra = window()->d_func()->maybeTopData()) { - if (extra->window) - emit extra->window->focusObjectChanged(extra->window->focusObject()); - } } @@ -10353,7 +10355,7 @@ void QWidget::updateGeometry() a window, causing the widget to be hidden. You must call show() to make the widget visible again.. - \sa windowType(), {Window Flags Example} + \sa windowType(), setWindowFlag(), {Window Flags Example} */ void QWidget::setWindowFlags(Qt::WindowFlags flags) { @@ -10361,6 +10363,23 @@ void QWidget::setWindowFlags(Qt::WindowFlags flags) d->setWindowFlags(flags); } +/*! + \since 5.9 + + Sets the window flag \a flag on this widget if \a on is true; + otherwise clears the flag. + + \sa setWindowFlags(), windowFlags(), windowType() +*/ +void QWidget::setWindowFlag(Qt::WindowType flag, bool on) +{ + Q_D(QWidget); + if (on) + d->setWindowFlags(data->window_flags | flag); + else + d->setWindowFlags(data->window_flags & ~flag); +} + /*! \internal Implemented in QWidgetPrivate so that QMdiSubWindowPrivate can reimplement it. @@ -12710,7 +12729,6 @@ void QWidget::activateWindow() } /*! - \fn int QWidget::metric(PaintDeviceMetric m) const Internal implementation of the virtual QPaintDevice::metric() function. @@ -12934,6 +12952,9 @@ void QWidget::setMask(const QBitmap &bitmap) */ void QWidget::clearMask() { + Q_D(QWidget); + if (!d->extra || !d->extra->hasMask) + return; setMask(QRegion()); } |