Skip to content

Commit

Permalink
Merge pull request #48 from adenexter/jb32661
Browse files Browse the repository at this point in the history
[wayland] Fix compositor blocking clients when the screen is off. Fixes JB#32661
  • Loading branch information
Chris Adams committed Oct 23, 2015
2 parents 4be829e + b611c5c commit ef6614a
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions src/compositor/compositor_api/qwaylandquicksurface.cpp
Expand Up @@ -53,6 +53,40 @@

QT_BEGIN_NAMESPACE

class QWaylandSurfaceTexture : public QSGTexture
{
public:
QWaylandSurfaceTexture(const QWaylandBufferRef &ref, QWaylandQuickSurface *surface)
: m_bufferRef(ref)
, m_textureSize(surface->size())
, m_textureId(m_bufferRef.createTexture())
, m_hasAlphaChannel(surface->useTextureAlpha())
{
}

~QWaylandSurfaceTexture()
{
m_bufferRef.destroyTexture();
}

int textureId() const { return m_textureId; }
QSize textureSize() const { return m_textureSize; }
bool hasAlphaChannel() const { return m_hasAlphaChannel; }
bool hasMipmaps() const { return false; }

void bind()
{
glBindTexture(GL_TEXTURE_2D, m_textureId);
updateBindOptions();
}

private:
QWaylandBufferRef m_bufferRef;
QSize m_textureSize;
int m_textureId;
bool m_hasAlphaChannel;
};

class BufferAttacher : public QWaylandBufferAttacher
{
public:
Expand Down Expand Up @@ -89,11 +123,7 @@ class BufferAttacher : public QWaylandBufferAttacher
if (bufferRef.isShm()) {
texture = window->createTextureFromImage(bufferRef.image());
} else {
QQuickWindow::CreateTextureOptions opt = 0;
if (surface->useTextureAlpha()) {
opt |= QQuickWindow::TextureHasAlphaChannel;
}
texture = window->createTextureFromId(bufferRef.createTexture(), surface->size(), opt);
texture = new QWaylandSurfaceTexture(bufferRef, surface);
}
texture->bind();
}
Expand Down Expand Up @@ -169,6 +199,7 @@ QWaylandQuickSurface::QWaylandQuickSurface(wl_client *client, quint32 id, int ve
QQuickWindow *window = static_cast<QQuickWindow *>(compositor->window());
connect(window, &QQuickWindow::beforeSynchronizing, this, &QWaylandQuickSurface::updateTexture, Qt::DirectConnection);
connect(window, &QQuickWindow::sceneGraphInvalidated, this, &QWaylandQuickSurface::invalidateTexture, Qt::DirectConnection);
connect(window, &QQuickWindow::sceneGraphAboutToStop, this, &QWaylandQuickSurface::invalidateTexture, Qt::DirectConnection);
connect(this, &QWaylandSurface::windowPropertyChanged, d->windowPropertyMap, &QQmlPropertyMap::insert);
connect(d->windowPropertyMap, &QQmlPropertyMap::valueChanged, this, &QWaylandSurface::setWindowProperty);

Expand Down

0 comments on commit ef6614a

Please sign in to comment.