Permalink
Browse files

Add QWaylandOutput to support multiple outputs

Add a new QWaylandOutput class to support multiple outputs.
Each QWaylandOutput need a window for rendering.

Rename OutputGlobal to Output and Output to OutputResource.

Add support for physical size, mode and available geometry.

Use better defaults for geometry and refreshRate from the QWindow
if available.

A window is no longer passed to QWaylandCompositor constructor
and all output related methods are removed, however one or more
outputs are required for hardware integration.

QWaylandCompositor returns a list of outputs and offers an API to add
or remove outputs.

Hardware integrations can run headless.

Change-Id: I742996571ddb78328f7bfa4f79b25a81995279e1
Done-with: Jan Arne Petersen <jan.petersen@kdab.com>
Done-with: Jørgen Lind <jorgen.lind@theqtcompany.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
  • Loading branch information...
plfiorini committed Aug 26, 2013
1 parent 2322ef5 commit b09f2e8440b7a0c9532d730d52296cf05b944ee2
Showing with 1,078 additions and 236 deletions.
  1. +4 −1 examples/wayland/qml-compositor/main.cpp
  2. +5 −4 examples/wayland/qwindow-compositor/qwindowcompositor.cpp
  3. +4 −1 examples/wayland/server-buffer/compositor/main.cpp
  4. +4 −0 src/compositor/compositor_api/compositor_api.pri
  5. +66 −11 src/compositor/compositor_api/qwaylandcompositor.cpp
  6. +14 −6 src/compositor/compositor_api/qwaylandcompositor.h
  7. +246 −0 src/compositor/compositor_api/qwaylandoutput.cpp
  8. +164 −0 src/compositor/compositor_api/qwaylandoutput.h
  9. +14 −18 src/compositor/compositor_api/qwaylandquickcompositor.cpp
  10. +5 −7 src/compositor/compositor_api/qwaylandquickcompositor.h
  11. +78 −0 src/compositor/compositor_api/qwaylandquickoutput.cpp
  12. +74 −0 src/compositor/compositor_api/qwaylandquickoutput.h
  13. +4 −3 src/compositor/compositor_api/qwaylandquicksurface.cpp
  14. +8 −0 src/compositor/compositor_api/qwaylandsurface.cpp
  15. +3 −0 src/compositor/compositor_api/qwaylandsurface.h
  16. +56 −50 src/compositor/wayland_wrapper/qwlcompositor.cpp
  17. +9 −11 src/compositor/wayland_wrapper/qwlcompositor_p.h
  18. +2 −2 src/compositor/wayland_wrapper/qwlextendedoutput.cpp
  19. +2 −2 src/compositor/wayland_wrapper/qwlextendedoutput_p.h
  20. +4 −2 src/compositor/wayland_wrapper/qwlinputpanelsurface.cpp
  21. +2 −1 src/compositor/wayland_wrapper/qwlinputpanelsurface_p.h
  22. +181 −58 src/compositor/wayland_wrapper/qwloutput.cpp
  23. +60 −38 src/compositor/wayland_wrapper/qwloutput_p.h
  24. +49 −8 src/compositor/wayland_wrapper/qwlshellsurface.cpp
  25. +2 −2 src/compositor/wayland_wrapper/qwlshellsurface_p.h
  26. +7 −0 src/compositor/wayland_wrapper/qwlsurface.cpp
  27. +4 −0 src/compositor/wayland_wrapper/qwlsurface_p.h
  28. +1 −2 src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp
  29. +1 −2 src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp
  30. +1 −1 src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp
  31. +2 −2 src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp
  32. +1 −1 src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp
  33. +1 −3 src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
