diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-07-23 08:24:06 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-07-23 08:37:47 (GMT) |
commit | be08fbc13f7370b6cc0c34660b4d1c16e4fdd3f5 (patch) | |
tree | 667ad95bc68c4a5423179672741152d758a0a6b3 | |
parent | d15e6a32aeced893a5b5b790f3235cc7b3e0b9af (diff) | |
download | Qt-be08fbc13f7370b6cc0c34660b4d1c16e4fdd3f5.zip Qt-be08fbc13f7370b6cc0c34660b4d1c16e4fdd3f5.tar.gz Qt-be08fbc13f7370b6cc0c34660b4d1c16e4fdd3f5.tar.bz2 |
Handle behavior change in resize and move events in Lighthouse
Dont post the resize event and move event seperatly on the
windowsystemintegration event queue, but as one event which will be
processed in one go.
-rw-r--r-- | src/gui/kernel/qapplication_p.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_qpa.cpp | 47 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_qpa.cpp | 1 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface_qpa.cpp | 24 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface_qpa_p.h | 22 |
5 files changed, 35 insertions, 62 deletions
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index de97f62..933e0ab 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -500,8 +500,7 @@ public: static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e); - static void processMoveEvent(QWindowSystemInterfacePrivate::MoveEvent *e); - static void processResizeEvent(QWindowSystemInterfacePrivate::ResizeEvent *e); + static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e); static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e); static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e); diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index d289dee..26ae82d 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -102,11 +102,8 @@ void QApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate case QWindowSystemInterfacePrivate::Touch: QApplicationPrivate::processTouchEvent(static_cast<QWindowSystemInterfacePrivate::TouchEvent *>(e)); break; - case QWindowSystemInterfacePrivate::Move: - QApplicationPrivate::processMoveEvent(static_cast<QWindowSystemInterfacePrivate::MoveEvent *>(e)); - break; - case QWindowSystemInterfacePrivate::Resize: - QApplicationPrivate::processResizeEvent(static_cast<QWindowSystemInterfacePrivate::ResizeEvent *>(e)); + case QWindowSystemInterfacePrivate::GeometryChange: + QApplicationPrivate::processGeometryChangeEvent(static_cast<QWindowSystemInterfacePrivate::GeometryChangeEvent*>(e)); break; case QWindowSystemInterfacePrivate::Enter: QApplicationPrivate::processEnterEvent(static_cast<QWindowSystemInterfacePrivate::EnterEvent *>(e)); @@ -826,27 +823,33 @@ void QApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::Leave } -void QApplicationPrivate::processMoveEvent(QWindowSystemInterfacePrivate::MoveEvent *moveEvent) + +void QApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e) { - if (moveEvent->moved.isNull()) { - //qDebug() << "QApplicationPrivate::processMoveEvent NULL"; - return; + if (e->tlw.isNull()) + return; + QWidget *tlw = e->tlw.data(); + if (!tlw->isWindow()) + return; //geo of native child widgets is controlled by lighthouse + //so we already have sent the events; besides this new rect + //is not mapped to parent + + QRect newRect = e->newGeometry; + QRect cr(tlw->geometry()); + bool isResize = cr.size() != newRect.size(); + bool isMove = cr.topLeft() != newRect.topLeft(); + tlw->data->crect = newRect; + if (isResize) { + QResizeEvent e(tlw->data->crect.size(), cr.size()); + QApplication::sendSpontaneousEvent(tlw, &e); + tlw->update(); } - moveEvent->moved.data()->data->crect.setTopLeft(moveEvent->newPos); - QMoveEvent e(moveEvent->moved.data()->geometry().topLeft(), moveEvent->newPos); - QApplication::sendSpontaneousEvent(moveEvent->moved.data(), &e); -} -void QApplicationPrivate::processResizeEvent(QWindowSystemInterfacePrivate::ResizeEvent *e) -{ - if (e->sizeChanged.isNull()) { - //qDebug() << "QApplicationPrivate::processResizeEvent NULL"; - return; + if (isMove) { + //### frame geometry + QMoveEvent e(tlw->data->crect.topLeft(), cr.topLeft()); + QApplication::sendSpontaneousEvent(tlw, &e); } - e->sizeChanged.data()->data->crect.setSize(e->newSize); - QResizeEvent resizeEvent(e->sizeChanged.data()->data->crect.size(), e->newSize); - QApplication::sendSpontaneousEvent(e->sizeChanged.data(), &resizeEvent); - e->sizeChanged.data()->update(); } void QApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e) diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index ac868eb..1b7d9d2 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -128,6 +128,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) if (windowType() != Qt::Desktop) { if (destroyWindow && isWindow()) { +//### jl: delete all child windows... QTLWExtra *topData = d->maybeTopData(); if (topData) { delete topData->platformWindow; diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp index dd78e8e..c49bd36 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp +++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp @@ -75,28 +75,8 @@ void QWindowSystemInterface::handleLeaveEvent(QWidget *tlw) void QWindowSystemInterface::handleGeometryChange(QWidget *tlw, const QRect &newRect) { - if (!tlw) - return; - if (!tlw->isWindow()) - return; //geo of native child widgets is controlled by lighthouse - //so we already have sent the events; besides this new rect - //is not mapped to parent - - QRect cr(tlw->geometry()); - - bool isResize = cr.size() != newRect.size(); - bool isMove = cr.topLeft() != newRect.topLeft(); - if (isResize) { - QWindowSystemInterfacePrivate::ResizeEvent *resizeEvent = - new QWindowSystemInterfacePrivate::ResizeEvent(tlw,newRect.size()); - QWindowSystemInterfacePrivate::queueWindowSystemEvent(resizeEvent); - } - - if (isMove) { - QWindowSystemInterfacePrivate::MoveEvent *moveEvent = - new QWindowSystemInterfacePrivate::MoveEvent(tlw,newRect.topLeft()); - QWindowSystemInterfacePrivate::queueWindowSystemEvent(moveEvent); - } + QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); } diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h index 90d1702..5f3ac5d 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa_p.h +++ b/src/gui/kernel/qwindowsysteminterface_qpa_p.h @@ -53,8 +53,7 @@ public: enum EventType { Close, - Resize, - Move, + GeometryChange, Enter, Leave, Mouse, @@ -80,22 +79,13 @@ public: QWeakPointer<QWidget> topLevel; }; - class ResizeEvent : public WindowSystemEvent { + class GeometryChangeEvent : public WindowSystemEvent { public: - ResizeEvent(QWidget *sizeChanged, const QSize &newSize) - : WindowSystemEvent(Resize), sizeChanged(sizeChanged), newSize(newSize) + GeometryChangeEvent(QWidget *tlw, const QRect &newGeometry) + : WindowSystemEvent(GeometryChange), tlw(tlw), newGeometry(newGeometry) { } - QWeakPointer<QWidget> sizeChanged; - QSize newSize; - }; - - class MoveEvent : public WindowSystemEvent { - public: - MoveEvent(QWidget *moved, const QPoint &newPos) - : WindowSystemEvent(Move), moved(moved), newPos(newPos) - { } - QWeakPointer<QWidget> moved; - QPoint newPos; + QWeakPointer<QWidget> tlw; + QRect newGeometry; }; class EnterEvent : public WindowSystemEvent { |