summaryrefslogtreecommitdiffstats
path: root/src/compositor/hardware_integration/xcomposite_share/xcompositehandler.cpp
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2011-12-05 17:09:02 +0100
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>2011-12-07 09:58:35 +0100
commit4c89518228012ddc3602eab405e4b5fb8108fcdf (patch)
tree615d4fdc38999e408d52998c39760064d223b652 /src/compositor/hardware_integration/xcomposite_share/xcompositehandler.cpp
parent542eca71e074b5110df2aaf822449bf7d6ec2b91 (diff)
Make wayland actually a module
Also fix so that QtCompositor can be built as shared object. + fix so that the default QT_WAYLAND_GL_CONFIG is wayland_egl Change-Id: I02b72e99286584426bd37ab2d00bbc84af11efdc Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
Diffstat (limited to 'src/compositor/hardware_integration/xcomposite_share/xcompositehandler.cpp')
-rw-r--r--src/compositor/hardware_integration/xcomposite_share/xcompositehandler.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/compositor/hardware_integration/xcomposite_share/xcompositehandler.cpp b/src/compositor/hardware_integration/xcomposite_share/xcompositehandler.cpp
new file mode 100644
index 000000000..a434c9aa4
--- /dev/null
+++ b/src/compositor/hardware_integration/xcomposite_share/xcompositehandler.cpp
@@ -0,0 +1,55 @@
+#include "xcompositehandler.h"
+
+#include "wayland-xcomposite-server-protocol.h"
+
+#include "xcompositebuffer.h"
+#include <X11/extensions/Xcomposite.h>
+
+XCompositeHandler::XCompositeHandler(Wayland::Compositor *compositor, Display *display, QWindow *window)
+ : mCompositor(compositor)
+ , mwindow(window)
+ , mDisplay(display)
+{
+ mCompositor->window()->create();
+
+ mFakeRootWidget = new QWindow(mCompositor->window());
+ mFakeRootWidget->setGeometry(QRect(-1,-1,1,1));
+ mFakeRootWidget->create();
+ mFakeRootWidget->show();
+ int composite_event_base, composite_error_base;
+ if (XCompositeQueryExtension(mDisplay, &composite_event_base, &composite_error_base)) {
+
+ } else {
+ qFatal("XComposite required");
+ }
+}
+
+void XCompositeHandler::createBuffer(struct wl_client *client, uint32_t id, Window window, const QSize &size)
+{
+ XCompositeBuffer *buffer = new XCompositeBuffer(mCompositor, window, size);
+ Wayland::addClientResource(client,&buffer->base()->resource,
+ id,&wl_buffer_interface,
+ &XCompositeBuffer::buffer_interface,
+ XCompositeBuffer::delete_resource);
+}
+
+void XCompositeHandler::xcomposite_bind_func(struct wl_client *client, void *data, uint32_t version, uint32_t id)
+{
+ Q_UNUSED(version);
+ XCompositeHandler *handler = static_cast<XCompositeHandler *>(data);
+ wl_resource *resource = wl_client_add_object(client,&wl_xcomposite_interface,&xcomposite_interface,id,handler);
+ const char *displayString = XDisplayString(handler->mDisplay);
+ wl_resource_post_event(resource, WL_XCOMPOSITE_ROOT, displayString, handler->mFakeRootWidget->winId());
+}
+
+void XCompositeHandler::create_buffer(struct wl_client *client,
+ struct wl_resource *xcomposite,
+ uint32_t id,
+ uint32_t x_window,
+ int32_t width,
+ int32_t height)
+{
+ Window window = (Window)x_window;
+ XCompositeHandler *that = reinterpret_cast<XCompositeHandler *>(xcomposite);
+ that->createBuffer(client, id, window, QSize(width,height));
+}