Added surface_extension and output_extension
authorJørgen Lind <jorgen.lind@nokia.com>
Mon, 19 Dec 2011 09:51:12 +0000 (10:51 +0100)
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>
Tue, 20 Dec 2011 12:58:55 +0000 (13:58 +0100)
This is an atempt on removing WindowManagerIntegration and create more
specialised extensions. Hopefully it will reduce tha "map lookups" we
have all because of the windowmanagerintegration is way to generic, and
hopefully it will make it easier to ready and understand the code

Change-Id: I126c430e87909e4520f6d241c0a6023214cb509a
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
34 files changed:
examples/qml-compositor/qml-compositor.pro
extensions/output-extension/output-extension.xml [new file with mode: 0644]
extensions/surface-extension/surface-extension.xml [new file with mode: 0644]
extensions/windowmanager/windowmanager.xml
src/compositor/compositor_api/waylandsurface.h
src/compositor/wayland_wrapper/wayland_wrapper.pri
src/compositor/wayland_wrapper/wlcompositor.cpp
src/compositor/wayland_wrapper/wlcompositor.h
src/compositor/wayland_wrapper/wlextendedoutput.cpp [new file with mode: 0644]
src/compositor/wayland_wrapper/wlextendedoutput.h [new file with mode: 0644]
src/compositor/wayland_wrapper/wlextendedsurface.cpp [new file with mode: 0644]
src/compositor/wayland_wrapper/wlextendedsurface.h [new file with mode: 0644]
src/compositor/wayland_wrapper/wloutput.cpp
src/compositor/wayland_wrapper/wloutput.h
src/compositor/wayland_wrapper/wlsurface.cpp
src/compositor/wayland_wrapper/wlsurface.h
src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp
src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h
src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp
src/plugins/platforms/wayland/qwaylanddisplay.cpp
src/plugins/platforms/wayland/qwaylanddisplay.h
src/plugins/platforms/wayland/qwaylandextendedoutput.cpp [new file with mode: 0644]
src/plugins/platforms/wayland/qwaylandextendedoutput.h [new file with mode: 0644]
src/plugins/platforms/wayland/qwaylandextendedsurface.cpp [new file with mode: 0644]
src/plugins/platforms/wayland/qwaylandextendedsurface.h [new file with mode: 0644]
src/plugins/platforms/wayland/qwaylandnativeinterface.cpp
src/plugins/platforms/wayland/qwaylandnativeinterface.h
src/plugins/platforms/wayland/qwaylandscreen.cpp
src/plugins/platforms/wayland/qwaylandscreen.h
src/plugins/platforms/wayland/qwaylandwindow.cpp
src/plugins/platforms/wayland/qwaylandwindow.h
src/plugins/platforms/wayland/wayland.pro
src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp
src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h

index 7a564d2..88c4ca0 100644 (file)
@@ -8,7 +8,7 @@ CONFIG += use_pkgconfig
 
 LIBS += -L ../../lib
 
-QT += quick v8
+QT += quick declarative     v8
 QT += quick-private
 
 QT += compositor
diff --git a/extensions/output-extension/output-extension.xml b/extensions/output-extension/output-extension.xml
new file mode 100644 (file)
index 0000000..32996ea
--- /dev/null
@@ -0,0 +1,71 @@
+<!--
+# /****************************************************************************
+# **
+# ** 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>
diff --git a/extensions/surface-extension/surface-extension.xml b/extensions/surface-extension/surface-extension.xml
new file mode 100644 (file)
index 0000000..db150ae
--- /dev/null
@@ -0,0 +1,75 @@
+<!--
+# /****************************************************************************
+# **
+# ** 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>
index 6f0db5b..d9d5b39 100644 (file)
             <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>
index d9f68d7..c62e384 100644 (file)
@@ -111,6 +111,7 @@ public:
 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;
index 478b399..4e35462 100644 (file)
@@ -1,3 +1,8 @@
+WAYLANDSOURCES += \
+                $$PWD/../../../extensions/surface-extension/surface-extension.xml \
+                $$PWD/../../../extensions/output-extension/output-extension.xml
+
+
 HEADERS += \
     $$PWD/wlcompositor.h \
     $$PWD/wldisplay.h \
@@ -9,7 +14,9 @@ HEADERS += \
     $$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 \
@@ -22,5 +29,7 @@ SOURCES += \
     $$PWD/wldatadevicemanager.cpp \
     $$PWD/wldatadevice.cpp \
     $$PWD/wldataoffer.cpp \
