1 /****************************************************************************
3 ** This file is part of QtCompositor**
5 ** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).
6 ** All rights reserved.
8 ** Contact: Nokia Corporation qt-info@nokia.com
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
16 ** Redistributions of source code must retain the above copyright
17 ** notice, this list of conditions and the following disclaimer.
19 ** Redistributions in binary form must reproduce the above copyright
20 ** notice, this list of conditions and the following disclaimer in the
21 ** documentation and/or other materials provided with the distribution.
23 ** Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the
24 ** names of its contributors may be used to endorse or promote products
25 ** derived from this software without specific prior written permission.
27 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 ** 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;
69 class Q_COMPOSITOR_EXPORT Compositor : public QObject
74 Compositor(WaylandCompositor *qt_compositor);
77 void frameFinished(Surface *surface = 0);
78 void setInputFocus(Surface *surface);
79 void setKeyFocus(Surface *surface);
80 Surface *keyFocus() const;
81 void setPointerFocus(Surface *surface, const QPoint &globalPos = QPoint(), const QPoint &localPos = QPoint());
82 Surface *pointerFocus() const;
84 Surface *getSurfaceFromWinId(uint winId) const;
85 struct wl_client *getClientFromWinId(uint winId) const;
86 QImage image(uint winId) const;
88 InputDevice *inputDevice() { return m_input; }
89 InputDevice *defaultInputDevice();
91 void createSurface(struct wl_client *client, uint32_t id);
92 void surfaceDestroyed(Surface *surface);
93 void markSurfaceAsDirty(Surface *surface);
95 void destroyClientForSurface(Surface *surface);
97 static uint currentTimeMsecs();
99 QWindow *window() const;
101 GraphicsHardwareIntegration *graphicsHWIntegration() const;
102 void initializeHardwareIntegration();
103 void initializeWindowManagerProtocol();
104 void enableSubSurfaceExtension();
105 bool setDirectRenderSurface(Surface *surface);
106 Surface *directRenderSurface() const {return m_directRenderSurface;}
108 QList<Surface*> surfacesForClient(wl_client* client);
110 WaylandCompositor *qtCompositor() const { return m_qt_compositor; }
112 struct wl_display *wl_display() const { return m_display->handle(); }
114 static Compositor *instance();
116 QList<struct wl_client *> clients() const;
118 WindowManagerServerIntegration *windowManagerIntegration() const { return m_windowManagerIntegration; }
120 void setScreenOrientation(Qt::ScreenOrientation orientation);
121 Qt::ScreenOrientation screenOrientation() const;
122 void setOutputGeometry(const QRect &geometry);
124 bool isDragging() const;
125 void sendDragMoveEvent(const QPoint &global, const QPoint &local, Surface *surface);
126 void sendDragEndEvent();
128 typedef void (*RetainedSelectionFunc)(QMimeData *, void *);
129 void setRetainedSelectionWatcher(RetainedSelectionFunc func, void *param);
130 void overrideSelection(QMimeData *data);
132 bool wantsRetainedSelection() const;
133 void feedRetainedSelectionData(QMimeData *data);
136 void releaseBuffer(void*);
139 void processWaylandEvents();
145 InputDevice *m_input;
148 //make this a list of the available screens
149 OutputGlobal m_output_global;
153 DataDeviceManager *m_data_device_manager;
155 QList<Surface *> m_surfaces;
156 QSet<Surface *> m_dirty_surfaces;
159 uint32_t m_current_frame;
160 int m_last_queued_buf;
162 wl_event_loop *m_loop;
164 WaylandCompositor *m_qt_compositor;
165 Qt::ScreenOrientation m_orientation;
167 Surface *m_directRenderSurface;
169 #ifdef QT_COMPOSITOR_WAYLAND_GL
170 GraphicsHardwareIntegration *m_graphics_hw_integration;
174 WindowManagerServerIntegration *m_windowManagerIntegration;
178 OutputExtensionGlobal *m_outputExtension;
179 SurfaceExtensionGlobal *m_surfaceExtension;
180 SubSurfaceExtensionGlobal *m_subSurfaceExtension;
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