Update QtCompositor API to use wayland 1.0.0
authorAndy Nichols <andy.nichols@digia.com>
Fri, 2 Nov 2012 19:21:16 +0000 (20:21 +0100)
committerAndy Nichols <andy.nichols@digia.com>
Sun, 4 Nov 2012 19:58:30 +0000 (20:58 +0100)
Change-Id: I6b598595cdb8ff91d5146e0ae2511752bcfa473f
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
config.tests/wayland_egl/main.cpp
src/compositor/wayland_wrapper/wlcompositor.cpp
src/compositor/wayland_wrapper/wlsurface.cpp
src/compositor/wayland_wrapper/wlsurface.h
wayland_sha1.txt

index 8a0c746..9899a0e 100644 (file)
@@ -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;
 }
index 841e2ea..8c1b057 100644 (file)
@@ -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>
@@ -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;
@@ -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
 }
@@ -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)
index a348cdd..d05f36b 100644 (file)
@@ -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;
@@ -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 = {
@@ -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)
@@ -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) {
index e9141b2..642e8f7 100644 (file)
@@ -166,6 +166,7 @@ private:
     SurfaceBuffer *createSurfaceBuffer(struct wl_buffer *buffer);
     void frameFinishedInternal();
     bool postBuffer();
+    void commit();
 
     void attach(struct wl_buffer *buffer);
 
@@ -180,6 +181,7 @@ private:
                                           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);
 
 };
 
index 8aba759..dad1dd3 100644 (file)
@@ -1,3 +1,3 @@
 This version of Qt-Compositor is checked against the following sha1 from the
 Wayland repository:
-4b681a7fd4bee01c4d3385e69ee47ed3856c2229
+1f521a4f7760df73e1d1d8a6791d1c7bf536584e