Skip to content

Commit

Permalink
Update QtCompositor API to use wayland 1.0.0
Browse files Browse the repository at this point in the history
Change-Id: I6b598595cdb8ff91d5146e0ae2511752bcfa473f
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
  • Loading branch information
Andy Nichols committed Nov 4, 2012
1 parent 0f6ffad commit 5a55619
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion config.tests/wayland_egl/main.cpp
Expand Up @@ -42,7 +42,7 @@

int main()
{
struct wl_egl_pixmap *pm = wl_egl_pixmap_create(100,100,0);
struct wl_egl_window *window = wl_egl_window_create(0,100,100);

return 0;
}
8 changes: 7 additions & 1 deletion src/compositor/wayland_wrapper/wlcompositor.cpp
Expand Up @@ -63,6 +63,9 @@
#include <qpa/qplatformscreenpageflipper.h>
#include <QDebug>

#include <QtCore/QAbstractEventDispatcher>
#include <QtGui/private/qguiapplication_p.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -109,7 +112,6 @@ void Compositor::bind_func(struct wl_client *client, void *data,
wl_client_add_object(client,&wl_compositor_interface, &compositor_interface, id,data);
}


Compositor *Compositor::instance()
{
return compositor;
Expand Down Expand Up @@ -172,6 +174,9 @@ Compositor::Compositor(WaylandCompositor *qt_compositor)
QSocketNotifier *sockNot = new QSocketNotifier(fd, QSocketNotifier::Read, this);
connect(sockNot, SIGNAL(activated(int)), this, SLOT(processWaylandEvents()));

QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(processWaylandEvents()));

qRegisterMetaType<SurfaceBuffer*>("SurfaceBuffer*");
//initialize distancefieldglyphcache here
}
Expand Down Expand Up @@ -267,6 +272,7 @@ void Compositor::processWaylandEvents()
int ret = wl_event_loop_dispatch(m_loop, 0);
if (ret)
fprintf(stderr, "wl_event_loop_dispatch error: %d\n", ret);
wl_display_flush_clients(m_display->handle());
}

void Compositor::surfaceDestroyed(Surface *surface)
Expand Down
22 changes: 16 additions & 6 deletions src/compositor/wayland_wrapper/wlsurface.cpp
Expand Up @@ -399,6 +399,14 @@ bool Surface::postBuffer() {
return false;
}

void Surface::commit()
{
if (!m_bufferQueue.isEmpty() && !m_backBuffer)
advanceBufferQueue();

doUpdate();
}

void Surface::attach(struct wl_buffer *buffer)
{
SurfaceBuffer *last = m_bufferQueue.size()?m_bufferQueue.last():0;
Expand Down Expand Up @@ -429,11 +437,6 @@ void Surface::damage(const QRect &rect)
surfaceBuffer->setDamage(rect);
else
qWarning() << "Surface::damage() null buffer";

if (!m_bufferQueue.isEmpty() && !m_backBuffer)
advanceBufferQueue();

doUpdate();
}

const struct wl_surface_interface Surface::surface_interface = {
Expand All @@ -442,7 +445,8 @@ const struct wl_surface_interface Surface::surface_interface = {
Surface::surface_damage,
Surface::surface_frame,
Surface::surface_set_opaque_region,
Surface::surface_set_input_region
Surface::surface_set_input_region,
Surface::surface_commit
};

void Surface::surface_destroy(struct wl_client *, struct wl_resource *surface_resource)
Expand Down Expand Up @@ -491,6 +495,12 @@ void Surface::surface_set_input_region(struct wl_client *client, struct wl_resou
surface->m_inputRegion = region ? resolve<Region>(region)->region() : QRegion(QRect(QPoint(), surface->size()));
}

void Surface::surface_commit(wl_client *client, wl_resource *resource)
{
Q_UNUSED(client);
resolve<Surface>(resource)->commit();
}

void Surface::setTitle(const QString &title)
{
if (m_title != title) {
Expand Down
2 changes: 2 additions & 0 deletions src/compositor/wayland_wrapper/wlsurface.h
Expand Up @@ -166,6 +166,7 @@ class Q_COMPOSITOR_EXPORT Surface : public Object<struct wl_surface>
SurfaceBuffer *createSurfaceBuffer(struct wl_buffer *buffer);
void frameFinishedInternal();
bool postBuffer();
void commit();

void attach(struct wl_buffer *buffer);

Expand All @@ -180,6 +181,7 @@ class Q_COMPOSITOR_EXPORT Surface : public Object<struct wl_surface>
struct wl_resource *region);
static void surface_set_input_region(struct wl_client *client, struct wl_resource *resource,
struct wl_resource *region);
static void surface_commit(struct wl_client *client, struct wl_resource *resource);

};

Expand Down
2 changes: 1 addition & 1 deletion wayland_sha1.txt
@@ -1,3 +1,3 @@
This version of Qt-Compositor is checked against the following sha1 from the
Wayland repository:
4b681a7fd4bee01c4d3385e69ee47ed3856c2229
1f521a4f7760df73e1d1d8a6791d1c7bf536584e

0 comments on commit 5a55619

Please sign in to comment.