1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the Qt Compositor.
9 ** $QT_BEGIN_LICENSE:BSD$
10 ** You may use this file under the terms of the BSD license as follows:
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
15 ** * Redistributions of source code must retain the above copyright
16 ** notice, this list of conditions and the following disclaimer.
17 ** * Redistributions in binary form must reproduce the above copyright
18 ** notice, this list of conditions and the following disclaimer in
19 ** the documentation and/or other materials provided with the
21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22 ** the names of its contributors may be used to endorse or promote
23 ** products derived from this software without specific prior written
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ****************************************************************************/
41 #ifndef WL_COMPOSITOR_H
42 #define WL_COMPOSITOR_H
44 #include "waylandexport.h"
46 #include <QtCore/QSet>
49 #include "wldisplay.h"
50 #include "wlshmbuffer.h"
52 #include <wayland-server.h>
54 class WaylandCompositor;
55 class GraphicsHardwareIntegration;
56 class WindowManagerServerIntegration;
63 class DataDeviceManager;
64 class OutputExtensionGlobal;
65 class SurfaceExtensionGlobal;
66 class SubSurfaceExtensionGlobal;
68 class TouchExtensionGlobal;
70 class Q_COMPOSITOR_EXPORT Compositor : public QObject
75 Compositor(WaylandCompositor *qt_compositor);
78 void frameFinished(Surface *surface = 0);
80 Surface *getSurfaceFromWinId(uint winId) const;
81 struct wl_client *getClientFromWinId(uint winId) const;
82 QImage image(uint winId) const;
84 InputDevice *defaultInputDevice(); //we just have 1 default device for now (since QPA doesn't give us anything else)
86 void createSurface(struct wl_client *client, uint32_t id);
87 void surfaceDestroyed(Surface *surface);
88 void markSurfaceAsDirty(Surface *surface);
90 void destroyClientForSurface(Surface *surface);
92 static uint currentTimeMsecs();
94 QWindow *window() const;
96 GraphicsHardwareIntegration *graphicsHWIntegration() const;
97 void initializeHardwareIntegration();
98 void initializeDefaultInputDevice();
99 void initializeWindowManagerProtocol();
100 void enableSubSurfaceExtension();
101 bool setDirectRenderSurface(Surface *surface);
102 Surface *directRenderSurface() const {return m_directRenderSurface;}
104 QList<Surface*> surfacesForClient(wl_client* client);
106 WaylandCompositor *qtCompositor() const { return m_qt_compositor; }
108 struct wl_display *wl_display() const { return m_display->handle(); }
110 static Compositor *instance();
112 QList<struct wl_client *> clients() const;
114 WindowManagerServerIntegration *windowManagerIntegration() const { return m_windowManagerIntegration; }
116 void setScreenOrientation(Qt::ScreenOrientation orientation);
117 Qt::ScreenOrientation screenOrientation() const;
118 void setOutputGeometry(const QRect &geometry);
120 void enableTouchExtension();
121 TouchExtensionGlobal *touchExtension() { return m_touchExtension; }
123 bool isDragging() const;
124 void sendDragMoveEvent(const QPoint &global, const QPoint &local, Surface *surface);
125 void sendDragEndEvent();
127 typedef void (*RetainedSelectionFunc)(QMimeData *, void *);
128 void setRetainedSelectionWatcher(RetainedSelectionFunc func, void *param);
129 void overrideSelection(QMimeData *data);
131 bool wantsRetainedSelection() const;
132 void feedRetainedSelectionData(QMimeData *data);
135 void releaseBuffer(void*);
138 void processWaylandEvents();
144 InputDevice *m_default_input_device;
147 //make this a list of the available screens
148 OutputGlobal m_output_global;
152 DataDeviceManager *m_data_device_manager;
154 QList<Surface *> m_surfaces;
155 QSet<Surface *> m_dirty_surfaces;
158 uint32_t m_current_frame;
159 int m_last_queued_buf;
161 wl_event_loop *m_loop;
163 WaylandCompositor *m_qt_compositor;
164 Qt::ScreenOrientation m_orientation;
166 Surface *m_directRenderSurface;
168 #ifdef QT_COMPOSITOR_WAYLAND_GL
169 GraphicsHardwareIntegration *m_graphics_hw_integration;
173 WindowManagerServerIntegration *m_windowManagerIntegration;
177 OutputExtensionGlobal *m_outputExtension;
178 SurfaceExtensionGlobal *m_surfaceExtension;
179 SubSurfaceExtensionGlobal *m_subSurfaceExtension;
180 TouchExtensionGlobal *m_touchExtension;
182 static void bind_func(struct wl_client *client, void *data,
183 uint32_t version, uint32_t id);
185 RetainedSelectionFunc m_retainNotify;
186 void *m_retainNotifyParam;
191 #endif //WL_COMPOSITOR_H