@@ -42,6 +43,7 @@
#include "qwaylandquicksurface.h"
#include <QtCompositor/qwaylandsurfaceitem.h>
+#include <QtCompositor/qwaylandoutput.h>
#include <QGuiApplication>
#include <QTimer>
@@ -60,14 +62,15 @@ class QmlCompositor : public QQuickView, public QWaylandQuickCompositor
public:
QmlCompositor()
- : QWaylandQuickCompositor(this, 0, DefaultExtensions | SubSurfaceExtension)
+ : QWaylandQuickCompositor(0, DefaultExtensions | SubSurfaceExtension)
, m_fullscreenSurface(0)
{
setSource(QUrl("main.qml"));
setResizeMode(QQuickView::SizeRootObjectToView);
setColor(Qt::black);
winId();
addDefaultShell();
+ createOutput(this, "", "");
connect(this, SIGNAL(afterRendering()), this, SLOT(sendCallbacks()));
}
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
@@ -55,6 +56,7 @@
#include <QtCompositor/qwaylandinput.h>
#include <QtCompositor/qwaylandbufferref.h>
#include <QtCompositor/qwaylandsurfaceview.h>
+#include <QtCompositor/qwaylandoutput.h>
QT_BEGIN_NAMESPACE
@@ -108,7 +110,7 @@ class BufferAttacher : public QWaylandBufferAttacher
};
QWindowCompositor::QWindowCompositor(CompositorWindow *window)
- : QWaylandCompositor(window, 0, DefaultExtensions | SubSurfaceExtension)
+ : QWaylandCompositor(0, DefaultExtensions | SubSurfaceExtension)
, m_window(window)
, m_backgroundTexture(0)
, m_textureBlitter(0)
@@ -134,8 +136,7 @@ QWindowCompositor::QWindowCompositor(CompositorWindow *window)
setRetainedSelectionEnabled(true);
- setOutputGeometry(QRect(QPoint(0, 0), window->size()));
- setOutputRefreshRate(qRound(qGuiApp->primaryScreen()->refreshRate() * 1000.0));
+ createOutput(window, "", "");
addDefaultShell();
}
@@ -321,7 +322,7 @@ void QWindowCompositor::render()
// Draw the background image texture
m_textureBlitter->drawTexture(m_backgroundTexture->textureId(),
QRect(QPoint(0, 0), m_backgroundImage.size()),
- window()->size(),
+ m_window->size(),
0, false, true);
foreach (QWaylandSurface *surface, m_surfaces) {
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
@@ -54,6 +55,7 @@
#include <QQuickView>
#include "qwayland-server-share-buffer.h"
+#include <QtCompositor/qwaylandoutput.h>
#include <QtCompositor/private/qwlcompositor_p.h>
#include <QtCompositor/private/qwlserverbufferintegration_p.h>
@@ -70,7 +72,7 @@ class QmlCompositor
public:
QmlCompositor()
- : QWaylandQuickCompositor(this, 0, DefaultExtensions | SubSurfaceExtension)
+ : QWaylandQuickCompositor(0, DefaultExtensions | SubSurfaceExtension)
, QtWaylandServer::qt_share_buffer(QWaylandCompositor::handle()->wl_display(), 1)
, m_server_buffer_32_bit(0)
, m_server_buffer_item_32_bit(0)
@@ -82,6 +84,7 @@ class QmlCompositor
setColor(Qt::black);
create();
grabWindow();
+ createOutput(this, "", "");
addDefaultShell();
connect(this, SIGNAL(afterRendering()), this, SLOT(sendCallbacks()));
@@ -7,6 +7,7 @@ HEADERS += \
compositor_api/qwaylandsurface_p.h \
compositor_api/qwaylandinput.h \
compositor_api/qwaylandinputpanel.h \
+ compositor_api/qwaylandoutput.h \
compositor_api/qwaylanddrag.h \
compositor_api/qwaylandbufferref.h \
compositor_api/qwaylandsurfaceview.h \
@@ -19,6 +20,7 @@ SOURCES += \
compositor_api/qwaylandsurface.cpp \
compositor_api/qwaylandinput.cpp \
compositor_api/qwaylandinputpanel.cpp \
+ compositor_api/qwaylandoutput.cpp \
compositor_api/qwaylanddrag.cpp \
compositor_api/qwaylandbufferref.cpp \
compositor_api/qwaylandsurfaceview.cpp \
@@ -31,11 +33,13 @@ qtHaveModule(quick) {
SOURCES += \
compositor_api/qwaylandquickcompositor.cpp \
compositor_api/qwaylandquicksurface.cpp \
+ compositor_api/qwaylandquickoutput.cpp \
compositor_api/qwaylandsurfaceitem.cpp
HEADERS += \
compositor_api/qwaylandquickcompositor.h \
compositor_api/qwaylandquicksurface.h \
+ compositor_api/qwaylandquickoutput.h \
compositor_api/qwaylandsurfaceitem.h
QT += qml quick
@@ -41,6 +41,7 @@
#include "qwaylandcompositor.h"
#include "qwaylandinput.h"
+#include "qwaylandoutput.h"
#include "qwaylandglobalinterface.h"
#include "qwaylandsurfaceview.h"
@@ -55,22 +56,21 @@
#include <QtCore/QStringList>
#include <QtGui/QDesktopServices>
+#include <QtGui/QScreen>
#include <QDebug>
QT_BEGIN_NAMESPACE
-QWaylandCompositor::QWaylandCompositor(QWindow *window, const char *socketName, ExtensionFlags extensions)
+QWaylandCompositor::QWaylandCompositor(const char *socketName, ExtensionFlags extensions)
: m_compositor(new QtWayland::Compositor(this, extensions))
- , m_toplevel_window(window)
{
m_compositor->m_socket_name = socketName;
m_compositor->init();
}
-QWaylandCompositor::QWaylandCompositor(QWindow *window, const char *socketName, QtWayland::Compositor *dptr)
+QWaylandCompositor::QWaylandCompositor(const char *socketName, QtWayland::Compositor *dptr)
: m_compositor(dptr)
- , m_toplevel_window(window)
{
m_compositor->m_socket_name = socketName;
m_compositor->init();
@@ -143,9 +143,24 @@ QList<QWaylandSurface *> QWaylandCompositor::surfaces() const
return surfs;
}
-QWindow * QWaylandCompositor::window() const
+QList<QWaylandOutput *> QWaylandCompositor::outputs() const
{
- return m_toplevel_window;
+ return m_compositor->outputs();
+}
+
+QWaylandOutput *QWaylandCompositor::output(QWindow *window)
+{
+ return m_compositor->output(window);
+}
+
+QWaylandOutput *QWaylandCompositor::primaryOutput() const
+{
+ return m_compositor->primaryOutput();
+}
+
+void QWaylandCompositor::setPrimaryOutput(QWaylandOutput *output)
+{
+ m_compositor->setPrimaryOutput(output);
}
void QWaylandCompositor::cleanupGraphicsResources()
@@ -221,33 +236,66 @@ const char *QWaylandCompositor::socketName() const
return m_compositor->m_socket_name.constData();
}
+#if QT_DEPRECATED_SINCE(5, 5)
/*!
Set the screen orientation based on accelerometer data or similar.
*/
void QWaylandCompositor::setScreenOrientation(Qt::ScreenOrientation orientation)
{
- m_compositor->setScreenOrientation(orientation);
+ QWaylandOutput *output = primaryOutput();
+ if (output) {
+ bool isPortrait = output->window()->screen()->primaryOrientation() == Qt::PortraitOrientation;
+
+ switch (orientation) {
+ case Qt::PrimaryOrientation:
+ output->setTransform(QWaylandOutput::TransformNormal);
+ break;
+ case Qt::LandscapeOrientation:
+ output->setTransform(isPortrait ? QWaylandOutput::Transform270 : QWaylandOutput::TransformNormal);
+ break;
+ case Qt::PortraitOrientation:
+ output->setTransform(isPortrait ? QWaylandOutput::TransformNormal : QWaylandOutput::Transform90);
+ break;
+ case Qt::InvertedLandscapeOrientation:
+ output->setTransform(isPortrait ? QWaylandOutput::Transform90 : QWaylandOutput::Transform180);
+ break;
+ case Qt::InvertedPortraitOrientation:
+ output->setTransform(isPortrait ? QWaylandOutput::Transform180 : QWaylandOutput::Transform270);
+ break;
+ }
+ }
}
void QWaylandCompositor::setOutputGeometry(const QRect &geometry)
{
- m_compositor->setOutputGeometry(geometry);
+ QWaylandOutput *output = primaryOutput();
+ if (output)
+ output->setGeometry(geometry);
}
QRect QWaylandCompositor::outputGeometry() const
{
- return m_compositor->outputGeometry();
+ QWaylandOutput *output = primaryOutput();
+ if (output)
+ return output->geometry();
+ return QRect();
}
void QWaylandCompositor::setOutputRefreshRate(int rate)
{
- m_compositor->setOutputRefreshRate(rate);
+ QWaylandOutput *output = primaryOutput();
+ if (output)
+ output->setMode({output->mode().size, rate});
}
int QWaylandCompositor::outputRefreshRate() const
{
- return m_compositor->outputRefreshRate();
+ QWaylandOutput *output = primaryOutput();
+ if (output)
+ return output->mode().refreshRate;
+ return 0;
}
+#endif
QWaylandInputDevice *QWaylandCompositor::defaultInputDevice() const
{
@@ -302,4 +350,11 @@ QWaylandInputDevice *QWaylandCompositor::inputDeviceFor(QInputEvent *inputEvent)
return m_compositor->inputDeviceFor(inputEvent);
}
+QWaylandOutput *QWaylandCompositor::createOutput(QWindow *window,
+ const QString &manufacturer,
+ const QString &model)
+{
+ return new QWaylandOutput(this, window, manufacturer, model);
+}
+
QT_END_NAMESPACE
@@ -63,6 +63,7 @@ class QWaylandInputPanel;
class QWaylandDrag;
class QWaylandGlobalInterface;
class QWaylandSurfaceView;
+class QWaylandOutput;
namespace QtWayland
{
@@ -86,7 +87,7 @@ class Q_COMPOSITOR_EXPORT QWaylandCompositor
};
Q_DECLARE_FLAGS(ExtensionFlags, ExtensionFlag)
- QWaylandCompositor(QWindow *window = 0, const char *socketName = 0, ExtensionFlags extensions = DefaultExtensions);
+ QWaylandCompositor(const char *socketName = 0, ExtensionFlags extensions = DefaultExtensions);
virtual ~QWaylandCompositor();
void addGlobalInterface(QWaylandGlobalInterface *interface);
@@ -102,7 +103,11 @@ class Q_COMPOSITOR_EXPORT QWaylandCompositor
QList<QWaylandSurface *> surfacesForClient(QWaylandClient* client) const;
QList<QWaylandSurface *> surfaces() const;
- QWindow *window()const;
+ QList<QWaylandOutput *> outputs() const;
+ QWaylandOutput *output(QWindow *window);
+
+ QWaylandOutput *primaryOutput() const;
+ void setPrimaryOutput(QWaylandOutput *output);
virtual void surfaceCreated(QWaylandSurface *surface) = 0;
virtual void surfaceAboutToBeDestroyed(QWaylandSurface *surface);
@@ -122,13 +127,15 @@ class Q_COMPOSITOR_EXPORT QWaylandCompositor
const char *socketName() const;
+#if QT_DEPRECATED_SINCE(5, 5)
void setScreenOrientation(Qt::ScreenOrientation orientation);
void setOutputGeometry(const QRect &outputGeometry);
QRect outputGeometry() const;
void setOutputRefreshRate(int refreshRate);
int outputRefreshRate() const;
+#endif
QWaylandInputDevice *defaultInputDevice() const;
@@ -154,14 +161,15 @@ class Q_COMPOSITOR_EXPORT QWaylandCompositor
QWaylandInputDevice *inputDeviceFor(QInputEvent *inputEvent);
protected:
- QWaylandCompositor(QWindow *window, const char *socketName, QtWayland::Compositor *dptr);
+ QWaylandCompositor(const char *socketName, QtWayland::Compositor *dptr);
virtual void retainedSelectionReceived(QMimeData *mimeData);
+ virtual QWaylandOutput *createOutput(QWindow *window,
+ const QString &manufacturer,
+ const QString &model);
+
friend class QtWayland::Compositor;
QtWayland::Compositor *m_compositor;
-
-private:
- QWindow *m_toplevel_window;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QWaylandCompositor::ExtensionFlags)
Oops, something went wrong.

0 comments on commit b09f2e8

Please sign in to comment.