Update widget winId when screen changes
When a window's screen changes it may recreate the platform window. In that case, update the winId in the widget to keep it in sync. Task-number: QTBUG-40681 Change-Id: Iec815320214832bb63952de3a5bd1340a04dacd4 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>bb10
parent
ed167dcb72
commit
75e5ffe0f7
|
|
@ -9042,6 +9042,12 @@ bool QWidget::event(QEvent *event)
|
|||
event->ignore();
|
||||
break;
|
||||
#endif
|
||||
case QEvent::ScreenChangeInternal:
|
||||
if (const QTLWExtra *te = d->maybeTopData()) {
|
||||
const QWindow *win = te->window;
|
||||
d->setWinId((win && win->handle()) ? win->handle()->winId() : 0);
|
||||
}
|
||||
break;
|
||||
#ifndef QT_NO_PROPERTIES
|
||||
case QEvent::DynamicPropertyChange: {
|
||||
const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
CONFIG += testcase
|
||||
CONFIG += parallel_test
|
||||
TARGET = tst_qwidget_window
|
||||
QT += widgets testlib
|
||||
QT += widgets testlib core-private gui-private
|
||||
SOURCES += tst_qwidget_window.cpp
|
||||
|
||||
x11 {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@
|
|||
#include <qlistwidget.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qboxlayout.h>
|
||||
#include <qlabel.h>
|
||||
#include <private/qwindow_p.h>
|
||||
|
||||
static inline void setFrameless(QWidget *w)
|
||||
{
|
||||
|
|
@ -97,6 +99,7 @@ private slots:
|
|||
#endif
|
||||
|
||||
void tst_qtbug35600();
|
||||
void tst_updateWinId_QTBUG40681();
|
||||
};
|
||||
|
||||
void tst_QWidget_window::initTestCase()
|
||||
|
|
@ -603,5 +606,33 @@ void tst_QWidget_window::tst_qtbug35600()
|
|||
// QTBUG-35600: program may crash here or on exit
|
||||
}
|
||||
|
||||
void tst_QWidget_window::tst_updateWinId_QTBUG40681()
|
||||
{
|
||||
QWidget w;
|
||||
QVBoxLayout *vl = new QVBoxLayout(&w);
|
||||
QLabel *lbl = new QLabel("HELLO1");
|
||||
lbl->setAttribute(Qt::WA_NativeWindow);
|
||||
lbl->setObjectName("label1");
|
||||
vl->addWidget(lbl);
|
||||
w.setMinimumWidth(200);
|
||||
|
||||
w.show();
|
||||
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&w));
|
||||
|
||||
QCOMPARE(lbl->winId(), lbl->windowHandle()->winId());
|
||||
|
||||
// simulate screen change and notification
|
||||
QWindow *win = w.windowHandle();
|
||||
w.windowHandle()->destroy();
|
||||
lbl->windowHandle()->destroy();
|
||||
w.windowHandle()->create();
|
||||
lbl->windowHandle()->create();
|
||||
QWindowPrivate *p = qt_window_private(win);
|
||||
p->emitScreenChangedRecursion(win->screen());
|
||||
|
||||
QCOMPARE(lbl->winId(), lbl->windowHandle()->winId());
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QWidget_window)
|
||||
#include "tst_qwidget_window.moc"
|
||||
|
|
|
|||
Loading…
Reference in New Issue