LIBS += -L ../../lib
-QT += quick v8
+QT += quick declarative v8
QT += quick-private
QT += compositor
--- /dev/null
+<!--
+# /****************************************************************************
+# **
+# ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+# ** Contact: Nokia Corporation (qt-info@nokia.com)
+# **
+# ** This file is part of qt-compositor.
+# **
+# ****************************************************************************/
+-->
+<protocol name="output_extension">
+
+ <copyright>
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+ All rights reserved.
+ Contact: Nokia Corporation (qt-info@nokia.com)
+
+ This file is part of the plugins of the Qt Toolkit.
+
+ $QT_BEGIN_LICENSE:LGPL$
+ GNU Lesser General Public License Usage
+ This file may be used under the terms of the GNU Lesser General Public
+ License version 2.1 as published by the Free Software Foundation and
+ appearing in the file LICENSE.LGPL included in the packaging of this
+ file. Please review the following information to ensure the GNU Lesser
+ General Public License version 2.1 requirements will be met:
+ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+
+ In addition, as a special exception, Nokia gives you certain additional
+ rights. These rights are described in the Nokia Qt LGPL Exception
+ version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+
+ GNU General Public License Usage
+ Alternatively, this file may be used under the terms of the GNU General
+ Public License version 3.0 as published by the Free Software Foundation
+ and appearing in the file LICENSE.GPL included in the packaging of this
+ file. Please review the following information to ensure the GNU General
+ Public License version 3.0 requirements will be met:
+ http://www.gnu.org/copyleft/gpl.html.
+
+ Other Usage
+ Alternatively, this file may be used in accordance with the terms and
+ conditions contained in a signed written agreement between you and Nokia.
+
+
+
+
+
+ $QT_END_LICENSE$
+ </copyright>
+
+ <interface name="wl_output_extension" version="1">
+ <request name="get_extended_output">
+ <arg name="id" type="new_id" interface="wl_extended_output"/>
+ <arg name="output" type="object" interface="wl_output"/>
+ </request>
+ </interface>
+
+ <interface name="wl_extended_output" version="1">
+ <enum name="rotation">
+ <entry name="PortraitOrientation" value="1"/>
+ <entry name="LandscapeOrientation" value="2"/>
+ <entry name="InvertedPortraitOrientation" value="4"/>
+ <entry name="InvertedLandscapeOrientation" value="8"/>
+ </enum>
+
+ <event name="set_screen_rotation">
+ <arg name="rotation" type="int"/>
+ </event>
+ </interface>
+</protocol>
--- /dev/null
+<!--
+# /****************************************************************************
+# **
+# ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+# ** Contact: Nokia Corporation (qt-info@nokia.com)
+# **
+# ** This file is part of qt-compositor.
+# **
+# ****************************************************************************/
+-->
+<protocol name="surface_extension">
+
+ <copyright>
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+ All rights reserved.
+ Contact: Nokia Corporation (qt-info@nokia.com)
+
+ This file is part of the plugins of the Qt Toolkit.
+
+ $QT_BEGIN_LICENSE:LGPL$
+ GNU Lesser General Public License Usage
+ This file may be used under the terms of the GNU Lesser General Public
+ License version 2.1 as published by the Free Software Foundation and
+ appearing in the file LICENSE.LGPL included in the packaging of this
+ file. Please review the following information to ensure the GNU Lesser
+ General Public License version 2.1 requirements will be met:
+ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+
+ In addition, as a special exception, Nokia gives you certain additional
+ rights. These rights are described in the Nokia Qt LGPL Exception
+ version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+
+ GNU General Public License Usage
+ Alternatively, this file may be used under the terms of the GNU General
+ Public License version 3.0 as published by the Free Software Foundation
+ and appearing in the file LICENSE.GPL included in the packaging of this
+ file. Please review the following information to ensure the GNU General
+ Public License version 3.0 requirements will be met:
+ http://www.gnu.org/copyleft/gpl.html.
+
+ Other Usage
+ Alternatively, this file may be used in accordance with the terms and
+ conditions contained in a signed written agreement between you and Nokia.
+
+
+
+
+
+ $QT_END_LICENSE$
+ </copyright>
+
+ <interface name="wl_surface_extension" version="1">
+ <request name="get_extended_surface">
+ <arg name="id" type="new_id" interface="wl_extended_surface"/>
+ <arg name="surface" type="object" interface="wl_surface"/>
+ </request>
+ </interface>
+
+ <interface name="wl_extended_surface" version="1">
+ <event name="onscreen_visibility">
+ <arg name="visible" type="int"/>
+ </event>
+
+ <event name="set_generic_property">
+ <arg name="name" type="string"/>
+ <arg name="value" type="array"/>
+ </event>
+
+ <!-- update generic property from client to server -->
+ <request name="update_generic_property">
+ <arg name="name" type="string"/>
+ <arg name="value" type="array"/>
+ </request>
+ </interface>
+</protocol>
<arg name="processid" type="string" />
</request>
- <!-- informs the client that it is visible/not visible on screen and can therfore stop / need to start rendering.
- The client need to implement the handling of this by itself. This means, we cannot enforce the client to obey,
- but we can encourage it to do so. -->
- <event name="client_onscreen_visibility">
- <arg name="visible" type="int"/>
- </event>
-
- <!-- Sets screen rotation, typically based on accelerometer/orientation sensor reading data -->
- <event name="set_screen_rotation">
- <arg name="output" type="object" interface="wl_output"/>
- <arg name="rotation" type="int"/>
- </event>
-
- <!--sends a generic property to the client -->
- <event name="set_generic_property">
- <arg name="surface" type="object" interface="wl_surface"/>
- <arg name="name" type="string"/>
- <arg name="value" type="array"/>
- </event>
-
- <!-- update generic property from client to server -->
- <request name="update_generic_property">
- <arg name="surface" type="object" interface="wl_surface"/>
- <arg name="name" type="string"/>
- <arg name="value" type="array"/>
- </request>
</interface>
</protocol>
signals:
void mapped(const QSize &size);
void damaged(const QRect &rect);
+ void windowPropertyChanged(const QString &name, const QVariant &value);
friend class Wayland::Surface;
friend class Wayland::SurfacePrivate;
+WAYLANDSOURCES += \
+ $$PWD/../../../extensions/surface-extension/surface-extension.xml \
+ $$PWD/../../../extensions/output-extension/output-extension.xml
+
+
HEADERS += \
$$PWD/wlcompositor.h \
$$PWD/wldisplay.h \
$$PWD/wldatadevicemanager.h \
$$PWD/wldatadevice.h \
$$PWD/wldataoffer.h \
- $$PWD/wldatasource.h
+ $$PWD/wldatasource.h \
+ $$PWD/wlextendedsurface.h \
+ $$PWD/wlextendedoutput.h
SOURCES += \
$$PWD/wlcompositor.cpp \
$$PWD/wldatadevicemanager.cpp \
$$PWD/wldatadevice.cpp \
$$PWD/wldataoffer.cpp \
- $$PWD/wldatasource.cpp
+ $$PWD/wldatasource.cpp \
+ $$PWD/wlextendedsurface.cpp \
+ $$PWD/wlextendedoutput.cpp
#include "waylandcompositor.h"
#include "wldatadevicemanager.h"
#include "wldatadevice.h"
+#include "wlextendedoutput.h"
+#include "wlextendedsurface.h"
#include <QWindow>
#include <QSocketNotifier>
, m_graphics_hw_integration(0)
#endif
, m_retainNotify(0)
+ , m_outputExtension(0)
+ , m_surfaceExtension(0)
{
compositor = this;
qDebug() << "Compositor instance is" << this;
m_graphics_hw_integration = GraphicsHardwareIntegration::createGraphicsHardwareIntegration(qt_compositor);
#endif
m_windowManagerIntegration = new WindowManagerServerIntegration(this);
- connect(m_windowManagerIntegration,
- SIGNAL(windowPropertyChanged(wl_client*,wl_surface*,QString,QVariant)),
- SLOT(windowPropertyChanged(wl_client*,wl_surface*,QString,QVariant)));
wl_display_add_global(m_display->handle(),&wl_compositor_interface,this,Compositor::bind_func);
m_input = new InputDevice(this);
m_data_device_manager = new DataDeviceManager(this);
- wl_display_add_global(m_display->handle(),&wl_output_interface, &m_output,Output::output_bind_func);
+ wl_display_add_global(m_display->handle(),&wl_output_interface, &m_output_global,OutputGlobal::output_bind_func);
wl_display_add_global(m_display->handle(), &wl_shell_interface, &m_shell, Shell::bind_func);
+ m_outputExtension = new OutputExtensionGlobal(this);
+ m_surfaceExtension = new SurfaceExtensionGlobal(this);
if (wl_display_add_socket(m_display->handle(), qt_compositor->socketName())) {
fprintf(stderr, "Fatal: Failed to open server socket\n");
QList<struct wl_client *> prevClientList = clients();
m_surfaces << surface;
+
+ //this is not how we want to solve this.
if (!prevClientList.contains(client)) {
- m_windowManagerIntegration->setScreenOrientation(client, m_output.resourceForClient(client), m_orientation);
+ Output *output = m_output_global.outputForClient(client);
+ Q_ASSERT(output);
+ if (output->extendedOutput()) {
+ output->extendedOutput()->sendOutputOrientation(m_orientation);
+ }
emit clientAdded(client);
}
fprintf(stderr, "wl_event_loop_dispatch error: %d\n", ret);
}
-void Compositor::windowPropertyChanged(wl_client *client, wl_surface *changedSurface, const QString &name, const QVariant &value)
-{
- for(int i = 0; i < m_surfaces.length(); ++i) {
- Surface *surface = m_surfaces[i];
- if (surface->clientHandle() == client && surface->base() == changedSurface) {
- surface->setWindowProperty(name, value, false);
- }
- }
-}
-
void Compositor::surfaceDestroyed(Surface *surface)
{
m_surfaces.removeOne(surface);
QList<struct wl_client*> clientList = clients();
for (int i = 0; i < clientList.length(); ++i) {
struct wl_client *client = clientList.at(i);
- m_windowManagerIntegration->setScreenOrientation(client, m_output.resourceForClient(client), orientation);
+ Output *output = m_output_global.outputForClient(client);
+ Q_ASSERT(output);
+ if (output->extendedOutput()){
+ output->extendedOutput()->sendOutputOrientation(orientation);
+ }
}
}
void Compositor::setOutputGeometry(const QRect &geometry)
{
- m_output.setGeometry(geometry);
+ m_output_global.setGeometry(geometry);
}
InputDevice* Compositor::defaultInputDevice()
class Surface;
class InputDevice;
class DataDeviceManager;
+class OutputExtensionGlobal;
+class SurfaceExtensionGlobal;
class Q_COMPOSITOR_EXPORT Compositor : public QObject
{
private slots:
void processWaylandEvents();
- void windowPropertyChanged(wl_client *client, wl_surface *surface, const QString &name, const QVariant &value);
private:
Display *m_display;
/* Output */
//make this a list of the available screens
- Output m_output;
+ OutputGlobal m_output_global;
Shell m_shell;
#ifdef QT_COMPOSITOR_WAYLAND_GL
GraphicsHardwareIntegration *m_graphics_hw_integration;
#endif
+
+ //extensions
WindowManagerServerIntegration *m_windowManagerIntegration;
+ OutputExtensionGlobal *m_outputExtension;
+ SurfaceExtensionGlobal *m_surfaceExtension;
+
static void bind_func(struct wl_client *client, void *data,
uint32_t version, uint32_t id);
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "wlextendedoutput.h"
+
+#include "wlcompositor.h"
+#include "wloutput.h"
+
+namespace Wayland {
+
+OutputExtensionGlobal::OutputExtensionGlobal(Compositor *compositor)
+ : m_compositor(compositor)
+{
+ wl_display_add_global(compositor->wl_display(),
+ &wl_output_extension_interface,
+ this,
+ OutputExtensionGlobal::bind_func);
+}
+
+void OutputExtensionGlobal::bind_func(wl_client *client, void *data, uint32_t version, uint32_t id)
+{
+ wl_client_add_object(client,&wl_output_extension_interface,&output_extension_interface,id,data);
+}
+
+void OutputExtensionGlobal::get_extended_output(wl_client *client, wl_resource *output_extension_resource, uint32_t id, wl_resource *output_resource)
+{
+ Q_UNUSED(output_extension_resource);
+ Output *output = static_cast<Output *>(output_resource->data);
+ new ExtendedOutput(client,id,output);
+}
+
+const struct wl_output_extension_interface OutputExtensionGlobal::output_extension_interface = {
+ OutputExtensionGlobal::get_extended_output
+};
+
+ExtendedOutput::ExtendedOutput(struct wl_client *client, uint32_t id, Output *output)
+ : m_output(output)
+{
+ Q_ASSERT(m_output->extendedOutput() == 0);
+ m_output->setExtendedOutput(this);
+ m_extended_output_resource = wl_client_add_object(client,&wl_extended_output_interface,0,id,this);
+}
+
+void ExtendedOutput::sendOutputOrientation(Qt::ScreenOrientation orientation)
+{
+ int sendOpperation;
+ switch (orientation) {
+ case Qt::PortraitOrientation:
+ sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION;
+ break;
+ case Qt::LandscapeOrientation:
+ sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_LANDSCAPEORIENTATION;
+ break;
+ case Qt::InvertedPortraitOrientation:
+ sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_INVERTEDPORTRAITORIENTATION;
+ break;
+ case Qt::InvertedLandscapeOrientation:
+ sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_INVERTEDLANDSCAPEORIENTATION;
+ break;
+ default:
+ sendOpperation = WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION;
+ }
+ wl_resource_post_event(m_extended_output_resource,WL_EXTENDED_OUTPUT_SET_SCREEN_ROTATION,sendOpperation);
+}
+
+
+}
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WLEXTENDEDOUTPUT_H
+#define WLEXTENDEDOUTPUT_H
+
+#include "wayland-output-extension-server-protocol.h"
+
+#include <QtCore/qnamespace.h>
+
+namespace Wayland {
+
+class Compositor;
+class Output;
+
+class OutputExtensionGlobal
+{
+public:
+ OutputExtensionGlobal(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_output(struct wl_client *client,
+ struct wl_resource *output_extension_resource,
+ uint32_t id,
+ struct wl_resource *output_resource);
+ static const struct wl_output_extension_interface output_extension_interface;
+
+};
+
+class ExtendedOutput
+{
+public:
+ ExtendedOutput(struct wl_client *client, uint32_t id, Output *output);
+
+ void sendOutputOrientation(Qt::ScreenOrientation orientation);
+
+private:
+ struct wl_resource *m_extended_output_resource;
+ Output *m_output;
+
+};
+
+}
+
+#endif // WLEXTENDEDOUTPUT_H
--- /dev/null
+/****************************************************************************
+**
+** This file is part of QtCompositor**
+**
+** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+**
+** Contact: Nokia Corporation qt-info@nokia.com
+**
+** You may use this file under the terms of the BSD license as follows:
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**
+** Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+**
+** Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in the
+** documentation and/or other materials provided with the distribution.
+**
+** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the
+** names of its contributors may be used to endorse or promote products
+** derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**
+****************************************************************************/
+
+#include "wlextendedsurface.h"
+
+#include "wlcompositor.h"
+#include "wlsurface.h"
+
+namespace Wayland {
+
+SurfaceExtensionGlobal::SurfaceExtensionGlobal(Compositor *compositor)
+ : m_compositor(compositor)
+{
+ wl_display_add_global(m_compositor->wl_display(),
+ &wl_surface_extension_interface,
+ this,
+ SurfaceExtensionGlobal::bind_func);
+}
+
+void SurfaceExtensionGlobal::bind_func(struct wl_client *client, void *data,
+ uint32_t version, uint32_t id)
+{
+ Q_UNUSED(version);
+ wl_client_add_object(client, &wl_surface_extension_interface,&surface_extension_interface,id,data);
+}
+
+const struct wl_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 = reinterpret_cast<Surface *>(surface_resource);
+ new ExtendedSurface(client,id,surface);
+}
+
+ExtendedSurface::ExtendedSurface(struct wl_client *client, uint32_t id, Surface *surface)
+ : m_surface(surface)
+{
+ Q_ASSERT(surface->extendedSurface() == 0);
+ surface->setExtendedSurface(this);
+ m_extended_surface_resource = wl_client_add_object(client,
+ &wl_extended_surface_interface,
+ &extended_surface_interface,
+ id,
+ this);
+}
+
+void ExtendedSurface::sendGenericProperty(const char *name, const QVariant &variant)
+{
+ QByteArray byteValue;
+ QDataStream ds(&byteValue, QIODevice::WriteOnly);
+ ds << variant;
+ wl_array data;
+ data.size = byteValue.size();
+ data.data = (void*) byteValue.constData();
+ data.alloc = 0;
+ wl_resource_post_event(m_extended_surface_resource,WL_EXTENDED_SURFACE_SET_GENERIC_PROPERTY, name,&data);
+
+}
+
+void ExtendedSurface::sendOnScreenVisibllity(bool visible)
+{
+ int32_t visibleInt = visible;
+ wl_resource_post_event(m_extended_surface_resource,WL_EXTENDED_SURFACE_ONSCREEN_VISIBILITY,visibleInt);
+}
+
+void ExtendedSurface::update_generic_property(wl_client *client, wl_resource *extended_surface_resource, const char *name, wl_array *value)
+{
+ Q_UNUSED(client);
+ ExtendedSurface *extended_surface = static_cast<ExtendedSurface *>(extended_surface_resource->data);
+ QVariant variantValue;
+ QByteArray byteValue((const char*)value->data, value->size);
+ QDataStream ds(&byteValue, QIODevice::ReadOnly);
+ ds >> variantValue;
+ extended_surface->m_surface->setWindowProperty(QString::fromLatin1(name),variantValue,false);
+
+}
+
+const struct wl_extended_surface_interface ExtendedSurface::extended_surface_interface = {
+ ExtendedSurface::update_generic_property
+};
+
+}
--- /dev/null
+/****************************************************************************
+**
+** This file is part of QtCompositor**
+**
+** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+**
+** Contact: Nokia Corporation qt-info@nokia.com
+**
+** You may use this file under the terms of the BSD license as follows:
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**
+** Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+**
+** Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in the
+** documentation and/or other materials provided with the distribution.
+**
+** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the
+** names of its contributors may be used to endorse or promote products
+** derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**
+****************************************************************************/
+
+#ifndef WLEXTENDEDSURFACE_H
+#define WLEXTENDEDSURFACE_H
+
+#include "wayland-surface-extension-server-protocol.h"
+
+#include <QtCore/QVariant>
+
+namespace Wayland {
+
+class Compositor;
+class Surface;
+
+class SurfaceExtensionGlobal
+{
+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 wl_surface_extension_interface surface_extension_interface;
+
+};
+
+class ExtendedSurface
+{
+public:
+ ExtendedSurface(struct wl_client *client, uint32_t id, Surface *surface);
+
+ void sendGenericProperty(const char *name, const QVariant &variant);
+ void sendOnScreenVisibllity(bool visible);
+
+private:
+ struct wl_resource *m_extended_surface_resource;
+ Surface *m_surface;
+
+ static void update_generic_property(struct wl_client *client,
+ struct wl_resource *resource,
+ const char *name,
+ struct wl_array *value);
+ static const struct wl_extended_surface_interface extended_surface_interface;
+};
+
+}
+
+#endif // WLEXTENDEDSURFACE_H
namespace Wayland {
-void Output::output_bind_func(struct wl_client *client, void *data,
+OutputGlobal::OutputGlobal()
+ : m_displayId(-1)
+ , m_numQueued(0)
+{
+ QScreen *screen = QGuiApplication::primaryScreen();
+ m_geometry = QRect(QPoint(0, 0), screen->availableGeometry().size());
+}
+
+void OutputGlobal::setGeometry(const QRect &geometry)
+{
+ m_geometry = geometry;
+}
+
+Output *OutputGlobal::outputForClient(wl_client *client) const
+{
+ return static_cast<Output *>(resourceForClient(client)->data);
+}
+
+void OutputGlobal::output_bind_func(struct wl_client *client, void *data,
uint32_t version, uint32_t id)
{
Q_UNUSED(version);
- Output *output = static_cast<Output *>(data);
+ OutputGlobal *output_global = static_cast<OutputGlobal *>(data);
- struct wl_resource *resource = wl_client_add_object(client,&wl_output_interface,0,id,data);
- output->registerResource(resource);
- wl_resource_post_event(resource, WL_OUTPUT_GEOMETRY, 0, 0,
- output->size().width(), output->size().height(),0,"","");
+ Output *output = new Output(output_global,client,version,id);
+ output_global->registerResource(output->handle());
+}
+
+
+
+Output::Output(OutputGlobal *outputGlobal, wl_client *client, uint32_t version, uint32_t id)
+ : m_output_global(outputGlobal)
+ , m_extended_output(0)
+{
+ Q_UNUSED(version);
+ m_output_resource = wl_client_add_object(client,&wl_output_interface,0,id,this);
+ wl_resource_post_event(m_output_resource, WL_OUTPUT_GEOMETRY, 0, 0,
+ m_output_global->size().width(), m_output_global->size().height(),0,"","");
+
+ wl_resource_post_event(m_output_resource,WL_OUTPUT_MODE, WL_OUTPUT_MODE_CURRENT|WL_OUTPUT_MODE_PREFERRED,
+ m_output_global->size().width(),m_output_global->size().height());
- wl_resource_post_event(resource,WL_OUTPUT_MODE, WL_OUTPUT_MODE_CURRENT|WL_OUTPUT_MODE_PREFERRED,
- output->size().width(),output->size().height());
}
+ExtendedOutput *Output::extendedOutput() const
+{
+ return m_extended_output;
+}
-Output::Output()
- : m_displayId(-1)
- , m_numQueued(0)
+void Output::setExtendedOutput(ExtendedOutput *extendedOutput)
{
- QScreen *screen = QGuiApplication::primaryScreen();
- m_geometry = QRect(QPoint(0, 0), screen->availableGeometry().size());
+ m_extended_output = extendedOutput;
}
-void Output::setGeometry(const QRect &geometry)
+wl_resource *Output::handle() const
{
- m_geometry = geometry;
+ return m_output_resource;
}
} // namespace Wayland
#include <QtCore/QRect>
+
namespace Wayland {
-class Output : public ResourceCollection
+class Output;
+class ExtendedOutput;
+
+class OutputGlobal : public ResourceCollection
{
public:
- Output();
+ OutputGlobal();
void setGeometry(const QRect &geometry);
int y() const { return m_geometry.y(); }
QSize size() const { return m_geometry.size(); }
+ Output *outputForClient(struct wl_client *client) const;
+
static void output_bind_func(struct wl_client *client, void *data,
uint32_t version, uint32_t id);
private:
};
+class Output
+{
+public:
+ Output(OutputGlobal *outputGlobal, wl_client *client, uint32_t version, uint32_t id);
+
+ OutputGlobal *outputGlobal() const;
+
+ ExtendedOutput *extendedOutput() const;
+ void setExtendedOutput(ExtendedOutput *extendedOutput);
+
+ struct wl_resource *handle() const;
+private:
+ struct wl_resource *m_output_resource;
+ OutputGlobal *m_output_global;
+ ExtendedOutput *m_extended_output;
+
+};
+
}
#endif //WL_OUTPUT_H
#include "wlcompositor.h"
#include "wlshmbuffer.h"
#include "wlinputdevice.h"
+#include "wlextendedsurface.h"
#include <QtCore/QDebug>
, frame_callback(0)
, surfaceBuffer(0)
, surfaceType(WaylandSurface::Invalid)
+ , extendedSurface(0)
{
struct wl_buffer *previousBuffer;
struct wl_resource *frame_callback;
+ ExtendedSurface *extendedSurface;
private:
struct wl_buffer *surfaceBuffer;
WaylandSurface::Type surfaceType;
{
Q_D(Surface);
d->windowProperties.insert(name, value);
- if (writeUpdateToClient)
- d->compositor->windowManagerIntegration()->setWindowProperty(d->client, base(), name, value);
+ handle()->windowPropertyChanged(name,value);
+ if (writeUpdateToClient && d->extendedSurface) {
+ const char *property = qPrintable(name);
+ d->extendedSurface->sendGenericProperty(property,value);
+ }
}
uint32_t toWaylandButton(Qt::MouseButton button)
return d->lastMousePos;
}
+void Surface::setExtendedSurface(ExtendedSurface *extendedSurface)
+{
+ Q_D(Surface);
+ d->extendedSurface = extendedSurface;
+}
+
+ExtendedSurface *Surface::extendedSurface() const
+{
+ Q_D(const Surface);
+ return d->extendedSurface;
+}
+
void Surface::sendMousePressEvent(int x, int y, Qt::MouseButton button)
{
Q_D(Surface);
void Surface::sendOnScreenVisibilityChange(bool visible)
{
-#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
Q_D(Surface);
- d->compositor->windowManagerIntegration()->setVisibilityOnScreen(d->client, visible);
-#endif
+ if (d->extendedSurface) {
+ d->extendedSurface->sendOnScreenVisibllity(visible);
+ }
}
} // namespace Wayland
class Compositor;
class Buffer;
+class ExtendedSurface;
class SurfacePrivate;
QVariant windowProperty(const QString &propertyName) const;
void setWindowProperty(const QString &name, const QVariant &value, bool writeUpdateToClient = true);
- void setSurfaceCreationFinished(bool isCreated);
-
QPoint lastMousePos() const;
+ void setExtendedSurface(ExtendedSurface *extendedSurface);
+ ExtendedSurface *extendedSurface() const;
+
static const struct wl_surface_interface surface_interface;
protected:
QScopedPointer<SurfacePrivate> d_ptr;
return m_managedClients.value(client, 0);
}
-void WindowManagerServerIntegration::setVisibilityOnScreen(wl_client *client, bool visible)
-{
- struct wl_resource *win_mgr_resource = resourceForClient(client);
- wl_resource_post_event(win_mgr_resource,WL_WINDOWMANAGER_CLIENT_ONSCREEN_VISIBILITY,visible);
-}
-
-void WindowManagerServerIntegration::setScreenOrientation(wl_client *client, wl_resource *output_resource, Qt::ScreenOrientation orientation)
-{
- struct wl_resource *win_mgr_resource = resourceForClient(client);
- wl_resource_post_event(win_mgr_resource,WL_WINDOWMANAGER_SET_SCREEN_ROTATION,output_resource, qint32(orientation));
-}
-
-// client -> server
-void WindowManagerServerIntegration::updateWindowProperty(wl_client *client, wl_surface *surface, const char *name, struct wl_array *value)
-{
- QVariant variantValue;
- QByteArray byteValue((const char*)value->data, value->size);
- QDataStream ds(&byteValue, QIODevice::ReadOnly);
- ds >> variantValue;
-
- emit windowPropertyChanged(client, surface, QString::fromLatin1(name), variantValue);
-}
-
-// server -> client
-void WindowManagerServerIntegration::setWindowProperty(wl_client *client, wl_surface *surface, const QString &name, const QVariant &value)
-{
- QByteArray byteValue;
- QDataStream ds(&byteValue, QIODevice::WriteOnly);
- ds << value;
- wl_array data;
- data.size = byteValue.size();
- data.data = (void*) byteValue.constData();
- data.alloc = 0;
-
- struct wl_resource *win_mgr_resource = resourceForClient(client);
- wl_resource_post_event(win_mgr_resource,WL_WINDOWMANAGER_SET_GENERIC_PROPERTY,surface, name.toLatin1().constData(),&data);
-}
-
-
void WindowManagerServerIntegration::mapClientToProcess(wl_client *client, uint32_t processId)
{
WaylandManagedClient *managedClient = m_managedClients.value(client, new WaylandManagedClient);
window_mgr->authenticateWithToken(client,wl_authentication_token);
}
-void WindowManagerServerIntegration::update_generic_property(struct wl_client *client,
- struct wl_resource *window_mgr_resource,
- wl_resource *surface_resource,
- const char *name,
- struct wl_array *value)
-{
- WindowManagerServerIntegration *window_mgr = static_cast<WindowManagerServerIntegration *>(window_mgr_resource->data);
- struct wl_surface *surface = static_cast<struct wl_surface *>(surface_resource->data);
- window_mgr->updateWindowProperty(client,surface,name,value);
-}
-
const struct wl_windowmanager_interface WindowManagerServerIntegration::windowmanager_interface = {
WindowManagerServerIntegration::map_client_to_process,
WindowManagerServerIntegration::authenticate_with_token,
- WindowManagerServerIntegration::update_generic_property
};
WaylandManagedClient *managedClient(wl_client *client) const;
- void setVisibilityOnScreen(wl_client *client, bool visible);
void setScreenOrientation(wl_client *client, struct wl_resource *output_resource, Qt::ScreenOrientation orientationInDegrees);
- void updateWindowProperty(wl_client *client, struct wl_surface *surface, const char *name, struct wl_array *value);
- void setWindowProperty(wl_client *client, struct wl_surface *surface, const QString &name, const QVariant &value);
-
signals:
void clientAuthenticated(wl_client *client);
- void windowPropertyChanged(wl_client *client, struct wl_surface *surface, const QString &name, const QVariant &value);
private:
void mapClientToProcess(wl_client *client, uint32_t processId);
static void authenticate_with_token(struct wl_client *client,
struct wl_resource *windowMgrResource,
const char *wl_authentication_token);
- static void update_generic_property(struct wl_client *client,
- struct wl_resource *windowMgrResource,
- struct wl_resource *surfaceResource,
- const char *name, struct wl_array *value);
static const struct wl_windowmanager_interface windowmanager_interface;
};
m_waylandEglWindow = wl_egl_window_create(mSurface, size.width(), size.height());
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
- QWaylandWindowManagerIntegration::instance()->flushPropertyChanges(this);
+ //remove when we don't delay wl_surface creation
+// QWaylandWindowManagerIntegration::instance()->flushPropertyChanges(this);
#endif
}
#include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
#endif
+#include "qwaylandextendedoutput.h"
+#include "qwaylandextendedsurface.h"
+
#include <QtCore/QAbstractEventDispatcher>
#include <QtGui/private/qguiapplication_p.h>
QWaylandDisplay::QWaylandDisplay(void)
: mDndSelectionHandler(0)
, mLastKeyboardFocusInputDevice(0)
+ , mWindowExtension(0)
+ , mOutputExtension(0)
{
display = this;
qRegisterMetaType<uint32_t>("uint32_t");
mInputDevices.append(inputDevice);
} else if (interface == "wl_data_device_manager") {
mDndSelectionHandler = new QWaylandDataDeviceManager(this, id);
+ } else if (interface == "wl_output_extension") {
+ mOutputExtension = new QWaylandOutputExtension(this,id);
+ } else if (interface == "wl_surface_extension") {
+ mWindowExtension = new QWaylandSurfaceExtension(this,id);
}
}
class QWaylandWindowManagerIntegration;
class QWaylandDataDeviceManager;
class QWaylandShell;
+class QWaylandSurfaceExtension;
+class QWaylandOutputExtension;
class QWaylandDisplay : public QObject {
Q_OBJECT
QWaylandDataDeviceManager *dndSelectionHandler() const { return mDndSelectionHandler; }
+ QWaylandSurfaceExtension *windowExtension() const { return mWindowExtension; }
+ QWaylandOutputExtension *outputExtension() const { return mOutputExtension; }
+
struct wl_shm *shm() const { return mShm; }
static uint32_t currentTimeMillisec();
QList<QWaylandInputDevice *> mInputDevices;
QWaylandInputDevice *mLastKeyboardFocusInputDevice;
QWaylandDataDeviceManager *mDndSelectionHandler;
+ QWaylandSurfaceExtension *mWindowExtension;
+ QWaylandOutputExtension *mOutputExtension;
QSocketNotifier *mReadNotifier;
int mFd;
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandextendedoutput.h"
+
+#include "qwaylandscreen.h"
+
+#include "wayland-output-extension-client-protocol.h"
+
+#include <QtGui/QWindowSystemInterface>
+
+#include <QtCore/QDebug>
+
+QWaylandOutputExtension::QWaylandOutputExtension(QWaylandDisplay *display, uint32_t id)
+{
+ m_output_extension = static_cast<struct wl_output_extension *>(
+ wl_display_bind(display->wl_display(),id, &wl_output_extension_interface));
+
+ QList<QPlatformScreen *> platformScreens = display->screens();
+ for (int i = 0; i < platformScreens.size(); i++) {
+ QWaylandScreen *waylandScreen = static_cast<QWaylandScreen *>(platformScreens.at(i));
+ if (!waylandScreen->extendedOutput()) {
+ QWaylandExtendedOutput *extendedOutput = getExtendedOutput(waylandScreen);
+ waylandScreen->setExtendedOutput(extendedOutput);
+ qDebug() << "extended output enabled";
+ }
+ }
+}
+
+QWaylandExtendedOutput *QWaylandOutputExtension::getExtendedOutput(QWaylandScreen *screen)
+{
+ qDebug() << "getExtendedOutput";
+ struct wl_extended_output *extended_output =
+ wl_output_extension_get_extended_output(m_output_extension,screen->output());
+ return new QWaylandExtendedOutput(screen,extended_output);
+}
+
+QWaylandExtendedOutput::QWaylandExtendedOutput(QWaylandScreen *screen, wl_extended_output *extended_output)
+ : m_extended_output(extended_output)
+ , m_screen(screen)
+ , m_orientation(m_screen->primaryOrientation())
+{
+ wl_extended_output_add_listener(m_extended_output,&extended_output_listener,this);
+}
+
+Qt::ScreenOrientation QWaylandExtendedOutput::currentOrientation() const
+{
+ return m_orientation;
+}
+
+void QWaylandExtendedOutput::set_screen_rotation(void *data, wl_extended_output *wl_extended_output, int32_t rotation)
+{
+ Q_UNUSED(wl_extended_output);
+ QWaylandExtendedOutput *extended_output = static_cast<QWaylandExtendedOutput *>(data);
+ switch (rotation) {
+ case WL_EXTENDED_OUTPUT_ROTATION_PORTRAITORIENTATION:
+ extended_output->m_orientation = Qt::PortraitOrientation;
+ break;
+ case WL_EXTENDED_OUTPUT_ROTATION_LANDSCAPEORIENTATION:
+ extended_output->m_orientation = Qt::LandscapeOrientation;
+ break;
+ case WL_EXTENDED_OUTPUT_ROTATION_INVERTEDPORTRAITORIENTATION:
+ extended_output->m_orientation = Qt::InvertedPortraitOrientation;
+ break;
+ case WL_EXTENDED_OUTPUT_ROTATION_INVERTEDLANDSCAPEORIENTATION:
+ extended_output->m_orientation = Qt::InvertedLandscapeOrientation;
+ break;
+ default:
+ extended_output->m_orientation = Qt::PortraitOrientation;
+ break;
+ }
+ QWindowSystemInterface::handleScreenOrientationChange(extended_output->m_screen->screen());
+}
+
+const struct wl_extended_output_listener QWaylandExtendedOutput::extended_output_listener = {
+ QWaylandExtendedOutput::set_screen_rotation
+};
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDEXTENDEDOUTPUT_H
+#define QWAYLANDEXTENDEDOUTPUT_H
+
+#include "qwaylanddisplay.h"
+
+class QWaylandExtendedOutput;
+
+class QWaylandOutputExtension
+{
+public:
+ QWaylandOutputExtension(QWaylandDisplay *display, uint32_t id);
+
+ QWaylandExtendedOutput* getExtendedOutput(QWaylandScreen *screen);
+private:
+ struct wl_output_extension *m_output_extension;
+};
+
+class QWaylandExtendedOutput
+{
+public:
+ QWaylandExtendedOutput(QWaylandScreen *screen, struct wl_extended_output *extended_output);
+
+ Qt::ScreenOrientation currentOrientation() const;
+private:
+ struct wl_extended_output *m_extended_output;
+ QWaylandScreen *m_screen;
+ Qt::ScreenOrientation m_orientation;
+
+ static void set_screen_rotation(void *data,
+ struct wl_extended_output *wl_extended_output,
+ int32_t rotation);
+ static const struct wl_extended_output_listener extended_output_listener;
+};
+
+
+#endif // QWAYLANDEXTENDEDOUTPUT_H
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandextendedsurface.h"
+
+#include "qwaylandwindow.h"
+
+#include "wayland-client.h"
+#include "wayland-surface-extension-client-protocol.h"
+
+#include "qwaylanddisplay.h"
+
+#include "qwaylandnativeinterface.h"
+
+#include <QtGui/QGuiApplication>
+#include <QtGui/QPlatformNativeInterface>
+
+QWaylandSurfaceExtension::QWaylandSurfaceExtension(QWaylandDisplay *display, uint32_t id)
+{
+ m_surface_extension = static_cast<struct wl_surface_extension *>(
+ wl_display_bind(display->wl_display(),id, &wl_surface_extension_interface));
+}
+
+QWaylandExtendedSurface *QWaylandSurfaceExtension::getExtendedWindow(QWaylandWindow *window)
+{
+ struct wl_surface *surface = window->wl_surface();
+ Q_ASSERT(surface);
+ struct wl_extended_surface *extended_surface =
+ wl_surface_extension_get_extended_surface(m_surface_extension,surface);
+
+ return new QWaylandExtendedSurface(window,extended_surface);
+}
+
+
+QWaylandExtendedSurface::QWaylandExtendedSurface(QWaylandWindow *window, struct wl_extended_surface *extended_surface)
+ : m_window(window)
+ , m_extended_surface(extended_surface)
+{
+ wl_extended_surface_add_listener(m_extended_surface,&QWaylandExtendedSurface::extended_surface_listener,this);
+}
+
+void QWaylandExtendedSurface::updateGenericProperty(const QString &name, const QVariant &value)
+{
+
+ QByteArray byteValue;
+ QDataStream ds(&byteValue, QIODevice::WriteOnly);
+ ds << value;
+
+ wl_array data;
+ data.size = byteValue.size();
+ data.data = (void*)byteValue.constData();
+ data.alloc = 0;
+
+ wl_extended_surface_update_generic_property(m_extended_surface,qPrintable(name),&data);
+
+ m_properties.insert(name,value);
+ QWaylandNativeInterface *nativeInterface = static_cast<QWaylandNativeInterface *>(
+ QGuiApplication::platformNativeInterface());
+ nativeInterface->emitWindowPropertyChanged(m_window,name);
+}
+
+QVariantMap QWaylandExtendedSurface::properties() const
+{
+ return m_properties;
+}
+
+QVariant QWaylandExtendedSurface::property(const QString &name)
+{
+ return m_properties.value(name);
+}
+
+QVariant QWaylandExtendedSurface::property(const QString &name, const QVariant &defaultValue)
+{
+ return m_properties.value(name,defaultValue);
+}
+
+void QWaylandExtendedSurface::onscreen_visibility(void *data, wl_extended_surface *wl_extended_surface, int32_t visible)
+{
+ QWaylandExtendedSurface *extendedWindow = static_cast<QWaylandExtendedSurface *>(data);
+ Q_UNUSED(extendedWindow);
+ Q_UNUSED(wl_extended_surface);
+
+ QEvent evt(visible != 0 ? QEvent::ApplicationActivate : QEvent::ApplicationDeactivate);
+ QCoreApplication::sendEvent(QCoreApplication::instance(), &evt);
+}
+
+void QWaylandExtendedSurface::set_generic_property(void *data, wl_extended_surface *wl_extended_surface, const char *name, wl_array *value)
+{
+ Q_UNUSED(wl_extended_surface);
+
+ QWaylandExtendedSurface *extended_window = static_cast<QWaylandExtendedSurface *>(data);
+
+ QVariant variantValue;
+ QByteArray baValue = QByteArray((const char*)value->data, value->size);
+ QDataStream ds(&baValue, QIODevice::ReadOnly);
+ ds >> variantValue;
+
+ QString qstring_name = QString::fromLatin1(name);
+ extended_window->m_properties.insert(qstring_name,variantValue);
+
+ QWaylandNativeInterface *nativeInterface = static_cast<QWaylandNativeInterface *>(
+ QGuiApplication::platformNativeInterface());
+ nativeInterface->emitWindowPropertyChanged(extended_window->m_window,QString::fromLatin1(name));
+}
+
+const struct wl_extended_surface_listener QWaylandExtendedSurface::extended_surface_listener = {
+ QWaylandExtendedSurface::onscreen_visibility,
+ QWaylandExtendedSurface::set_generic_property
+};
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDEXTENDEDSURFACE_H
+#define QWAYLANDEXTENDEDSURFACE_H
+
+#include <wayland-client.h>
+
+#include <QtCore/QString>
+#include <QtCore/QVariant>
+
+class QWaylandDisplay;
+class QWaylandWindow;
+class QWaylandExtendedSurface;
+
+class QWaylandSurfaceExtension
+{
+public:
+ QWaylandSurfaceExtension(QWaylandDisplay *display, uint32_t id);
+
+ QWaylandExtendedSurface *getExtendedWindow(QWaylandWindow *window);
+private:
+ struct wl_surface_extension *m_surface_extension;
+};
+
+class QWaylandExtendedSurface
+{
+public:
+ QWaylandExtendedSurface(QWaylandWindow *window, struct wl_extended_surface *extended_surface);
+
+ void updateGenericProperty(const QString &name, const QVariant &value);
+ QVariantMap properties() const;
+ QVariant property(const QString &name);
+ QVariant property(const QString &name, const QVariant &defaultValue);
+private:
+ QWaylandWindow *m_window;
+ struct wl_extended_surface *m_extended_surface;
+
+ QVariantMap m_properties;
+
+ static void onscreen_visibility(void *data,
+ struct wl_extended_surface *wl_extended_surface,
+ int32_t visible);
+
+ static void set_generic_property(void *data,
+ struct wl_extended_surface *wl_extended_surface,
+ const char *name,
+ struct wl_array *value);
+
+ static const struct wl_extended_surface_listener extended_surface_listener;
+
+};
+
+#endif // QWAYLANDEXTENDEDSURFACE_H
#include "qwaylandnativeinterface.h"
#include "qwaylanddisplay.h"
#include "qwaylandwindow.h"
+#include "qwaylandextendedsurface.h"
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/QScreen>
QVariantMap QWaylandNativeInterface::windowProperties(QPlatformWindow *window) const
{
- return m_windowProperties.value(window);
+ QWaylandWindow *waylandWindow = static_cast<QWaylandWindow *>(window);
+ if (QWaylandExtendedSurface *extendedWindow = waylandWindow->extendedWindow())
+ return extendedWindow->properties();
+ return QVariantMap();
}
+
QVariant QWaylandNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const
{
- const QVariantMap properties = m_windowProperties.value(window);
- return properties.value(name);
+ QWaylandWindow *waylandWindow = static_cast<QWaylandWindow *>(window);
+ if (QWaylandExtendedSurface *extendedWindow = waylandWindow->extendedWindow())
+ return extendedWindow->property(name);
+ return QVariant();
}
QVariant QWaylandNativeInterface::windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const
{
- const QVariantMap properties = m_windowProperties.value(window);
- return properties.value(name, defaultValue);
+ QWaylandWindow *waylandWindow = static_cast<QWaylandWindow *>(window);
+ if (QWaylandExtendedSurface *extendedWindow = waylandWindow->extendedWindow()) {
+ return extendedWindow->property(name,defaultValue);
+ }
+ return defaultValue;
}
void QWaylandNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value)
{
- QVariantMap props = m_windowProperties.value(window);
- props.insert(name, value);
- m_windowProperties.insert(window, props);
-
QWaylandWindow *wlWindow = static_cast<QWaylandWindow*>(window);
-#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
- QWaylandWindowManagerIntegration::instance()->setWindowProperty(wlWindow, name, value);
-#endif
+ if (QWaylandExtendedSurface *extendedWindow = wlWindow->extendedWindow())
+ extendedWindow->updateGenericProperty(name,value);
+}
- emit windowPropertyChanged(window, name);
+void QWaylandNativeInterface::emitWindowPropertyChanged(QPlatformWindow *window, const QString &name)
+{
+ emit windowPropertyChanged(window,name);
}
QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const;
void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value);
+ void emitWindowPropertyChanged(QPlatformWindow *window, const QString &name);
private:
static QWaylandScreen *qPlatformScreenForWindow(QWindow *window);
#include "qwaylanddisplay.h"
#include "qwaylandcursor.h"
+#include "qwaylandextendedoutput.h"
#include <QWindowSystemInterface>
: QPlatformScreen()
, mWaylandDisplay(waylandDisplay)
, mOutput(output)
+ , mExtendedOutput(0)
, mGeometry(geometry)
, mDepth(32)
, mFormat(QImage::Format_ARGB32_Premultiplied)
- , mOrientation(primaryOrientation())
, mWaylandCursor(new QWaylandCursor(this))
{
+ //maybe the global is sent after the first screen?
+ if (waylandDisplay->outputExtension()) {
+ mExtendedOutput = waylandDisplay->outputExtension()->getExtendedOutput(this);
+ }
}
QWaylandScreen::~QWaylandScreen()
Qt::ScreenOrientation QWaylandScreen::currentOrientation() const
{
- return mOrientation;
+ if (mExtendedOutput)
+ return mExtendedOutput->currentOrientation();
+ return primaryOrientation();
}
-void QWaylandScreen::setOrientation(const Qt::ScreenOrientation orientation)
+QWaylandExtendedOutput *QWaylandScreen::extendedOutput() const
{
- mOrientation = orientation;
- QWindowSystemInterface::handleScreenOrientationChange(screen());
+ return mExtendedOutput;
+}
+
+void QWaylandScreen::setExtendedOutput(QWaylandExtendedOutput *extendedOutput)
+{
+ Q_ASSERT(!mExtendedOutput);
+ mExtendedOutput = extendedOutput;
}
QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window)
class QWaylandDisplay;
class QWaylandCursor;
+class QWaylandExtendedOutput;
class QWaylandScreen : public QPlatformScreen
{
QImage::Format format() const;
Qt::ScreenOrientation currentOrientation() const;
- void setOrientation(const Qt::ScreenOrientation orientation);
wl_output *output() const { return mOutput; }
+ QWaylandExtendedOutput *extendedOutput() const;
+ void setExtendedOutput(QWaylandExtendedOutput *extendedOutput);
+
static QWaylandScreen *waylandScreenFromWindow(QWindow *window);
private:
QWaylandDisplay *mWaylandDisplay;
struct wl_output *mOutput;
+ QWaylandExtendedOutput *mExtendedOutput;
QRect mGeometry;
int mDepth;
QImage::Format mFormat;
QSize mPhysicalSize;
- Qt::ScreenOrientation mOrientation;
+
QWaylandCursor *mWaylandCursor;
};
#include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
#endif
+#include "qwaylandextendedsurface.h"
+
#include <QCoreApplication>
#include <QtGui/QWindowSystemInterface>
{
if (mSurface) {
delete mShellSurface;
+ delete mExtendedWindow;
wl_surface_destroy(mSurface);
}
if (!mSurface && visible) {
mSurface = mDisplay->createSurface(this);
mShellSurface = mDisplay->shell()->createShellSurface(this);
+ if (mDisplay->windowExtension())
+ mExtendedWindow = mDisplay->windowExtension()->getExtendedWindow(this);
newSurfaceCreated();
wl_shell_surface_set_toplevel(mShellSurface->handle());
}
if (!visible) {
+ delete mShellSurface;
+ mShellSurface = 0;
+ delete mExtendedWindow;
+ mExtendedWindow = 0;
wl_surface_destroy(mSurface);
mSurface = NULL;
}
// the first frame has been rendered
}
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
- QWaylandWindowManagerIntegration::instance()->flushPropertyChanges(this);
+ //TODO: remove when we don't delay wl_surface creation
+// QWaylandWindowManagerIntegration::instance()->flushPropertyChanges(this);
#endif
}
while (mWaitingForFrameSync)
mDisplay->blockingReadEvents();
}
+
+QWaylandShellSurface *QWaylandWindow::shellSurface() const
+{
+ return mShellSurface;
+}
+
+QWaylandExtendedSurface *QWaylandWindow::extendedWindow() const
+{
+ return mExtendedWindow;
+}
class QWaylandDisplay;
class QWaylandBuffer;
class QWaylandShellSurface;
+class QWaylandExtendedSurface;
struct wl_egl_window;
class QWaylandWindow : public QPlatformWindow
struct wl_surface *wl_surface() const { return mSurface; }
QWaylandShellSurface *shellSurface() const;
+ QWaylandExtendedSurface *extendedWindow() const;
+
protected:
struct wl_surface *mSurface;
QWaylandShellSurface *mShellSurface;
+ QWaylandExtendedSurface *mExtendedWindow;
+
virtual void newSurfaceCreated();
QWaylandDisplay *mDisplay;
QWaylandBuffer *mBuffer;
QT += core-private gui-private opengl-private platformsupport-private
+WAYLANDSOURCES += \
+ $$PWD/../../../../extensions/surface-extension/surface-extension.xml \
+ $$PWD/../../../../extensions/output-extension/output-extension.xml
+
SOURCES = main.cpp \
qwaylandintegration.cpp \
qwaylandnativeinterface.cpp \
qwaylanddatadevicemanager.cpp \
qwaylanddatasource.cpp \
qwaylandshell.cpp \
- qwaylandshellsurface.cpp
+ qwaylandshellsurface.cpp \
+ qwaylandextendedoutput.cpp \
+ qwaylandextendedsurface.cpp
HEADERS = qwaylandintegration.h \
qwaylandnativeinterface.h \
qwaylanddatadevicemanager.h \
qwaylanddatasource.h \
qwaylandshell.h \
- qwaylandshellsurface.h
+ qwaylandshellsurface.h \
+ qwaylandextendedoutput.h \
+ qwaylandextendedsurface.h
INCLUDEPATH += $$QMAKE_INCDIR_WAYLAND
LIBS += $$QMAKE_LIBS_WAYLAND
QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::m_instance = 0;
-const struct wl_windowmanager_listener QWaylandWindowManagerIntegration::m_windowManagerListener = {
- QWaylandWindowManagerIntegration::wlHandleOnScreenVisibilityChange,
- QWaylandWindowManagerIntegration::wlHandleScreenOrientationChange,
- QWaylandWindowManagerIntegration::wlHandleWindowPropertyChange
-};
QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::createIntegration(QWaylandDisplay *waylandDisplay)
{
QWaylandWindowManagerIntegration *integration = static_cast<QWaylandWindowManagerIntegration *>(data);
integration->d_ptr->m_waylandWindowManager =
static_cast<struct wl_windowmanager *>(wl_display_bind(display, id, &wl_windowmanager_interface));
- wl_windowmanager *windowManager = integration->d_ptr->m_waylandWindowManager;
- wl_windowmanager_add_listener(windowManager, &m_windowManagerListener, integration);
}
}
wl_windowmanager_authenticate_with_token(d->m_waylandWindowManager, authToken.constData());
}
}
-
-static wl_array writePropertyValue(const QVariant &value)
-{
- QByteArray byteValue;
- QDataStream ds(&byteValue, QIODevice::WriteOnly);
- ds << value;
-
- wl_array data;
- data.size = byteValue.size();
- data.data = (void*)byteValue.constData();
- data.alloc = 0;
-
- return data;
-}
-
-void QWaylandWindowManagerIntegration::setWindowProperty(QWaylandWindow *window, const QString &propertyName, const QVariant &propertyValue)
-{
- Q_D(QWaylandWindowManagerIntegration);
- if (d->m_blockPropertyUpdates)
- return;
-
- if (window->wl_surface()) {
- wl_array data = writePropertyValue(propertyValue);
- wl_windowmanager_update_generic_property(d->m_waylandWindowManager, window->wl_surface(),
- propertyName.toLatin1().constData(),
- &data);
- } else {
- QVariantMap props = d->m_queuedProperties.value(window->window());
- props.insert(propertyName, propertyValue);
- d->m_queuedProperties.insert(window->window(), props);
- connect(window->window(), SIGNAL(destroyed()), SLOT(removeQueuedPropertiesForWindow()));
- }
-}
-
-void QWaylandWindowManagerIntegration::flushPropertyChanges(QWaylandWindow *windowToFlush)
-{
- // write all changes we got while we did not have a surface.
- // this can happen during startup, for example, or while the window is hidden.
- Q_D(QWaylandWindowManagerIntegration);
-
- if (!windowToFlush || !windowToFlush->window())
- return;
-
-
- QVariantMap properties = d->m_queuedProperties.value(windowToFlush->window());
- wl_surface *surface = windowToFlush->wl_surface();
-
- QMapIterator<QString, QVariant> pIt(properties);
- while (pIt.hasNext()) {
- pIt.next();
- wl_array data = writePropertyValue(pIt.value());
- wl_windowmanager_update_generic_property(d->m_waylandWindowManager, surface, pIt.key().toLatin1().constData(), &data);
- }
-
- d->m_queuedProperties.clear();
-}
-
-void QWaylandWindowManagerIntegration::removeQueuedPropertiesForWindow()
-{
- Q_D(QWaylandWindowManagerIntegration);
- QWindow *window = static_cast<QWindow*>(sender());
- d->m_queuedProperties.remove(window);
-}
-
-void QWaylandWindowManagerIntegration::wlHandleOnScreenVisibilityChange(void *data, struct wl_windowmanager *wl_windowmanager, int visible)
-{
- Q_UNUSED(data);
- Q_UNUSED(wl_windowmanager);
- QEvent evt(visible != 0 ? QEvent::ApplicationActivate : QEvent::ApplicationDeactivate);
- QCoreApplication::sendEvent(QCoreApplication::instance(), &evt);
-}
-
-void QWaylandWindowManagerIntegration::wlHandleScreenOrientationChange(void *data, struct wl_windowmanager *wl_windowmanager,
- struct wl_output *wl_output, int screenOrientation)
-{
- QWaylandWindowManagerIntegration *integration = QWaylandWindowManagerIntegration::instance();
- QWaylandScreen *screen = integration->d_ptr->m_waylandDisplay->screenForOutput(wl_output);
- if (screen)
- screen->setOrientation(Qt::ScreenOrientation(screenOrientation));
-}
-
-void QWaylandWindowManagerIntegration::wlHandleWindowPropertyChange(void *data, struct wl_windowmanager *wl_windowmanager,
- struct wl_surface *surface,
- const char *propertyName, struct wl_array *propertyValue)
-{
- // window manager changes a window property
- Q_UNUSED(data);
- Q_UNUSED(wl_windowmanager);
-
- QVariant variantValue;
- QByteArray baValue = QByteArray((const char*)propertyValue->data, propertyValue->size);
- QDataStream ds(&baValue, QIODevice::ReadOnly);
- ds >> variantValue;
-
- QPlatformNativeInterface *nativeInterface = qApp->platformNativeInterface();
- QWaylandWindowManagerIntegration *inst = QWaylandWindowManagerIntegration::instance();
-
- QList<QWindow *> windows = qApp->topLevelWindows();
- foreach (QWindow *window, windows) {
- QPlatformWindow *platformWindowForWindow = window->handle();
- if (!platformWindowForWindow)
- continue;
- QWaylandWindow *waylandWindow = static_cast<QWaylandWindow*>(platformWindowForWindow);
- wl_surface *windowSurface = (wl_surface*)nativeInterface->nativeResourceForWindow(QByteArray("surface"), window);
- if (windowSurface == surface) {
- inst->handleWindowPropertyChange(waylandWindow, QString(propertyName), variantValue);
- break;
- }
- }
-}
-
-void QWaylandWindowManagerIntegration::handleWindowPropertyChange(QWaylandWindow *window,
- const QString &propertyName, const QVariant &propertyValue)
-{
- Q_D(QWaylandWindowManagerIntegration);
- d->m_blockPropertyUpdates = true;
-
- QPlatformNativeInterface *nativeInterface = qApp->platformNativeInterface();
- nativeInterface->setWindowProperty(window, propertyName, propertyValue);
-
- d->m_blockPropertyUpdates = false;
-}
void mapSurfaceToProcess(struct wl_surface *surface, long long processId);
void mapClientToProcess(long long processId);
void authenticateWithToken(const QByteArray &token = QByteArray());
- void setWindowProperty(QWaylandWindow *window, const QString &propertyName, const QVariant &propertyValue);
-
- void flushPropertyChanges(QWaylandWindow *windowToFlush);
-
-private slots:
- void removeQueuedPropertiesForWindow();
private:
static void wlHandleListenerGlobal(wl_display *display, uint32_t id,
const char *interface, uint32_t version, void *data);
- static void wlHandleOnScreenVisibilityChange(void *data, struct wl_windowmanager *wl_windowmanager, int visible);
- static void wlHandleScreenOrientationChange(void *data, struct wl_windowmanager *wl_windowmanager,
- struct wl_output *wl_output, int screenOrientation);
- static void wlHandleWindowPropertyChange(void *data, struct wl_windowmanager *wl_windowmanager,
- struct wl_surface *surface,
- const char *propertyName, struct wl_array *propertyValue);
-
- void handleWindowPropertyChange(QWaylandWindow *window, const QString &propertyName, const QVariant &propertyValue);
-
private:
QScopedPointer<QWaylandWindowManagerIntegrationPrivate> d_ptr;
static QWaylandWindowManagerIntegration *m_instance;