-    $$PWD/wldatasource.cpp
+    $$PWD/wldatasource.cpp \
+    $$PWD/wlextendedsurface.cpp \
+    $$PWD/wlextendedoutput.cpp
 
index 4094f85..c4ed0ec 100644 (file)
@@ -47,6 +47,8 @@
 #include "waylandcompositor.h"
 #include "wldatadevicemanager.h"
 #include "wldatadevice.h"
+#include "wlextendedoutput.h"
+#include "wlextendedsurface.h"
 
 #include <QWindow>
 #include <QSocketNotifier>
@@ -124,6 +126,8 @@ Compositor::Compositor(WaylandCompositor *qt_compositor)
     , m_graphics_hw_integration(0)
 #endif
     , m_retainNotify(0)
+    , m_outputExtension(0)
+    , m_surfaceExtension(0)
 {
     compositor = this;
     qDebug() << "Compositor instance is" << this;
@@ -135,19 +139,18 @@ Compositor::Compositor(WaylandCompositor *qt_compositor)
         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");
@@ -194,8 +197,14 @@ void Compositor::createSurface(struct wl_client *client, int id)
 
     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);
     }
 
@@ -260,16 +269,6 @@ void Compositor::processWaylandEvents()
         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);
@@ -383,13 +382,17 @@ void Compositor::setScreenOrientation(Qt::ScreenOrientation orientation)
     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()
index 9f1b496..9cf75ec 100644 (file)
@@ -62,6 +62,8 @@ namespace Wayland {
 class Surface;
 class InputDevice;
 class DataDeviceManager;
+class OutputExtensionGlobal;
+class SurfaceExtensionGlobal;
 
 class Q_COMPOSITOR_EXPORT Compositor : public QObject
 {
@@ -135,7 +137,6 @@ signals:
 
 private slots:
     void processWaylandEvents();
-    void windowPropertyChanged(wl_client *client, wl_surface *surface, const QString &name, const QVariant &value);
 
 private:
     Display *m_display;
@@ -145,7 +146,7 @@ private:
 
     /* Output */
     //make this a list of the available screens
-    Output m_output;
+    OutputGlobal m_output_global;
 
     Shell m_shell;
 
@@ -173,8 +174,13 @@ private:
 #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);
 
diff --git a/src/compositor/wayland_wrapper/wlextendedoutput.cpp b/src/compositor/wayland_wrapper/wlextendedoutput.cpp
new file mode 100644 (file)
index 0000000..0ce55ed
--- /dev/null
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** 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);
+}
+
+
+}
diff --git a/src/compositor/wayland_wrapper/wlextendedoutput.h b/src/compositor/wayland_wrapper/wlextendedoutput.h
new file mode 100644 (file)
index 0000000..5b3d5c0
--- /dev/null
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** 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
diff --git a/src/compositor/wayland_wrapper/wlextendedsurface.cpp b/src/compositor/wayland_wrapper/wlextendedsurface.cpp
new file mode 100644 (file)
index 0000000..85bdd8e
--- /dev/null
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** 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
+};
+
+}
diff --git a/src/compositor/wayland_wrapper/wlextendedsurface.h b/src/compositor/wayland_wrapper/wlextendedsurface.h
new file mode 100644 (file)
index 0000000..d322896
--- /dev/null
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** 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
index 0221107..c7c7d0c 100644 (file)
 
 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
index 30ce64b..83f7d84 100644 (file)
 
 #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);
 
@@ -58,6 +62,8 @@ public:
     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:
@@ -67,6 +73,24 @@ 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
index 28cbf5e..7712745 100644 (file)
@@ -45,6 +45,7 @@
 #include "wlcompositor.h"
 #include "wlshmbuffer.h"
 #include "wlinputdevice.h"
+#include "wlextendedsurface.h"
 
 #include <QtCore/QDebug>
 
@@ -85,6 +86,7 @@ public:
         , frame_callback(0)
         , surfaceBuffer(0)
         , surfaceType(WaylandSurface::Invalid)
