diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-04-28 14:08:22 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-04-28 14:17:53 (GMT) |
commit | 27e57ccd327fbc1edbb23d9959c5388023974dfc (patch) | |
tree | 78cc58d1f31751e4fc18b1773544c565a72e02ee | |
parent | 22fcb9580a6e2a183489c35eeafb6b32fcde96ea (diff) | |
download | Qt-27e57ccd327fbc1edbb23d9959c5388023974dfc.zip Qt-27e57ccd327fbc1edbb23d9959c5388023974dfc.tar.gz Qt-27e57ccd327fbc1edbb23d9959c5388023974dfc.tar.bz2 |
Enable dynamic [de|con]struction of window surfaces based on visibility
When a window becomes completely obscured either because it has been
hidden or another window is completely covering it, the backing store
should be deallocated to save memory and then re-allocated when the
window is later made visible again.
Reviewed-by: Iain <qt-info@nokia.com>
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 35 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_s60.cpp | 7 |
2 files changed, 29 insertions, 13 deletions
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index b021b1c..c7bbcdb 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -531,6 +531,9 @@ TCoeInputCapabilities QSymbianControl::InputCapabilities() const void QSymbianControl::Draw(const TRect& r) const { QWindowSurface *surface = qwidget->windowSurface(); + if (!surface) + return; + QPaintEngine *engine = surface->paintDevice()->paintEngine(); if (!engine) return; @@ -948,6 +951,7 @@ int QApplication::s60ProcessEvent(TWsEvent *event) // Qt event handling. Handle some events regardless of if the handle is in our // widget map or not. CCoeControl* control = reinterpret_cast<CCoeControl*>(event->Handle()); + const bool controlInMap = QWidgetPrivate::mapper && QWidgetPrivate::mapper->contains(control); switch (event->Type()) { #ifndef QT_NO_IM case EEventKey: @@ -970,17 +974,12 @@ int QApplication::s60ProcessEvent(TWsEvent *event) } #endif case EEventPointerEnter: - if (QWidgetPrivate::mapper && QWidgetPrivate::mapper->contains(control)) - { - // Qt::Enter will be generated in HandlePointerL - return 1; - } + if (controlInMap) + return 1; // Qt::Enter will be generated in HandlePointerL break; case EEventPointerExit: - if (QWidgetPrivate::mapper && QWidgetPrivate::mapper->contains(control)) - { - if (S60) - { + if (controlInMap) { + if (S60) { // mouseEvent outside our window, send leave event to last focused widget QMouseEvent mEvent(QEvent::Leave, S60->lastPointerEventPos, S60->lastCursorPos, Qt::NoButton, QApplicationPrivate::mouse_buttons, Qt::NoModifier); @@ -995,11 +994,27 @@ int QApplication::s60ProcessEvent(TWsEvent *event) if (S60) S60->updateScreenSize(); return 0; // Propagate to CONE + case EEventWindowVisibilityChanged: + if (controlInMap) { + const TWsVisibilityChangedEvent *visChangedEvent = event->VisibilityChanged(); + QWidget *w = QWidgetPrivate::mapper->value(control); + if (!w->d_func()->maybeTopData()) + break; + if (visChangedEvent->iFlags & TWsVisibilityChangedEvent::ENotVisible) { + delete w->d_func()->topData()->backingStore; + w->d_func()->topData()->backingStore = 0; + } else if ((visChangedEvent->iFlags & TWsVisibilityChangedEvent::EPartiallyVisible) + && !w->d_func()->maybeBackingStore()) { + w->d_func()->topData()->backingStore = new QWidgetBackingStore(w); + } + return 1; + } + break; default: break; } - if (!QWidgetPrivate::mapper || !QWidgetPrivate::mapper->contains(control)) + if (!controlInMap) return -1; return 0; diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 116dc35..ec80a18 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -195,12 +195,13 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO data.crect.moveTopLeft(QPoint(clientRect.iTl.iX, clientRect.iTl.iY)); QSymbianControl *control= new QSymbianControl(q); control->ConstructL(true,desktop); - if (!desktop) - { + if (!desktop) { QTLWExtra *topExtra = topData(); topExtra->rwindow = control->DrawableWindow(); // Request mouse move events. - topExtra->rwindow->PointerFilter(EPointerFilterEnterExit | EPointerFilterMove | EPointerFilterDrag, 0); + topExtra->rwindow->PointerFilter(EPointerFilterEnterExit + | EPointerFilterMove | EPointerFilterDrag, 0); + topExtra->rwindow->EnableVisibilityChangeEvents(); } id = (WId)control; |