summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@digia.com>2013-06-05 15:24:05 +0200
committerAndy Nichols <andy.nichols@digia.com>2013-06-06 10:51:52 +0200
commit99774144586164729df58518235407f1f0531c39 (patch)
treec032278b44172f77782f5676e23525924e2dca0a
parentf4b88255a45b09da0fee8ffe24b9eca6785e0de3 (diff)
Make the Compositor side of extended surface use the QtWaylandScanner
Change-Id: I9b71f78c1db4aa4044dde25881d74a7c519046a8 Reviewed-by: Andy Nichols <andy.nichols@digia.com>
-rw-r--r--src/compositor/wayland_wrapper/qwlextendedsurface.cpp98
-rw-r--r--src/compositor/wayland_wrapper/qwlextendedsurface_p.h40
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface.cpp1
3 files changed, 45 insertions, 94 deletions
diff --git a/src/compositor/wayland_wrapper/qwlextendedsurface.cpp b/src/compositor/wayland_wrapper/qwlextendedsurface.cpp
index 19df7eb25..3ab886489 100644
--- a/src/compositor/wayland_wrapper/qwlextendedsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlextendedsurface.cpp
@@ -48,52 +48,30 @@ QT_BEGIN_NAMESPACE
namespace QtWayland {
SurfaceExtensionGlobal::SurfaceExtensionGlobal(Compositor *compositor)
- : m_compositor(compositor)
+ : QtWaylandServer::qt_surface_extension(compositor->wl_display())
{
- wl_display_add_global(m_compositor->wl_display(),
- &qt_surface_extension_interface,
- this,
- SurfaceExtensionGlobal::bind_func);
}
-void SurfaceExtensionGlobal::bind_func(struct wl_client *client, void *data,
- uint32_t version, uint32_t id)
+void SurfaceExtensionGlobal::surface_extension_get_extended_surface(Resource *resource,
+ uint32_t id,
+ struct wl_resource *surface_resource)
{
- Q_UNUSED(version);
- wl_client_add_object(client, &qt_surface_extension_interface,&surface_extension_interface,id,data);
-}
-
-const struct qt_surface_extension_interface SurfaceExtensionGlobal::surface_extension_interface = {
- SurfaceExtensionGlobal::get_extended_surface
-};
-
-void SurfaceExtensionGlobal::get_extended_surface(struct wl_client *client,
- struct wl_resource *surface_extension_resource,
- uint32_t id,
- struct wl_resource *surface_resource)
-{
- Q_UNUSED(surface_extension_resource);
Surface *surface = Surface::fromResource(surface_resource);
- new ExtendedSurface(client,id,surface);
+ new ExtendedSurface(resource->client(),id,surface);
}
ExtendedSurface::ExtendedSurface(struct wl_client *client, uint32_t id, Surface *surface)
- : m_surface(surface)
+ : QtWaylandServer::qt_extended_surface(client,id)
+ , m_surface(surface)
, m_contentOrientation(Qt::PrimaryOrientation)
, m_windowFlags(0)
{
Q_ASSERT(surface->extendedSurface() == 0);
- m_extended_surface_resource = wl_client_add_object(client,
- &qt_extended_surface_interface,
- &extended_surface_interface,
- id,
- this);
surface->setExtendedSurface(this);
}
ExtendedSurface::~ExtendedSurface()
{
-
}
void ExtendedSurface::sendGenericProperty(const QString &name, const QVariant &variant)
@@ -101,31 +79,27 @@ void ExtendedSurface::sendGenericProperty(const QString &name, const QVariant &v
QByteArray byteValue;
QDataStream ds(&byteValue, QIODevice::WriteOnly);
ds << variant;
- wl_array data;
- data.size = byteValue.size();
- data.data = (void*) byteValue.constData();
- data.alloc = 0;
- qt_extended_surface_send_set_generic_property(m_extended_surface_resource, qPrintable(name), &data);
+ send_set_generic_property(name, byteValue);
}
void ExtendedSurface::sendOnScreenVisibility(bool visible)
{
int32_t visibleInt = visible;
- qt_extended_surface_send_onscreen_visibility(m_extended_surface_resource, visibleInt);
+ send_onscreen_visibility(visibleInt);
}
-void ExtendedSurface::update_generic_property(wl_client *client, wl_resource *extended_surface_resource, const char *name, wl_array *value)
+void ExtendedSurface::extended_surface_update_generic_property(Resource *resource,
+ const QString &name,
+ struct wl_array *value)
{
- Q_UNUSED(client);
- ExtendedSurface *extended_surface = static_cast<ExtendedSurface *>(extended_surface_resource->data);
+ Q_UNUSED(resource);
QVariant variantValue;
QByteArray byteValue((const char*)value->data, value->size);
QDataStream ds(&byteValue, QIODevice::ReadOnly);
ds >> variantValue;
- extended_surface->setWindowProperty(QString::fromLatin1(name),variantValue,false);
-
+ setWindowProperty(name,variantValue,false);
}
static Qt::ScreenOrientation screenOrientationFromWaylandOrientation(int32_t orientation)
@@ -144,25 +118,13 @@ Qt::ScreenOrientation ExtendedSurface::contentOrientation() const
return m_contentOrientation;
}
-void ExtendedSurface::set_content_orientation(struct wl_client *client,
- struct wl_resource *extended_surface_resource,
- int32_t orientation)
-{
- Q_UNUSED(client);
- ExtendedSurface *extended_surface = static_cast<ExtendedSurface *>(extended_surface_resource->data);
-
- Qt::ScreenOrientation oldOrientation = extended_surface->m_contentOrientation;
- extended_surface->m_contentOrientation = screenOrientationFromWaylandOrientation(orientation);
- if (extended_surface->m_contentOrientation != oldOrientation)
- emit extended_surface->m_surface->waylandSurface()->contentOrientationChanged();
-}
-
-void ExtendedSurface::setWindowFlags(QWaylandSurface::WindowFlags flags)
+void ExtendedSurface::extended_surface_set_content_orientation(Resource *resource, int32_t orientation)
{
- if (flags == m_windowFlags)
- return;
- m_windowFlags = flags;
- emit m_surface->waylandSurface()->windowFlagsChanged(flags);
+ Q_UNUSED(resource);
+ Qt::ScreenOrientation oldOrientation = m_contentOrientation;
+ m_contentOrientation = screenOrientationFromWaylandOrientation(orientation);
+ if (m_contentOrientation != oldOrientation)
+ emit m_surface->waylandSurface()->contentOrientationChanged();
}
QVariantMap ExtendedSurface::windowProperties() const
@@ -184,18 +146,20 @@ void ExtendedSurface::setWindowProperty(const QString &name, const QVariant &val
sendGenericProperty(name, value);
}
-void ExtendedSurface::set_window_flags(wl_client *client, wl_resource *resource, int32_t flags)
+void ExtendedSurface::extended_surface_set_window_flags(Resource *resource, int32_t flags)
{
- Q_UNUSED(client);
- ExtendedSurface *extended_surface = static_cast<ExtendedSurface *>(resource->data);
- extended_surface->setWindowFlags(QWaylandSurface::WindowFlags(flags));
+ Q_UNUSED(resource);
+ QWaylandSurface::WindowFlags windowFlags(flags);
+ if (windowFlags== m_windowFlags)
+ return;
+ m_windowFlags = windowFlags;
+ emit m_surface->waylandSurface()->windowFlagsChanged(windowFlags);
}
-const struct qt_extended_surface_interface ExtendedSurface::extended_surface_interface = {
- ExtendedSurface::update_generic_property,
- ExtendedSurface::set_content_orientation,
- ExtendedSurface::set_window_flags
-};
+void ExtendedSurface::extended_surface_destroy_resource(Resource *)
+{
+ delete this;
+}
}
diff --git a/src/compositor/wayland_wrapper/qwlextendedsurface_p.h b/src/compositor/wayland_wrapper/qwlextendedsurface_p.h
index 20fbcc404..a28ed1b59 100644
--- a/src/compositor/wayland_wrapper/qwlextendedsurface_p.h
+++ b/src/compositor/wayland_wrapper/qwlextendedsurface_p.h
@@ -42,8 +42,8 @@
#define WLEXTENDEDSURFACE_H
#include <wayland-server.h>
-#include "wayland-surface-extension-server-protocol.h"
+#include "qwayland-server-surface-extension.h"
#include <private/qwlsurface_p.h>
#include <QtCompositor/qwaylandsurface.h>
@@ -58,25 +58,19 @@ namespace QtWayland {
class Compositor;
-class SurfaceExtensionGlobal
+class SurfaceExtensionGlobal : public QtWaylandServer::qt_surface_extension
{
public:
SurfaceExtensionGlobal(Compositor *compositor);
private:
- Compositor *m_compositor;
-
- static void bind_func(struct wl_client *client, void *data,
- uint32_t version, uint32_t id);
- static void get_extended_surface(struct wl_client *client,
- struct wl_resource *resource,
- uint32_t id,
- struct wl_resource *surface);
- static const struct qt_surface_extension_interface surface_extension_interface;
+ void surface_extension_get_extended_surface(Resource *resource,
+ uint32_t id,
+ struct wl_resource *surface);
};
-class ExtendedSurface
+class ExtendedSurface : public QtWaylandServer::qt_extended_surface
{
public:
ExtendedSurface(struct wl_client *client, uint32_t id, Surface *surface);
@@ -100,7 +94,6 @@ public:
void setWindowProperty(const QString &name, const QVariant &value, bool writeUpdateToClient = true);
private:
- struct wl_resource *m_extended_surface_resource;
Surface *m_surface;
Qt::ScreenOrientation m_contentOrientation;
@@ -110,22 +103,17 @@ private:
QByteArray m_authenticationToken;
QVariantMap m_windowProperties;
+ void extended_surface_update_generic_property(Resource *resource,
+ const QString &name,
+ struct wl_array *value) Q_DECL_OVERRIDE;
- static void update_generic_property(struct wl_client *client,
- struct wl_resource *resource,
- const char *name,
- struct wl_array *value);
-
- static void set_content_orientation(struct wl_client *client,
- struct wl_resource *resource,
- int32_t orientation);
+ void extended_surface_set_content_orientation(Resource *resource,
+ int32_t orientation) Q_DECL_OVERRIDE;
- static void set_window_flags(struct wl_client *client,
- struct wl_resource *resource,
- int32_t flags);
- void setWindowFlags(QWaylandSurface::WindowFlags flags);
+ void extended_surface_set_window_flags(Resource *resource,
+ int32_t flags) Q_DECL_OVERRIDE;
- static const struct qt_extended_surface_interface extended_surface_interface;
+ void extended_surface_destroy_resource(Resource *) Q_DECL_OVERRIDE;
};
}
diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp
index 85dfddb42..de4aa240a 100644
--- a/src/compositor/wayland_wrapper/qwlsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlsurface.cpp
@@ -95,7 +95,6 @@ Surface::Surface(struct wl_client *client, uint32_t id, Compositor *compositor)
Surface::~Surface()
{
delete m_waylandSurface;
- delete m_extendedSurface;
delete m_subSurface;
for (int i = 0; i < buffer_pool_size; i++) {