+        , extendedSurface(0)
 
 
     {
@@ -147,6 +149,7 @@ public:
 
     struct wl_buffer *previousBuffer;
     struct wl_resource *frame_callback;
+    ExtendedSurface *extendedSurface;
 private:
     struct wl_buffer *surfaceBuffer;
     WaylandSurface::Type surfaceType;
@@ -347,8 +350,11 @@ void Surface::setWindowProperty(const QString &name, const QVariant &value, bool
 {
     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)
@@ -375,6 +381,18 @@ QPoint Surface::lastMousePos() const
     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);
@@ -500,10 +518,10 @@ void Surface::setInputFocus()
 
 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
index 11262cf..b994ae9 100644 (file)
@@ -63,6 +63,7 @@ namespace Wayland {
 
 class Compositor;
 class Buffer;
+class ExtendedSurface;
 
 class SurfacePrivate;
 
@@ -116,10 +117,11 @@ public:
     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;
index 3580b3e..fdaa757 100644 (file)
@@ -68,45 +68,6 @@ WaylandManagedClient *WindowManagerServerIntegration::managedClient(wl_client *c
     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);
@@ -151,21 +112,9 @@ void WindowManagerServerIntegration::authenticate_with_token(struct wl_client *c
     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
 };
 
 
index fdf9b8d..b345dcc 100644 (file)
@@ -72,15 +72,10 @@ public:
 
     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);
@@ -99,10 +94,6 @@ private:
     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;
 };
 
index aebc44c..e9da602 100644 (file)
@@ -105,7 +105,8 @@ void QWaylandEglWindow::newSurfaceCreated()
     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
 }
 
index 886676e..0d62877 100644 (file)
@@ -57,6 +57,9 @@
 #include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
 #endif
 
+#include "qwaylandextendedoutput.h"
+#include "qwaylandextendedsurface.h"
+
 #include <QtCore/QAbstractEventDispatcher>
 #include <QtGui/private/qguiapplication_p.h>
 
@@ -109,6 +112,8 @@ static QWaylandDisplay *display = 0;
 QWaylandDisplay::QWaylandDisplay(void)
     : mDndSelectionHandler(0)
     , mLastKeyboardFocusInputDevice(0)
+    , mWindowExtension(0)
+    , mOutputExtension(0)
 {
     display = this;
     qRegisterMetaType<uint32_t>("uint32_t");
@@ -297,6 +302,10 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id,
         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);
     }
 }
 
index d18c691..cce0486 100644 (file)
@@ -59,6 +59,8 @@ class QWaylandGLIntegration;
 class QWaylandWindowManagerIntegration;
 class QWaylandDataDeviceManager;
 class QWaylandShell;
+class QWaylandSurfaceExtension;
+class QWaylandOutputExtension;
 
 class QWaylandDisplay : public QObject {
     Q_OBJECT
@@ -94,6 +96,9 @@ public:
 
     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();
@@ -119,6 +124,8 @@ private:
     QList<QWaylandInputDevice *> mInputDevices;
     QWaylandInputDevice *mLastKeyboardFocusInputDevice;
     QWaylandDataDeviceManager *mDndSelectionHandler;
+    QWaylandSurfaceExtension *mWindowExtension;
+    QWaylandOutputExtension *mOutputExtension;
 
     QSocketNotifier *mReadNotifier;
     int mFd;
diff --git a/src/plugins/platforms/wayland/qwaylandextendedoutput.cpp b/src/plugins/platforms/wayland/qwaylandextendedoutput.cpp
new file mode 100644 (file)
index 0000000..0173604
--- /dev/null
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** 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
+};
diff --git a/src/plugins/platforms/wayland/qwaylandextendedoutput.h b/src/plugins/platforms/wayland/qwaylandextendedoutput.h
new file mode 100644 (file)
index 0000000..e6288a6
--- /dev/null
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** 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
diff --git a/src/plugins/platforms/wayland/qwaylandextendedsurface.cpp b/src/plugins/platforms/wayland/qwaylandextendedsurface.cpp
new file mode 100644 (file)
index 0000000..97b5296
--- /dev/null
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** 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
+};
diff --git a/src/plugins/platforms/wayland/qwaylandextendedsurface.h b/src/plugins/platforms/wayland/qwaylandextendedsurface.h
new file mode 100644 (file)
index 0000000..10d17b9
--- /dev/null
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** 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
index 01c14ef..48effb9 100644 (file)
@@ -42,6 +42,7 @@
 #include "qwaylandnativeinterface.h"
 #include "qwaylanddisplay.h"
 #include "qwaylandwindow.h"
+#include "qwaylandextendedsurface.h"
 #include <QtGui/private/qguiapplication_p.h>
 #include <QtGui/QScreen>
 
@@ -75,31 +76,38 @@ QWaylandScreen * QWaylandNativeInterface::qPlatformScreenForWindow(QWindow *wind
 
 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);
 }
index 9db442a..102e139 100644 (file)
@@ -57,6 +57,7 @@ public:
     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);
 
