From 04bb7c0a1154ec120717caef217dc5c6fbf62ed3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B8rgen=20Lind?= Date: Wed, 6 Apr 2011 10:16:51 +0200 Subject: [PATCH] Lighthouse: Implement xcomposite extension for wayland --- .../wayland/gl_integration/gl_integration.pri | 4 + .../qwaylandxcompositeglxcontext.cpp | 101 +++++++++++++++++ .../xcomposite_glx/qwaylandxcompositeglxcontext.h | 43 +++++++ .../qwaylandxcompositeglxintegration.cpp | 85 ++++++++++++++ .../qwaylandxcompositeglxintegration.h | 52 +++++++++ .../xcomposite_glx/qwaylandxcompositeglxwindow.cpp | 36 ++++++ .../xcomposite_glx/qwaylandxcompositeglxwindow.h | 24 ++++ .../xcomposite_glx/xcomposite_glx.pri | 13 +++ .../xcomposite_share/qwaylandxcompositebuffer.cpp | 18 +++ .../xcomposite_share/qwaylandxcompositebuffer.h | 21 ++++ .../wayland-xcomposite-client-protocol.h | 126 +++++++++++++++++++++ .../xcomposite_share/wayland-xcomposite-protocol.c | 41 +++++++ .../xcomposite_share/xcomposite_share.pri | 9 ++ 13 files changed, 573 insertions(+) create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_share/xcomposite_share.pri diff --git a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri index 10567cd..52272c3 100644 --- a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri +++ b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri @@ -17,3 +17,7 @@ xpixmap_egl { xpixmap_glx { include ($$PWD/xpixmap_glx/xpixmap_glx.pri) } + +xcomposite_glx { + include ($$PWD/xcomposite_glx/xcomposite_glx.pri) +} diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp new file mode 100644 index 0000000..679772c --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp @@ -0,0 +1,101 @@ +#include "qwaylandxcompositeglxcontext.h" + +#include "qwaylandxcompositeglxwindow.h" +#include "qwaylandxcompositebuffer.h" + +#include "wayland-xcomposite-client-protocol.h" +#include + +#include + +QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(QWaylandXCompositeGLXIntegration *glxIntegration, QWaylandXCompositeGLXWindow *window) + : QPlatformGLContext() + , mGlxIntegration(glxIntegration) + , mWindow(window) + , mBuffer(0) + , mXWindow(0) + , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat())) +{ + XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig); + mContext = glXCreateContext(glxIntegration->xDisplay(),visualInfo,0,TRUE); + + geometryChanged(); +} + +void QWaylandXCompositeGLXContext::makeCurrent() +{ + QPlatformGLContext::makeCurrent(); + glXMakeCurrent(mGlxIntegration->xDisplay(),mXWindow,mContext); +} + +void QWaylandXCompositeGLXContext::doneCurrent() +{ + glXMakeCurrent(mGlxIntegration->xDisplay(),0,0); + QPlatformGLContext::doneCurrent(); +} + +void QWaylandXCompositeGLXContext::swapBuffers() +{ + QSize size = mWindow->geometry().size(); + + glXSwapBuffers(mGlxIntegration->xDisplay(),mXWindow); + mWindow->damage(QRegion(QRect(QPoint(0,0),size))); + mWindow->waitForFrameSync(); +} + +void * QWaylandXCompositeGLXContext::getProcAddress(const QString &procName) +{ + return (void *) glXGetProcAddress(reinterpret_cast(procName.toLatin1().data())); +} + +QPlatformWindowFormat QWaylandXCompositeGLXContext::platformWindowFormat() const +{ + return qglx_platformWindowFromGLXFBConfig(mGlxIntegration->xDisplay(),mConfig,mContext); +} + +void QWaylandXCompositeGLXContext::sync_function(void *data) +{ + QWaylandXCompositeGLXContext *that = static_cast(data); + that->mWaitCondition.wakeAll(); +} + +void QWaylandXCompositeGLXContext::geometryChanged() +{ + QSize size(mWindow->geometry().size()); + if (size.isEmpty()) { + //QGLWidget wants a context for a window without geometry + size = QSize(1,1); + } + + delete mBuffer; + //XFreePixmap deletes the glxPixmap as well + if (mXWindow) { + XDestroyWindow(mGlxIntegration->xDisplay(),mXWindow); + } + + XVisualInfo *visualInfo = glXGetVisualFromFBConfig(mGlxIntegration->xDisplay(),mConfig); + Colormap cmap = XCreateColormap(mGlxIntegration->xDisplay(),mGlxIntegration->rootWindow(),visualInfo->visual,AllocNone); + + XSetWindowAttributes a; + a.colormap = cmap; + mXWindow = XCreateWindow(mGlxIntegration->xDisplay(), mGlxIntegration->rootWindow(),0, 0, size.width(), size.height(), + 0, visualInfo->depth, InputOutput, visualInfo->visual, + CWColormap, &a); + + XCompositeRedirectWindow(mGlxIntegration->xDisplay(), mXWindow, CompositeRedirectManual); + XMapWindow(mGlxIntegration->xDisplay(), mXWindow); + + XSync(mGlxIntegration->xDisplay(),False); + mBuffer = new QWaylandXCompositeBuffer(mGlxIntegration->waylandXComposite(), + (uint32_t)mXWindow, + size, + mGlxIntegration->waylandDisplay()->argbVisual()); + mWindow->attach(mBuffer); + wl_display_sync_callback(mGlxIntegration->waylandDisplay()->wl_display(), + QWaylandXCompositeGLXContext::sync_function, + this); + QMutex lock; + lock.lock(); + wl_display_sync(mGlxIntegration->waylandDisplay()->wl_display(),0); + mWaitCondition.wait(&lock); +} diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h new file mode 100644 index 0000000..e5ccd9e --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h @@ -0,0 +1,43 @@ +#ifndef QWAYLANDXCOMPOSITEGLXCONTEXT_H +#define QWAYLANDXCOMPOSITEGLXCONTEXT_H + +#include + +#include + +#include "qwaylandbuffer.h" +#include "qwaylandxcompositeglxintegration.h" + +#include "qglxconvenience.h" + +class QWaylandXCompositeGLXWindow; +class QWaylandShmBuffer; + +class QWaylandXCompositeGLXContext : public QPlatformGLContext +{ +public: + QWaylandXCompositeGLXContext(QWaylandXCompositeGLXIntegration *glxIntegration, QWaylandXCompositeGLXWindow *window); + + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void* getProcAddress(const QString& procName); + + QPlatformWindowFormat platformWindowFormat() const; + + void geometryChanged(); + +private: + QWaylandXCompositeGLXIntegration *mGlxIntegration; + QWaylandXCompositeGLXWindow *mWindow; + QWaylandBuffer *mBuffer; + + Window mXWindow; + GLXFBConfig mConfig; + GLXContext mContext; + + static void sync_function(void *data); + QWaitCondition mWaitCondition; +}; + +#endif // QWAYLANDXCOMPOSITEGLXCONTEXT_H diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp new file mode 100644 index 0000000..dce3d27 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp @@ -0,0 +1,85 @@ +#include "qwaylandxcompositeglxintegration.h" + +#include "qwaylandxcompositeglxwindow.h" + +#include + +#include "wayland-xcomposite-client-protocol.h" + +QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) +{ + return new QWaylandXCompositeGLXIntegration(waylandDisplay); +} + +QWaylandXCompositeGLXIntegration::QWaylandXCompositeGLXIntegration(QWaylandDisplay * waylandDispaly) + : QWaylandGLIntegration() + , mWaylandDisplay(waylandDispaly) +{ + wl_display_add_global_listener(waylandDispaly->wl_display(), QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal, + this); +} + +QWaylandXCompositeGLXIntegration::~QWaylandXCompositeGLXIntegration() +{ + XCloseDisplay(mDisplay); +} + +void QWaylandXCompositeGLXIntegration::initialize() +{ +} + +QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWidget *widget) +{ + return new QWaylandXCompositeGLXWindow(widget,this); +} + +Display * QWaylandXCompositeGLXIntegration::xDisplay() const +{ + return mDisplay; +} + +int QWaylandXCompositeGLXIntegration::screen() const +{ + return mScreen; +} + +Window QWaylandXCompositeGLXIntegration::rootWindow() const +{ + return mRootWindow; +} + +QWaylandDisplay * QWaylandXCompositeGLXIntegration::waylandDisplay() const +{ + return mWaylandDisplay; +} +wl_xcomposite * QWaylandXCompositeGLXIntegration::waylandXComposite() const +{ + return mWaylandComposite; +} + +const struct wl_xcomposite_listener QWaylandXCompositeGLXIntegration::xcomposite_listener = { + QWaylandXCompositeGLXIntegration::rootInformation +}; + +void QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data) +{ + Q_UNUSED(version); + if (strcmp(interface, "xcomposite") == 0) { + QWaylandXCompositeGLXIntegration *integration = static_cast(data); + integration->mWaylandComposite = wl_xcomposite_create(display,id); + wl_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration); + } + +} + +void QWaylandXCompositeGLXIntegration::rootInformation(void *data, wl_xcomposite *xcomposite, const char *display_name, uint32_t root_window) +{ + Q_UNUSED(xcomposite); + QWaylandXCompositeGLXIntegration *integration = static_cast(data); + + qDebug() << "ROOT INFORMATION" << integration->mDisplay << integration->mRootWindow << integration->mScreen; + integration->mDisplay = XOpenDisplay(display_name); + integration->mRootWindow = (Window) root_window; + integration->mScreen = XDefaultScreen(integration->mDisplay); +} + diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h new file mode 100644 index 0000000..650fdcf --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h @@ -0,0 +1,52 @@ +#ifndef QWAYLANDXCOMPOSITEGLXINTEGRATION_H +#define QWAYLANDXCOMPOSITEGLXINTEGRATION_H + +#include "gl_integration/qwaylandglintegration.h" +#include "wayland-client.h" + +#include +#include +#include +#include +#include + +#include + +struct wl_xcomposite; + +class QWaylandXCompositeGLXIntegration : public QWaylandGLIntegration +{ +public: + QWaylandXCompositeGLXIntegration(QWaylandDisplay * waylandDispaly); + ~QWaylandXCompositeGLXIntegration(); + + void initialize(); + + QWaylandWindow *createEglWindow(QWidget *widget); + + QWaylandDisplay *waylandDisplay() const; + struct wl_xcomposite *waylandXComposite() const; + + Display *xDisplay() const; + int screen() const; + Window rootWindow() const; + +private: + QWaylandDisplay *mWaylandDisplay; + struct wl_xcomposite *mWaylandComposite; + + Display *mDisplay; + int mScreen; + Window mRootWindow; + + static void wlDisplayHandleGlobal(struct wl_display *display, uint32_t id, + const char *interface, uint32_t version, void *data); + + static const struct wl_xcomposite_listener xcomposite_listener; + static void rootInformation(void *data, + struct wl_xcomposite *xcomposite, + const char *display_name, + uint32_t root_window); +}; + +#endif // QWAYLANDXCOMPOSITEGLXINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp new file mode 100644 index 0000000..57ee27e --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp @@ -0,0 +1,36 @@ +#include "qwaylandxcompositeglxwindow.h" + +#include + +QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWidget *window, QWaylandXCompositeGLXIntegration *glxIntegration) + : QWaylandWindow(window) + , mGlxIntegration(glxIntegration) + , mContext(0) +{ + +} + +QWaylandWindow::WindowType QWaylandXCompositeGLXWindow::windowType() const +{ + //yeah. this type needs a new name + return QWaylandWindow::Egl; +} + +QPlatformGLContext * QWaylandXCompositeGLXWindow::glContext() const +{ + if (!mContext) { + qDebug() << "creating glcontext;"; + QWaylandXCompositeGLXWindow *that = const_cast(this); + that->mContext = new QWaylandXCompositeGLXContext(mGlxIntegration,that); + } + return mContext; +} + +void QWaylandXCompositeGLXWindow::setGeometry(const QRect &rect) +{ + QWaylandWindow::setGeometry(rect); + + if (mContext) { + mContext->geometryChanged(); + } +} diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h new file mode 100644 index 0000000..75058a5 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h @@ -0,0 +1,24 @@ +#ifndef QWAYLANDXCOMPOSITEGLXWINDOW_H +#define QWAYLANDXCOMPOSITEGLXWINDOW_H + +#include "qwaylandwindow.h" +#include "qwaylandxcompositeglxintegration.h" +#include "qwaylandxcompositeglxcontext.h" + +class QWaylandXCompositeGLXWindow : public QWaylandWindow +{ +public: + QWaylandXCompositeGLXWindow(QWidget *window, QWaylandXCompositeGLXIntegration *glxIntegration); + WindowType windowType() const; + + QPlatformGLContext *glContext() const; + + void setGeometry(const QRect &rect); + +private: + QWaylandXCompositeGLXIntegration *mGlxIntegration; + QWaylandXCompositeGLXContext *mContext; + +}; + +#endif // QWAYLANDXCOMPOSITEGLXWINDOW_H diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri new file mode 100644 index 0000000..43295e9 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri @@ -0,0 +1,13 @@ +include (../xcomposite_share/xcomposite_share.pri) +include (../../../glxconvenience/glxconvenience.pri) + +LIBS += -lXcomposite +SOURCES += \ + $$PWD/qwaylandxcompositeglxcontext.cpp \ + $$PWD/qwaylandxcompositeglxintegration.cpp \ + $$PWD/qwaylandxcompositeglxwindow.cpp + +HEADERS += \ + $$PWD/qwaylandxcompositeglxcontext.h \ + $$PWD/qwaylandxcompositeglxintegration.h \ + $$PWD/qwaylandxcompositeglxwindow.h diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp new file mode 100644 index 0000000..218907e --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp @@ -0,0 +1,18 @@ +#include "qwaylandxcompositebuffer.h" + +#include "wayland-client.h" + +QWaylandXCompositeBuffer::QWaylandXCompositeBuffer(wl_xcomposite *xcomposite, uint32_t window, const QSize &size, wl_visual *visual) + :mSize(size) +{ + mBuffer = wl_xcomposite_create_buffer(xcomposite, + window, + size.width(), + size.height(), + visual); +} + +QSize QWaylandXCompositeBuffer::size() const +{ + return mSize; +} diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h new file mode 100644 index 0000000..c9332d9 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h @@ -0,0 +1,21 @@ +#ifndef QWAYLANDXCOMPOSITEBUFFER_H +#define QWAYLANDXCOMPOSITEBUFFER_H + +#include "qwaylandbuffer.h" + +#include "wayland-xcomposite-client-protocol.h" + +class QWaylandXCompositeBuffer : public QWaylandBuffer +{ +public: + QWaylandXCompositeBuffer(struct wl_xcomposite *xcomposite, + uint32_t window, + const QSize &size, + struct wl_visual *visual); + + QSize size() const; +private: + QSize mSize; +}; + +#endif // QWAYLANDXCOMPOSITEBUFFER_H diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h new file mode 100644 index 0000000..1955a74 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h @@ -0,0 +1,126 @@ +/* + * Copyright © 2010 Kristian Høgsberg + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + + +#ifndef XCOMPOSITE_CLIENT_PROTOCOL_H +#define XCOMPOSITE_CLIENT_PROTOCOL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "wayland-util.h" + +struct wl_client; + +struct wl_xcomposite; + +struct wl_proxy; + +extern void +wl_proxy_marshal(struct wl_proxy *p, uint32_t opcode, ...); +extern struct wl_proxy * +wl_proxy_create(struct wl_proxy *factory, + const struct wl_interface *interface); +extern struct wl_proxy * +wl_proxy_create_for_id(struct wl_display *display, + const struct wl_interface *interface, uint32_t id); +extern void +wl_proxy_destroy(struct wl_proxy *proxy); + +extern int +wl_proxy_add_listener(struct wl_proxy *proxy, + void (**implementation)(void), void *data); + +extern void +wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data); + +extern void * +wl_proxy_get_user_data(struct wl_proxy *proxy); + +extern const struct wl_interface wl_xcomposite_interface; + +struct wl_xcomposite_listener { + void (*root)(void *data, + struct wl_xcomposite *xcomposite, + const char *display_name, + uint32_t root_window); +}; + +static inline int +wl_xcomposite_add_listener(struct wl_xcomposite *xcomposite, + const struct wl_xcomposite_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) xcomposite, + (void (**)(void)) listener, data); +} + +#define WL_XCOMPOSITE_CREATE_BUFFER 0 + +static inline struct wl_xcomposite * +wl_xcomposite_create(struct wl_display *display, uint32_t id) +{ + return (struct wl_xcomposite *) + wl_proxy_create_for_id(display, &wl_xcomposite_interface, id); +} + +static inline void +wl_xcomposite_set_user_data(struct wl_xcomposite *xcomposite, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) xcomposite, user_data); +} + +static inline void * +wl_xcomposite_get_user_data(struct wl_xcomposite *xcomposite) +{ + return wl_proxy_get_user_data((struct wl_proxy *) xcomposite); +} + +static inline void +wl_xcomposite_destroy(struct wl_xcomposite *xcomposite) +{ + wl_proxy_destroy((struct wl_proxy *) xcomposite); +} + +static inline struct wl_buffer * +wl_xcomposite_create_buffer(struct wl_xcomposite *xcomposite, uint32_t x_window, int width, int height, struct wl_visual *visual) +{ + struct wl_proxy *id; + + id = wl_proxy_create((struct wl_proxy *) xcomposite, + &wl_buffer_interface); + if (!id) + return NULL; + + wl_proxy_marshal((struct wl_proxy *) xcomposite, + WL_XCOMPOSITE_CREATE_BUFFER, id, x_window, width, height, visual); + + return (struct wl_buffer *) id; +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c new file mode 100644 index 0000000..da2e4a2 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c @@ -0,0 +1,41 @@ +/* + * Copyright © 2010 Kristian Høgsberg + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + + +#include +#include +#include "wayland-util.h" + +static const struct wl_message xcomposite_requests[] = { + { "create_buffer", "nuiio" }, +}; + +static const struct wl_message xcomposite_events[] = { + { "root", "su" }, +}; + +WL_EXPORT const struct wl_interface wl_xcomposite_interface = { + "xcomposite", 1, + ARRAY_LENGTH(xcomposite_requests), xcomposite_requests, + ARRAY_LENGTH(xcomposite_events), xcomposite_events, +}; + diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/xcomposite_share.pri b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/xcomposite_share.pri new file mode 100644 index 0000000..03b3521 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/xcomposite_share.pri @@ -0,0 +1,9 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/wayland-xcomposite-client-protocol.h \ + gl_integration/xcomposite_share/qwaylandxcompositebuffer.h + +SOURCES += \ + $$PWD/wayland-xcomposite-protocol.c \ + gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp -- 2.7.4