diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2010-10-07 15:46:13 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2011-01-25 17:50:58 (GMT) |
commit | 918baf0ce0132d7751751c3b1a6a5cae3eb566e7 (patch) | |
tree | 2770b1f6c2eb2064bbd0c0fe85fbe706dfd8ab19 /src | |
parent | 3c2bb14b11f590f425281184ae6a1dadb98d6326 (diff) | |
download | Qt-918baf0ce0132d7751751c3b1a6a5cae3eb566e7.zip Qt-918baf0ce0132d7751751c3b1a6a5cae3eb566e7.tar.gz Qt-918baf0ce0132d7751751c3b1a6a5cae3eb566e7.tar.bz2 |
wayland: Create and destroy surface at show and hide
Diffstat (limited to 'src')
4 files changed, 35 insertions, 10 deletions
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index c93ff25..277e965 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -210,15 +210,28 @@ QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) QWaylandWindow::QWaylandWindow(QWidget *window, QWaylandDisplay *display) : QPlatformWindow(window) + , mSurface(0) , mDisplay(display) { - mSurface = mDisplay->createSurface(); - wl_surface_set_user_data(mSurface, this); } QWaylandWindow::~QWaylandWindow() { - /* mDisplay->destroySurface() */ +} + +void QWaylandWindow::setVisible(bool visible) +{ + QWaylandWindowSurface *wws = + (QWaylandWindowSurface *) widget()->windowSurface(); + + if (visible) { + mSurface = mDisplay->createSurface(); + wl_surface_set_user_data(mSurface, this); + wws->attach(); + } else { + wl_surface_destroy(mSurface); + mSurface = NULL; + } } QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWidget *widget, WId winId) const diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index 20d890e..4e50f3c 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -131,6 +131,8 @@ public: ~QWaylandWindow(); struct wl_surface *surface() { return mSurface; } + void setVisible(bool visible); + private: struct wl_surface *mSurface; QWaylandDisplay *mDisplay; diff --git a/src/plugins/platforms/wayland/qwaylandwindowsurface.cpp b/src/plugins/platforms/wayland/qwaylandwindowsurface.cpp index f0f5018..41f72d0 100644 --- a/src/plugins/platforms/wayland/qwaylandwindowsurface.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindowsurface.cpp @@ -87,10 +87,19 @@ void QWaylandWindowSurface::flush(QWidget *widget, const QRegion ®ion, const } } +void QWaylandWindowSurface::attach(void) +{ + QWaylandWindow *ww = (QWaylandWindow *) window()->platformWindow(); + + if (ww->surface()) { + wl_surface_attach(ww->surface(), mBuffer); + wl_surface_map(ww->surface(), 0, 0, mImage->width(), mImage->height()); + } +} + void QWaylandWindowSurface::resize(const QSize &size) { //qDebug() << "QWaylandWindowSurface::setGeometry:" << (long)this << rect; - QWaylandWindow *ww = (QWaylandWindow *) window()->platformWindow(); QWindowSurface::resize(size); QImage::Format format = QApplicationPrivate::platformIntegration()->screens().first()->format(); @@ -100,6 +109,7 @@ void QWaylandWindowSurface::resize(const QSize &size) if (mImage != NULL) { delete mImage; munmap(mData, mSize); + wl_buffer_destroy(mBuffer); } mStride = size.width() * 4; @@ -119,13 +129,11 @@ void QWaylandWindowSurface::resize(const QSize &size) mImage = new QImage(mData, size.width(), size.height(), mStride, format); - struct wl_buffer *buffer = - mDisplay->createShmBuffer(fd, size.width(), size.height(), - mStride, mDisplay->argbVisual()); - wl_surface_attach(ww->surface(), buffer); - wl_surface_map(ww->surface(), 0, 0, size.width(), size.height()); - wl_buffer_destroy(buffer); + mBuffer = mDisplay->createShmBuffer(fd, size.width(), size.height(), + mStride, mDisplay->argbVisual()); close(fd); + + attach(); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/qwaylandwindowsurface.h b/src/plugins/platforms/wayland/qwaylandwindowsurface.h index 1054c51..1da6ab4 100644 --- a/src/plugins/platforms/wayland/qwaylandwindowsurface.h +++ b/src/plugins/platforms/wayland/qwaylandwindowsurface.h @@ -57,6 +57,7 @@ public: QPaintDevice *paintDevice(); void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); void resize(const QSize &size); + void attach(void); private: QImage *mImage; @@ -64,6 +65,7 @@ private: int mSize; int mStride; QWaylandDisplay *mDisplay; + struct wl_buffer *mBuffer; }; QT_END_NAMESPACE |