index 48471b7..8a23a9e 100644 (file)
@@ -43,6 +43,7 @@
 
 #include "qwaylanddisplay.h"
 #include "qwaylandcursor.h"
+#include "qwaylandextendedoutput.h"
 
 #include <QWindowSystemInterface>
 
@@ -50,12 +51,16 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, struct wl_output
     : 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()
@@ -85,13 +90,20 @@ QImage::Format QWaylandScreen::format() const
 
 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)
index 678243d..1e7c4a3 100644 (file)
@@ -46,6 +46,7 @@
 
 class QWaylandDisplay;
 class QWaylandCursor;
+class QWaylandExtendedOutput;
 
 class QWaylandScreen : public QPlatformScreen
 {
@@ -60,20 +61,23 @@ public:
     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;
 };
 
index e921b86..43eafaf 100644 (file)
@@ -54,6 +54,8 @@
 #include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
 #endif
 
+#include "qwaylandextendedsurface.h"
+
 #include <QCoreApplication>
 #include <QtGui/QWindowSystemInterface>
 
@@ -81,6 +83,7 @@ QWaylandWindow::~QWaylandWindow()
 {
     if (mSurface) {
         delete mShellSurface;
+        delete mExtendedWindow;
         wl_surface_destroy(mSurface);
     }
 
@@ -105,11 +108,17 @@ void QWaylandWindow::setVisible(bool visible)
     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;
     }
@@ -159,7 +168,8 @@ void QWaylandWindow::newSurfaceCreated()
         // 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
 }
 
@@ -184,3 +194,13 @@ void QWaylandWindow::waitForFrameSync()
     while (mWaitingForFrameSync)
         mDisplay->blockingReadEvents();
 }
+
+QWaylandShellSurface *QWaylandWindow::shellSurface() const
+{
+    return mShellSurface;
+}
+
+QWaylandExtendedSurface *QWaylandWindow::extendedWindow() const
+{
+    return mExtendedWindow;
+}
index 1419f17..8ce8161 100644 (file)
@@ -50,6 +50,7 @@
 class QWaylandDisplay;
 class QWaylandBuffer;
 class QWaylandShellSurface;
+class QWaylandExtendedSurface;
 struct wl_egl_window;
 
 class QWaylandWindow : public QPlatformWindow
@@ -79,9 +80,13 @@ public:
     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;
index 58dafe8..ec4c12a 100644 (file)
@@ -15,6 +15,10 @@ mac {
 
 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 \
@@ -31,7 +35,9 @@ SOURCES =   main.cpp \
             qwaylanddatadevicemanager.cpp \
             qwaylanddatasource.cpp \
             qwaylandshell.cpp \
-            qwaylandshellsurface.cpp
+            qwaylandshellsurface.cpp \
+            qwaylandextendedoutput.cpp \
+            qwaylandextendedsurface.cpp
 
 HEADERS =   qwaylandintegration.h \
             qwaylandnativeinterface.h \
@@ -48,7 +54,9 @@ HEADERS =   qwaylandintegration.h \
             qwaylanddatadevicemanager.h \
             qwaylanddatasource.h \
             qwaylandshell.h \
-            qwaylandshellsurface.h
+            qwaylandshellsurface.h \
+            qwaylandextendedoutput.h \
+            qwaylandextendedsurface.h
 
 INCLUDEPATH += $$QMAKE_INCDIR_WAYLAND
 LIBS += $$QMAKE_LIBS_WAYLAND
index 9b34df4..f09c5ed 100644 (file)
@@ -74,11 +74,6 @@ QWaylandWindowManagerIntegrationPrivate::QWaylandWindowManagerIntegrationPrivate
 
 QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::m_instance = 0;
 
-const struct wl_windowmanager_listener QWaylandWindowManagerIntegration::m_windowManagerListener = {
-    QWaylandWindowManagerIntegration::wlHandleOnScreenVisibilityChange,
-    QWaylandWindowManagerIntegration::wlHandleScreenOrientationChange,
-    QWaylandWindowManagerIntegration::wlHandleWindowPropertyChange
-};
 
 QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::createIntegration(QWaylandDisplay *waylandDisplay)
 {
@@ -118,8 +113,6 @@ void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *displa
         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);
     }
 }
 
@@ -141,125 +134,3 @@ void QWaylandWindowManagerIntegration::authenticateWithToken(const QByteArray &t
         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;
-}
index 50cd232..80366fe 100644 (file)
@@ -67,26 +67,11 @@ public:
     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;