void QWidgetPrivate::moveSurface(QWindowSurface *surface, const QPoint &offset) { QWSWindowSurface *s = static_cast<QWSWindowSurface*>(surface); if (!s->move(offset)) s->invalidateBuffer(); QWSDisplay::instance()->moveRegion(s->winId(), offset.x(), offset.y()); }
GfxPainter::GfxPainter(QWidget *wid, QPaintEvent *e) : fBuffer(0), buffer(0), _opacity(0xFF), realOpacity(1.0f), mainThreadProxy(0), dp(0), p(0), pImg(0), useQt(false), depth(Depth_16), opacityFunc(0), opacityFuncData(0) { Gfx::init(); #ifdef Q_WS_QWS if(!gfx_use_qt) { // XXX all this relies on the memory or shared memory window surface // we should probably test for this QWSWindowSurface *surface = static_cast<QWSWindowSurface *>(wid->windowSurface()); QImage *windowImage = static_cast<QImage *>(surface->paintDevice()); QPoint offset = surface->painterOffset(); if(windowImage->format() == QImage::Format_RGB16) { depth = Depth_16; } else if(windowImage->format() == QImage::Format_ARGB32_Premultiplied || windowImage->format() == QImage::Format_ARGB32 || windowImage->format() == QImage::Format_RGB32) { depth = Depth_32; } else { qWarning().nospace() << "GfxPainter: Unknown window image format (" << windowImage->format() << ")."; useQt = true; } if(!useQt) { // Add child widget offset if (!wid->isWindow()) offset += wid->mapTo(wid->window(), QPoint(0,0)); buffer = windowImage->bits() + offset.x() * depth + offset.y() * windowImage->bytesPerLine(); width = windowImage->width() - offset.x(); step = windowImage->width(); height = windowImage->height() - offset.y(); clipRegion = e->region(); if(!qt_region_is_rect(clipRegion)) clipRects = clipRegion.rects(); } } else { #endif useQt = true; #ifdef Q_WS_QWS } #endif if(useQt) p = new QPainter(wid); }
void QWidgetPrivate::dirtyWidget_sys(const QRegion &rgn, bool updateImmediately) { Q_Q(QWidget); QWidget *tlw = q->window(); QTLWExtra *tlwExtra = tlw->d_func()->topData(); QWidgetBackingStore *wbs = tlwExtra->backingStore; QRegion wrgn(rgn); if (tlw != q) { QPoint offs(q->mapTo(tlw, QPoint())); wrgn.translate(offs); } QWSWindowSurface *surface = static_cast<QWSWindowSurface*>(wbs->windowSurface); if (surface) { surface->d_ptr->updateImmediately = updateImmediately; if (tlwExtra->proxyWidget) { // Add the existing dirty region to the current update region before // we reset QWSWindowSurface::dirty. We do this in order to always // send an update event on sub-sequent updates/repaints. wrgn += surface->d_ptr->dirty; surface->d_ptr->dirty = QRegion(); // XXX: hw: Make sure we post/send update requests. surface->d_ptr->clip = wrgn; } surface->setDirty(wrgn); // re-get, since setDirty may recreate the surface surface = static_cast<QWSWindowSurface*>(wbs->windowSurface); surface->d_ptr->updateImmediately = false; #ifdef Q_BACKINGSTORE_SUBSURFACES // dirty on all subsurfaces... QList<QWindowSurface*> subSurfaces = wbs->subSurfaces; // XXX: hw: only if region intersects any of the subsurfaces for (int i = 0; i < subSurfaces.size(); ++i) { QWSWindowSurface *s = static_cast<QWSWindowSurface*>(subSurfaces.at(i)); QPoint p = s->window()->mapTo(tlw, QPoint()); // must use widget? s->d_ptr->updateImmediately = updateImmediately; s->setDirty(wrgn.translated(-p)); s->d_ptr->updateImmediately = false; } #endif // Q_BACKINGSTORE_SUBSURFACES } }
/*! \internal Paints all the dirty regions into \a pixmap. Returns the regions that have been repainted. */ void QWSManagerPrivate::paint(QPaintDevice *paintDevice, const QRegion ®ion) { if (dirtyRegions.empty() || !paintDevice || !paintDevice->paintEngine()) return; QTLWExtra *topextra = managed->d_func()->extra->topextra; Q_ASSERT(topextra && topextra->backingStore); QWidgetBackingStore *bs = topextra->backingStore; const QRect clipRect = managed->rect().translated(bs->topLevelOffset()); QDecoration &dec = QApplication::qwsDecoration(); QWSWindowSurface *surface; surface = static_cast<QWSWindowSurface*>(bs->windowSurface); const QRegion clippedRegion = region & surface->clipRegion(); const QRegion surfaceClip = clippedRegion.translated(bs->topLevelOffset()); paintDevice->paintEngine()->setSystemClip(surfaceClip); QPainter *painter = 0; const int numDirty = dirtyRegions.size(); for (int i = 0; i < numDirty; ++i) { int r = dirtyRegions.at(i); QDecoration::DecorationState state = dirtyStates.at(i); QRegion clipRegion = dec.region(managed, clipRect, r); if (!clipRegion.isEmpty()) { if (!painter) { painter = new QPainter(paintDevice); painter->setFont(qApp->font()); painter->translate(bs->topLevelOffset()); } clipRegion.translate(-bs->topLevelOffset()); painter->setClipRegion(clipRegion); dec.paint(painter, managed, r, state); } } dirtyRegions.clear(); dirtyStates.clear(); delete painter; }
//![2] bool PvrEglScreenSurfaceFunctions::createNativeWindow(QWidget *widget, EGLNativeWindowType *native) { //![2] QWSWindowSurface *surface = static_cast<QWSWindowSurface *>(widget->windowSurface()); if (!surface) { // The widget does not have a surface yet, so give it one. surface = new PvrEglWindowSurface(widget, screen, displayId); widget->setWindowSurface(surface); } else if (surface->key() != QLatin1String("PvrEgl")) { // The application has attached a QGLContext to an ordinary QWidget. // Replace the widget's window surface with a new one that can do GL. QRect geometry = widget->frameGeometry(); geometry.moveTo(widget->mapToGlobal(QPoint(0, 0))); surface = new PvrEglWindowSurface(widget, screen, displayId); surface->setGeometry(geometry); widget->setWindowSurface(surface); widget->setAttribute(Qt::WA_NoSystemBackground, true); } PvrEglWindowSurface *nsurface = static_cast<PvrEglWindowSurface*>(surface); *native = (EGLNativeWindowType)(nsurface->nativeDrawable()); return true; }
void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) { Q_Q(QWidget); if (extra) { // any size restrictions? w = qMin(w,extra->maxw); h = qMin(h,extra->maxh); w = qMax(w,extra->minw); h = qMax(h,extra->minh); } QPoint oldp = q->geometry().topLeft(); QSize olds = q->size(); QRect r(x, y, w, h); bool isResize = olds != r.size(); isMove = oldp != r.topLeft(); //### why do we have isMove as a parameter? // We only care about stuff that changes the geometry, or may // cause the window manager to change its state if (r.size() == olds && oldp == r.topLeft()) return; if (!data.in_set_window_state) { q->data->window_state &= ~Qt::WindowMaximized; q->data->window_state &= ~Qt::WindowFullScreen; if (q->isWindow()) topData()->normalGeometry = QRect(0, 0, -1, -1); } QPoint oldPos = q->pos(); data.crect = r; if ((q->windowType() == Qt::Desktop)) return; if (q->isVisible()) { bool toplevelMove = false; QWSWindowSurface *surface = 0; if (q->isWindow()) { //### ConfigPending not implemented, do we need it? //setAttribute(Qt::WA_WState_ConfigPending); const QWidgetBackingStore *bs = maybeBackingStore(); if (bs) surface = static_cast<QWSWindowSurface*>(bs->windowSurface); if (isMove && !isResize && surface) { const QPoint offset(x - oldp.x(), y - oldp.y()); moveSurface(surface, offset); toplevelMove = true; //server moves window, but we must send moveEvent, which might trigger painting #ifdef Q_BACKINGSTORE_SUBSURFACES QList<QWindowSurface*> surfaces = bs->subSurfaces; for (int i = 0; i < surfaces.size(); ++i) moveSurface(surfaces.at(i), offset); #endif } else { updateFrameStrut(); } } if (!toplevelMove) { if (q->isWindow()) { if (surface) surface->setGeometry(q->frameGeometry()); else invalidateBuffer(q->rect()); //### #ifdef Q_BACKINGSTORE_SUBSURFACES // XXX: should not resize subsurfaces. Children within a layout // will be resized automatically while children with a static // geometry should get a new clip region instead. const QRect clipRect = q->geometry(); QWidgetBackingStore *bs = maybeBackingStore(); QList<QWindowSurface*> surfaces = bs->subSurfaces; for (int i = 0; i < surfaces.size(); ++i) { QWSWindowSurface *s = static_cast<QWSWindowSurface*>(surfaces.at(i)); QRect srect = s->geometry(); s->setGeometry(clipRect & srect); } #endif } #ifdef Q_BACKINGSTORE_SUBSURFACES // XXX: merge this case with the isWindow() case else if (maybeTopData() && maybeTopData()->windowSurface) { QWSWindowSurface *surface; surface = static_cast<QWSWindowSurface*>(q->windowSurface()); if (isMove && !isResize) { moveSurface(surface, QPoint(x - oldp.x(), y - oldp.y())); } else { const QPoint p = q->mapToGlobal(QPoint()); surface->setGeometry(QRect(p, QSize(w, h))); } } #endif else { if (isMove && !isResize) moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y()); else invalidateBuffer_resizeHelper(oldPos, olds); } } //### must have frame geometry correct before sending move/resize events if (isMove) { QMoveEvent e(q->pos(), oldPos); QApplication::sendEvent(q, &e); } if (isResize) { QResizeEvent e(r.size(), olds); QApplication::sendEvent(q, &e); } } else { // not visible if (isMove && q->pos() != oldPos) q->setAttribute(Qt::WA_PendingMoveEvent, true); if (isResize) q->setAttribute(Qt::WA_PendingResizeEvent, true); } }
void QWidgetPrivate::show_sys() { Q_Q(QWidget); q->setAttribute(Qt::WA_Mapped); if (q->testAttribute(Qt::WA_DontShowOnScreen)) { invalidateBuffer(q->rect()); return; } if (q->isWindow()) { if (!q->testAttribute(Qt::WA_ShowWithoutActivating) && q->windowType() != Qt::Popup && q->windowType() != Qt::Tool && q->windowType() != Qt::ToolTip) { QWidget::qwsDisplay()->requestFocus(data.winid,true); } if (QWindowSurface *surface = q->windowSurface()) { const QRect frameRect = q->frameGeometry(); if (surface->geometry() != frameRect) surface->setGeometry(frameRect); } QRegion r = localRequestedRegion(); #ifndef QT_NO_QWS_MANAGER if (extra && extra->topextra && extra->topextra->qwsManager) { r.translate(data.crect.topLeft()); r += extra->topextra->qwsManager->region(); r.translate(-data.crect.topLeft()); } #endif data.fstrut_dirty = true; invalidateBuffer(r); bool staysontop = (q->windowFlags() & Qt::WindowStaysOnTopHint) || q->windowType() == Qt::Popup; if (!staysontop && q->parentWidget()) { // if our parent stays on top, so must we QWidget *ptl = q->parentWidget()->window(); if (ptl && (ptl->windowFlags() & Qt::WindowStaysOnTopHint)) staysontop = true; } QWSChangeAltitudeCommand::Altitude altitude; altitude = staysontop ? QWSChangeAltitudeCommand::StaysOnTop : QWSChangeAltitudeCommand::Raise; QWidget::qwsDisplay()->setAltitude(data.winid, altitude, true); if (!q->objectName().isEmpty()) { QWidget::qwsDisplay()->setWindowCaption(q, q->windowTitle()); } } #ifdef Q_BACKINGSTORE_SUBSURFACES else if ( extra && extra->topextra && extra->topextra->windowSurface) { QWSWindowSurface *surface; surface = static_cast<QWSWindowSurface*>(q->windowSurface()); const QPoint p = q->mapToGlobal(QPoint()); surface->setGeometry(QRect(p, q->size())); } #endif if (!q->window()->data->in_show) { invalidateBuffer(q->rect()); } }