Compositor memory leak fixes
[profile/ivi/qtwayland.git] / src / compositor / wayland_wrapper / wlcompositor.h
index a95916d..d8acad2 100644 (file)
@@ -1,28 +1,26 @@
 /****************************************************************************
 **
-** This file is part of QtCompositor**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
 **
-** Copyright © 2010 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:BSD$
 ** 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
+** "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.
+**   * 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
@@ -34,7 +32,9 @@
 ** 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.
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
 **
 ****************************************************************************/
 
 #include "wloutput.h"
 #include "wldisplay.h"
 #include "wlshmbuffer.h"
-#include "wlshell.h"
 
 #include <wayland-server.h>
 
 class WaylandCompositor;
+class WaylandInputDevice;
 class GraphicsHardwareIntegration;
 class WindowManagerServerIntegration;
+class QMimeData;
 
 namespace Wayland {
 
 class Surface;
 class InputDevice;
 class DataDeviceManager;
+class OutputExtensionGlobal;
+class SurfaceExtensionGlobal;
+class SubSurfaceExtensionGlobal;
+class Shell;
+class TouchExtensionGlobal;
 
 class Q_COMPOSITOR_EXPORT Compositor : public QObject
 {
@@ -71,20 +77,15 @@ public:
     ~Compositor();
 
     void frameFinished(Surface *surface = 0);
-    void setInputFocus(Surface *surface);
-    void setKeyFocus(Surface *surface);
-    Surface *keyFocus() const;
-    void setPointerFocus(Surface *surface, const QPoint &point = QPoint());
-    Surface *pointerFocus() const;
 
+    //these 3 functions will be removed if noone steps up soon.
     Surface *getSurfaceFromWinId(uint winId) const;
     struct wl_client *getClientFromWinId(uint winId) const;
     QImage image(uint winId) const;
 
-    InputDevice *inputDevice() { return m_input; }
-    InputDevice *defaultInputDevice();
+    InputDevice *defaultInputDevice(); //we just have 1 default device for now (since QPA doesn't give us anything else)
 
-    void createSurface(struct wl_client *client, int id);
+    void createSurface(struct wl_client *client, uint32_t id);
     void surfaceDestroyed(Surface *surface);
     void markSurfaceAsDirty(Surface *surface);
 
@@ -96,49 +97,60 @@ public:
 
     GraphicsHardwareIntegration *graphicsHWIntegration() const;
     void initializeHardwareIntegration();
+    void initializeDefaultInputDevice();
     void initializeWindowManagerProtocol();
+    void enableSubSurfaceExtension();
     bool setDirectRenderSurface(Surface *surface);
     Surface *directRenderSurface() const {return m_directRenderSurface;}
 
     QList<Surface*> surfacesForClient(wl_client* client);
 
-    WaylandCompositor *qtCompositor() const { return m_qt_compositor; }
+    WaylandCompositor *waylandCompositor() const { return m_qt_compositor; }
 
-    struct wl_display *wl_display() { return m_display->handle(); }
+    struct wl_display *wl_display() const { return m_display->handle(); }
 
     static Compositor *instance();
 
     QList<struct wl_client *> clients() const;
 
+    WindowManagerServerIntegration *windowManagerIntegration() const { return m_windowManagerIntegration; }
+
     void setScreenOrientation(Qt::ScreenOrientation orientation);
+    Qt::ScreenOrientation screenOrientation() const;
     void setOutputGeometry(const QRect &geometry);
+    QRect outputGeometry() const;
+
+    void enableTouchExtension();
+    TouchExtensionGlobal *touchExtension() { return m_touchExtension; }
+    void configureTouchExtension(int flags);
 
     bool isDragging() const;
     void sendDragMoveEvent(const QPoint &global, const QPoint &local, Surface *surface);
     void sendDragEndEvent();
 
+    typedef void (*RetainedSelectionFunc)(QMimeData *, void *);
+    void setRetainedSelectionWatcher(RetainedSelectionFunc func, void *param);
+    void overrideSelection(QMimeData *data);
+
+    bool wantsRetainedSelection() const;
+    void feedRetainedSelectionData(QMimeData *data);
+
 public slots:
     void releaseBuffer(void*);
 
-signals:
-    void clientAdded(wl_client *client);
-
 private slots:
     void processWaylandEvents();
-    void windowPropertyChanged(wl_client *client, wl_surface *surface, const QString &name, const QVariant &value);
 
 private:
     Display *m_display;
 
     /* Input */
-    InputDevice *m_input;
+    WaylandInputDevice *m_default_wayland_input_device;
+    InputDevice *m_default_input_device;
 
     /* Output */
     //make this a list of the available screens
-    Output m_output;
-
-    Shell m_shell;
-
+    OutputGlobal m_output_global;
     /* shm/*/
     ShmHandler m_shm;
 
@@ -156,17 +168,27 @@ private:
     WaylandCompositor *m_qt_compositor;
     Qt::ScreenOrientation m_orientation;
 
-    Surface *m_pointerFocusSurface;
-    Surface *m_keyFocusSurface;
     Surface *m_directRenderSurface;
 
 #ifdef QT_COMPOSITOR_WAYLAND_GL
     GraphicsHardwareIntegration *m_graphics_hw_integration;
 #endif
-    WindowManagerServerIntegration *m_windowManagerWaylandProtocol;
+
+    //extensions
+    WindowManagerServerIntegration *m_windowManagerIntegration;
+
+
+    Shell *m_shell;
+    OutputExtensionGlobal *m_outputExtension;
+    SurfaceExtensionGlobal *m_surfaceExtension;
+    SubSurfaceExtensionGlobal *m_subSurfaceExtension;
+    TouchExtensionGlobal *m_touchExtension;
 
     static void bind_func(struct wl_client *client, void *data,
                           uint32_t version, uint32_t id);
+
+    RetainedSelectionFunc m_retainNotify;
+    void *m_retainNotifyParam;
 };
 
 }