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>
-This document is heavily inspired by the Building Wayland document:
-http://wayland.freedesktop.org/building.html
+This is the Qt for Wayland module.
-However, it is slightly more messy
-:) If you encounter things you find unclear, and know of a better way of
-expressing it, then please send a patch:)
+Sometimes we are slightly behind upstream wayland, so if your compiling Wayland from git, reset to sha1 defined in wayland_sha1.txt
-Qt-Compositor is meant as a toolbox for making new funky Wayland compositors.
-
-Pre-requisites on Linux (apt-get): git, autoconf, automake, libtool, libexpat1-dev
-Pre-requisites on Mac OSX Snow Leopard: git, latest Gnu autoconf, latest Gnu automake, latest Gnu libtool, latest pkg-config.
-Make sure you have /usr/local/bin on the $PATH before /usr/bin
-
-1. To build wayland we need libffi + libffi headers on Linux. For Mac we need a special version of wayland/event-loop.c -- if you pull the distribution from the freedesktop.org, replace the event-loop.c with the one in this repo
-
-# sudo apt-get install libffi-dev
-On Mac ffi is part of the OS but you need to tell the the wayland configure
-export FFI_CFLAGS=-I/usr/include/ffi
-export FFI_LIBS-lffi
-
-Qt-Compositor contains a copy of the Wayland libraries. We have not changed
-them in any way, but they are provided for convenience so that you can compile
-everything using qmake. However, I suggest you use the official Wayland
-libraries. The only dependency they have is to ffi. The demos has some more
-dependencies, but we are not going to compile those.
-
-2. Clone Wayland from: git://anongit.freedesktop.org/wayland/wayland
-# git clone git://anongit.freedesktop.org/wayland/wayland
-
-3. Compile Wayland: ./autogen.sh -prefix=$HOME/install && make && make install
-
-4. Set your PKG_CONFIG_PATH so that the location of the Wayland libraries are
-picked up by Qt's configure.
-# export PKG_CONFIG_PATH=$HOME/install/lib/pkgconfig/
-
-6. Set the library path to pick up the Wayland libraries
-# export LD_LIBRARY_PATH=$HOME/install/lib
-
-8. Get the build dependencies that you need for QtGui.
-# sudo apt-get build-dep libqt4-gui
-
-One of the dependencies that the wayland-demos compositor and client
-applications has is xkbcommon. The Qt-Lighthouse wayland plugin has code to
-read xkbcommon codes sent over the wayland protocol, so that Qt-Lighthouse
-clients on Wayland will get keyboard functionality in other compositors.
-However, Qt-Compositor doesn't have this requirement. The support for xkbcommon
-is picked up by configure. If it is not detected the Wayland plug-in will be
-compiled with the: QT_NO_WAYLAND_XKB.
-
-libxkbcommon is available from: git://people.freedesktop.org/xorg/lib/libxkbcommon.git
-Use typically the following line to configure it:
-# ./autogen.sh --prefix=$HOME/install --with-xkb-config-root=/usr/share/X11/xkb
-
-Its a good idea to use out of source builds when building Qt. A good setup
-could be: $HOME/dev/qt-src/lighthouse where lighthouse is where you have a
-complete checkout of the lighthouse repository. Then you can have ie.:
-$HOME/dev/qt-builds/lighthouse-debug
-
-9. Clone Lighthouse from gitorious
-# git clone git@gitorious.org:+qt-developers/qt/lighthouse.git
-# $HOME/dev/qt-src/lighthouse
-(you might want to use git remote etc. if you already have a clone of
-qt-master)
-
-10. Configure and compile Qt-Lighthouse. So from
-$HOME/dev/qt-builds/lighthouse-debug do: ../../qt-src/lighthouse/configure -qpa
--developer-build && make
-
-11. OK, now we have Lighthouse and Wayland libs on our system. To try Wayland
-out we want the compositor to render into a XWindow(this is for development).
-So we need to compile up a X back-end for lighthouse. They don't get built
-automatically (yet). The Wayland plug-in will be ma
-
-Go into the directory: $HOME/dev/qt-src/lighthouse/src/plugins/platforms/xcb
-# make
-
-12. When this is done, you are ready to compile the qwidget-compositor. Enter
-the directory with $QT-COMPOSITOR-DIR/examples/qwidget-compositor #qmake &&
-make
-
-Makes generates a executable in $QT-COMPOSITOR-DIR/bin. Execute it and pass in
--platform xcb
-# $QT-COMPOSITOR-DIR/bin/qt-compositor -platform xcb
-
-This should give you a blank window. If you now open a another terminal with
-LD_LIBRARY_PATH set and run a simple Qt example with the -platform Wayland, it
-should render into this window.
+We hang out at #qt-labs and #qt-lighthouse on freenode if you have any questions
--- /dev/null
+TEMPLATE=subdirs
+SUBDIRS += qwidget-compositor qwidget-compositor-mdi qwindow-compositor
+
+contains(QT_CONFIG, quick) {
+ SUBDIRS += qml-compositor
+}
#include "waylandsurface.h"
#include "waylandsurfaceitem.h"
-#include <QApplication>
+#include <QGuiApplication>
#include <QTimer>
#include <QPainter>
#include <QMouseEvent>
int main(int argc, char *argv[])
{
- QApplication app(argc, argv);
+ QGuiApplication app(argc, argv);
QmlCompositor compositor;
compositor.setWindowTitle(QLatin1String("QML Compositor"));
# comment out the following to not use pkg-config in the pri files
CONFIG += use_pkgconfig
-DESTDIR=$$PWD/../../bin/
-
LIBS += -L ../../lib
-QT += declarative v8
-QT += opengl
-
-# to be removed once scenegraph gets rid of its widget dependencies
-#QT += widgets widgets-private
-
-!isEmpty(QT.core.MAJOR_VERSION):greaterThan(QT.core.MAJOR_VERSION, 4) {
- QT += core-private gui-private declarative-private opengl-private
-}
+QT += quick v8
+QT += quick-private
-include (../../src/qt-compositor/qt-compositor.pri)
-
-target.path += $$[QT_INSTALL_BINS]
-INSTALLS += target
+QT += compositor
+#include (../../src/compositor/compositor.pri)
# Input
SOURCES += main.cpp
CONFIG += qt warn_on debug create_prl link_prl
OBJECTS_DIR = .obj/release-shared
MOC_DIR = .moc/release-shared
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qtwayland/qml-compositor
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS qml-compositor.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtwayland/qml-compositor
+INSTALLS += target sources
{
Q_OBJECT
public:
- QWidgetCompositorMdi() : WaylandCompositor(this) {
+ QWidgetCompositorMdi() : WaylandCompositor(this->windowHandle()) {
m_mdiArea = new QMdiArea(this);
setCentralWidget(m_mdiArea);
+++ /dev/null
-TEMPLATE = app
-TARGET = qwidget-compositor-mdi
-DEPENDPATH += .
-INCLUDEPATH += .
-
-# comment out the following to not use pkg-config in the pri files
-CONFIG += use_pkgconfig
-
-DESTDIR=$$PWD/../../bin/
-
-include (../../src/qt-compositor/qt-compositor.pri)
-
-QT += widgets gui-private widgets-private
-
-# Input
-SOURCES += main.cpp
-
-CONFIG += qt warn_on debug create_prl link_prl
-OBJECTS_DIR = .obj/release-shared
-MOC_DIR = .moc/release-shared
# comment out the following to not use pkg-config in the pri files
CONFIG += use_pkgconfig
-DESTDIR=$$PWD/../../bin/
-
-include (../../src/qt-compositor/qt-compositor.pri)
+#include (../../src/qt-compositor/qt-compositor.pri)
# Input
SOURCES += main.cpp
} else {
QTBASE = $$QT_SOURCE_TREE
}
+
#TOUCHSCREEN_BASE = $$QTBASE/src/plugins/generic/touchscreen
#SOURCES += $$TOUCHSCREEN_BASE/qtouchscreen.cpp
#HEADERS += $$TOUCHSCREEN_BASE/qtouchscreen.h
#INCLUDEPATH += $$TOUCHSCREEN_BASE
#LIBS += -ludev -lmtdev
-QT += gui-private widgets widgets-private opengl opengl-private
-target.path += $$[QT_INSTALL_DATA]/bin
-INSTALLS += target
+QT += gui-private widgets widgets-private opengl opengl-private compositor
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qtwayland/qwidget-compositor
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS qwidget-compositor.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtwayland/qwidget-compositor
+INSTALLS += target sources
# comment out the following to not use pkg-config in the pri files
CONFIG += use_pkgconfig
-DESTDIR=$$PWD/../../bin/
-
LIBS += -L ../../lib
-include (../../src/qt-compositor/qt-compositor.pri)
+#include (../../src/qt-compositor/qt-compositor.pri)
# Input
SOURCES += main.cpp \
OBJECTS_DIR = .obj/release-shared
MOC_DIR = .moc/release-shared
-QT += gui opengl
+QT += gui
-target.path += $$[QT_INSTALL_BINS]
-INSTALLS += target
+QT += compositor
+#include(../../src/compositor/compositor.pri)
HEADERS += \
qopenglwindow.h \
qwindowcompositor.h
RESOURCES += qwindow-compositor.qrc
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qtwayland/qwindow-compositor
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS qwindow-compositor.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtwayland/qwindow-compositor
+INSTALLS += target sources
#include "surfacerenderer.h"
#include <QOpenGLFunctions>
+#include <QImage>
SurfaceRenderer::SurfaceRenderer(QOpenGLContext *context, QWindow *surface)
: m_context(context)
glBlendFunc (GL_ONE,GL_ONE_MINUS_SRC_ALPHA);
//May need to manually set context here
- m_shaderProgram = new QGLShaderProgram();
+ m_shaderProgram = new QOpenGLShaderProgram();
- m_shaderProgram->addShaderFromSourceCode(QGLShader::Vertex, textureVertexProgram);
- m_shaderProgram->addShaderFromSourceCode(QGLShader::Fragment, textureFragmentProgram);
+ m_shaderProgram->addShaderFromSourceCode(QOpenGLShader::Vertex, textureVertexProgram);
+ m_shaderProgram->addShaderFromSourceCode(QOpenGLShader::Fragment, textureFragmentProgram);
m_shaderProgram->link();
m_shaderProgram->bind();
GLuint SurfaceRenderer::textureFromImage(const QImage &image)
{
//TODO: Replace this line
- QImage convertedImage = QGLWidget::convertToGLFormat(image);
+ //QImage convertedImage = QGLWidget::convertToGLFormat(image);
GLuint textureId;
//Copy QImage data to Texture
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, convertedImage.width(), convertedImage.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, convertedImage.constBits());
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image.constBits());
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
#define SURFACERENDERER_H
#include <QOpenGLContext>
-#include <QGLShaderProgram>
+#include <QOpenGLShaderProgram>
#include <QWindow>
class SurfaceRenderer
QOpenGLContext *m_context;
QWindow *m_surface;
- QGLShaderProgram *m_shaderProgram;
+ QOpenGLShaderProgram *m_shaderProgram;
QMatrix4x4 m_transformMatrix;
int m_matrixLocation;
--- /dev/null
+QT.compositor.VERSION = 5.0.0
+QT.compositor.MAJOR_VERSION = 5
+QT.compositor.MINOR_VERSION = 0
+QT.compositor.PATCH_VERSION = 0
+
+QT.compositor.name = QtCompositor
+QT.compositor.bins = $$QT_MODULE_BIN_BASE
+QT.compositor.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtCompositor
+QT.compositor.private_includes = $$QT_MODULE_INCLUDE_BASE/QtCompositor/$$QT.compositor.VERSION
+QT.compositor.sources = $$QT_MODULE_BASE/src/compositor
+QT.compositor.libs = $$QT_MODULE_LIB_BASE
+QT.compositor.plugins = $$QT_MODULE_PLUGIN_BASE
+QT.compositor.imports = $$QT_MODULE_IMPORT_BASE
+QT.compositor.depends = gui
+contains(QT_CONFIG, opengl) {
+ QT.compositor.DEFINES = QT_COMPOSITOR_WAYLAND_GL
+}
+
+QT_CONFIG += compositor
TEMPLATE=subdirs
-SUBDIRS=src
+
+module_qtcompositor_src.subdir = src
+module_qtcompositor_src.target = module-module_qtcompositor_src
+
+module_qtcompositor_examples.subdir = examples
+module_qtcompositor_examples.target = module_qtcompositor_examples
+module_qtcompositor_examples.depends = module_qtcompositor_src
+!contains(QT_BUILD_PARTS,examples) {
+ module_qtcompositor_examples.CONFIG = no_default_target no_default_install
+}
+
+SUBDIRS += module_qtcompositor_src \
+ module_qtcompositor_examples \
+CONFIG += module
+MODULE_PRI += $$PWD/../../modules/qt_compositor.pri
+
INCLUDEPATH += $$PWD
DEFINES += QT_WAYLAND_WINDOWMANAGER_SUPPORT
+DEFINES += QT_BUILD_COMPOSITOR_LIB
!mac:use_pkgconfig {
CONFIG += link_pkgconfig
LIBS += -lwayland-server -lffi
}
+HEADERS += qtcompositorversion.h
+
include ($$PWD/util/util.pri)
include ($$PWD/wayland_wrapper/wayland_wrapper.pri)
include ($$PWD/hardware_integration/hardware_integration.pri)
--- /dev/null
+load(qt_module)
+
+TARGET = QtCompositor
+QPRO_PWD = $$PWD
+
+include (compositor.pri)
+load(qt_module_config)
+
+QT += gui-private
+
$$PWD/waylandcompositor.cpp \
$$PWD/waylandsurface.cpp
-contains(QT, declarative) {
+QT += core-private
+
+contains(QT_CONFIG, quick) {
SOURCES += $$PWD/waylandsurfaceitem.cpp
HEADERS += $$PWD/waylandsurfaceitem.h
- DEFINES += QT_COMPOSITOR_DECLARATIVE
-}
+ DEFINES += QT_COMPOSITOR_QUICK
-!isEmpty(QT.core.MAJOR_VERSION):greaterThan(QT.core.MAJOR_VERSION, 4) {
- QT += core-private
- contains(QT, declarative):QT += declarative-private gui-private
+ QT += quick
+ QT += quick-private gui-private
}
+
class Compositor;
}
-class WaylandCompositor
+class Q_COMPOSITOR_EXPORT WaylandCompositor
{
public:
WaylandCompositor(QWindow *window = 0, const char *socketName = 0);
class SurfacePrivate;
}
-class WaylandSurface : public QObject
+class Q_COMPOSITOR_EXPORT WaylandSurface : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(WaylandSurface)
#include "waylandsurfaceitem.h"
#include "waylandsurface.h"
-#include <QtDeclarative/QSGEngine>
+#include <QtQuick/QSGEngine>
#include <QtGui/QKeyEvent>
-#include <QtDeclarative/QSGSimpleTextureNode>
-#include <QtDeclarative/QSGSimpleRectNode>
-#include <QtDeclarative/QQuickCanvas>
+#include <QtQuick/QSGSimpleTextureNode>
+#include <QtQuick/QSGSimpleRectNode>
+#include <QtQuick/QQuickCanvas>
class WaylandSurfaceTextureProvider : public QSGTextureProvider
{
#include <QtQuick/QQuickItem>
#include <QtQuick/qsgtexture.h>
-#include <private/qsgtextureprovider_p.h>
+#include <QtQuick/private/qsgtextureprovider_p.h>
class WaylandSurface;
class WaylandSurfaceTextureProvider;
Q_DECLARE_METATYPE(WaylandSurface*)
-class WaylandSurfaceItem : public QQuickItem
+class Q_COMPOSITOR_EXPORT WaylandSurfaceItem : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(WaylandSurface* surface READ surface WRITE setSurface)
QT_WAYLAND_GL_INTEGRATION = $$QT_WAYLAND_GL_CONFIG
} else {
contains(QT_CONFIG, opengles2) {
- isEqual(QT_WAYLAND_GL_CONFIG, wayland_egl) {
- QT_WAYLAND_GL_INTEGRATION = $$QT_WAYLAND_GL_CONFIG
- CONFIG += mesa_egl
- DEFINES += MESA_EGL_NO_X11_HEADERS
+ isEqual(QT_WAYLAND_GL_CONFIG, xcomposite_egl) {
+ QT_WAYLAND_GL_INTEGRATION = xcomposite_egl
+ CONFIG += xcomposite_egl
} else:isEqual(QT_WAYLAND_GL_CONFIG,dri2_xcb) {
QT_WAYLAND_GL_INTEGRATION = $$QT_WAYLAND_GL_CONFIG
CONFIG += dri2_xcb
} else {
- QT_WAYLAND_GL_INTEGRATION = xcomposite_egl
- CONFIG += xcomposite_egl
+ QT_WAYLAND_GL_INTEGRATION = $$QT_WAYLAND_GL_CONFIG
+ CONFIG += wayland_egl
+ DEFINES += MESA_EGL_NO_X11_HEADERS
}
} else {
QT_WAYLAND_GL_INTEGRATION = xcomposite_glx
system(echo "Qt-Compositor configured as raster only compositor")
}
-mesa_egl {
+wayland_egl {
include (wayland_egl/wayland_egl.pri)
}
dri2_xcb {
--- /dev/null
+TEMPLATE=subdirs
+SUBDIRS += wayland
QT_WAYLAND_GL_CONFIG = $$(QT_WAYLAND_GL_CONFIG)
contains(QT_CONFIG, opengles2) {
- isEqual(QT_WAYLAND_GL_CONFIG, wayland_egl) {
- QT_WAYLAND_GL_INTEGRATION = $$QT_WAYLAND_GL_CONFIG
- CONFIG += wayland_egl
+ isEqual(QT_WAYLAND_GL_CONFIG, xcomposite_egl) {
+ QT_WAYLAND_GL_INTEGRATION = xcomposite_egl
+ CONFIG += xcomposite_egl
} else:isEqual(QT_WAYLAND_GL_CONFIG,readback) {
QT_WAYLAND_GL_INTEGRATION = readback_egl
CONFIG += readback_egl
} else {
- QT_WAYLAND_GL_INTEGRATION = xcomposite_egl
- CONFIG += xcomposite_egl
+ QT_WAYLAND_GL_INTEGRATION = $$QT_WAYLAND_GL_CONFIG
+ CONFIG += wayland_egl
}
} else:mac {
QT_WAYLAND_GL_INTEGRATION = readback_cgl
TARGET = qwayland
load(qt_plugin)
+load(qt_module)
CONFIG += qpa/genericunixfontdatabase
-#DESTDIR = $$QT.gui.plugins/platforms
+DESTDIR = $$QT.gui.plugins/platforms
DEFINES += Q_PLATFORM_WAYLAND
DEFINES += $$QMAKE_DEFINES_WAYLAND
--- /dev/null
+TEMPLATE=subdirs
+SUBDIRS += platforms
+++ /dev/null
-TEMPLATE = lib
-
-include (qt-compositor.pri)
-
-installPath = $$INSTALLBASE
-
-target.path = $$installPath/lib
-headers_path = $$installPath/include
-
-headers.path = $$headers_path/qt-compositor
-headers.files = $$HEADERS
-
-INSTALLS = target headers
-
-QT += gui-private
TEMPLATE=subdirs
-SUBDIRS=qt-compositor
+SUBDIRS += plugins compositor
--- /dev/null
+%modules = ( # path to module name map
+ "QtCompositor" => "$basedir/src/compositor",
+);
+%moduleheaders = ( # restrict the module headers to those found in relative path
+);
+%classnames = (
+);
+%mastercontent = (
+ "gui" => "#include <QtGui/QtGui>\n",
+);
+%modulepris = (
+ "QtCompositor" => "$basedir/modules/qt_compositor.pri",
+);
+%deprecatedheaders = (
+);
+# Module dependencies.
+# Every module that is required to build this module should have one entry.
+# Each of the module version specifiers can take one of the following values:
+# - A specific Git revision.
+# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch)
+#
+%dependencies = (
+ "qtbase" => "refs/heads/master",
+);