summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidgetwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/kernel/qwidgetwindow.cpp')
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp74
1 files changed, 51 insertions, 23 deletions
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 7b52638e28..de8f11e5ec 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -434,14 +434,19 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
QWindow *win = w->windowHandle();
if (!win)
win = w->nativeParentWidget()->windowHandle();
- if (win && win->geometry().contains(event->globalPos())) {
- // Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec()
- const QPoint localPos = win->mapFromGlobal(event->globalPos());
- QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers());
- QCoreApplicationPrivate::setEventSpontaneous(e, true);
- QGuiApplicationPrivate::setMouseEventSource(e, QGuiApplicationPrivate::mouseEventSource(event));
- e->setTimestamp(event->timestamp());
- QCoreApplication::postEvent(win, e);
+ if (win) {
+ const QRect globalGeometry = win->isTopLevel()
+ ? win->geometry()
+ : QRect(win->mapToGlobal(QPoint(0, 0)), win->size());
+ if (globalGeometry.contains(event->globalPos())) {
+ // Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec()
+ const QPoint localPos = win->mapFromGlobal(event->globalPos());
+ QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers());
+ QCoreApplicationPrivate::setEventSpontaneous(e, true);
+ QGuiApplicationPrivate::setMouseEventSource(e, QGuiApplicationPrivate::mouseEventSource(event));
+ e->setTimestamp(event->timestamp());
+ QCoreApplication::postEvent(win, e);
+ }
}
}
}
@@ -539,14 +544,36 @@ void QWidgetWindow::handleKeyEvent(QKeyEvent *event)
QGuiApplication::sendSpontaneousEvent(receiver, event);
}
-void QWidgetWindow::updateGeometry()
+bool QWidgetWindow::updateSize()
{
+ bool changed = false;
if (m_widget->testAttribute(Qt::WA_OutsideWSRange))
- return;
+ return changed;
+ if (m_widget->data->crect.size() != geometry().size()) {
+ changed = true;
+ m_widget->data->crect.setSize(geometry().size());
+ }
- const QMargins margins = frameMargins();
+ updateMargins();
+ return changed;
+}
+
+bool QWidgetWindow::updatePos()
+{
+ bool changed = false;
+ if (m_widget->testAttribute(Qt::WA_OutsideWSRange))
+ return changed;
+ if (m_widget->data->crect.topLeft() != geometry().topLeft()) {
+ changed = true;
+ m_widget->data->crect.moveTopLeft(geometry().topLeft());
+ }
+ updateMargins();
+ return changed;
+}
- m_widget->data->crect = geometry();
+void QWidgetWindow::updateMargins()
+{
+ const QMargins margins = frameMargins();
QTLWExtra *te = m_widget->d_func()->topData();
te->posIncludesFrame= false;
te->frameStrut.setCoords(margins.left(), margins.top(), margins.right(), margins.bottom());
@@ -605,24 +632,25 @@ void QWidgetWindow::updateNormalGeometry()
void QWidgetWindow::handleMoveEvent(QMoveEvent *event)
{
- updateGeometry();
- QGuiApplication::sendSpontaneousEvent(m_widget, event);
+ if (updatePos())
+ QGuiApplication::sendSpontaneousEvent(m_widget, event);
}
void QWidgetWindow::handleResizeEvent(QResizeEvent *event)
{
QSize oldSize = m_widget->data->crect.size();
- updateGeometry();
- QGuiApplication::sendSpontaneousEvent(m_widget, event);
+ if (updateSize()) {
+ QGuiApplication::sendSpontaneousEvent(m_widget, event);
- if (m_widget->d_func()->paintOnScreen()) {
- QRegion updateRegion(geometry());
- if (m_widget->testAttribute(Qt::WA_StaticContents))
- updateRegion -= QRect(0, 0, oldSize.width(), oldSize.height());
- m_widget->d_func()->syncBackingStore(updateRegion);
- } else {
- m_widget->d_func()->syncBackingStore();
+ if (m_widget->d_func()->paintOnScreen()) {
+ QRegion updateRegion(geometry());
+ if (m_widget->testAttribute(Qt::WA_StaticContents))
+ updateRegion -= QRect(0, 0, oldSize.width(), oldSize.height());
+ m_widget->d_func()->syncBackingStore(updateRegion);
+ } else {
+ m_widget->d_func()->syncBackingStore();
+ }
}
}