Remove the window_manager_integration object.
[profile/ivi/qtwayland.git] / src / compositor / wayland_wrapper / wlcompositor.h
1 /****************************************************************************
2 **
3 ** This file is part of QtCompositor**
4 **
5 ** Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).
6 ** All rights reserved.
7 **
8 ** Contact:  Nokia Corporation qt-info@nokia.com
9 **
10 ** You may use this file under the terms of the BSD license as follows:
11 **
12 ** Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
14 ** met:
15 **
16 ** Redistributions of source code must retain the above copyright
17 ** notice, this list of conditions and the following disclaimer.
18 **
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.
22 **
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.
26 **
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.
38 **
39 ****************************************************************************/
40
41 #ifndef WL_COMPOSITOR_H
42 #define WL_COMPOSITOR_H
43
44 #include "waylandexport.h"
45
46 #include <QtCore/QSet>
47
48 #include "wloutput.h"
49 #include "wldisplay.h"
50 #include "wlshmbuffer.h"
51 #include "wlshell.h"
52
53 #include <wayland-server.h>
54
55 class WaylandCompositor;
56 class GraphicsHardwareIntegration;
57 class WindowManagerServerIntegration;
58
59 namespace Wayland {
60
61 class Surface;
62 class InputDevice;
63 class DataDeviceManager;
64
65 class Q_COMPOSITOR_EXPORT Compositor : public QObject
66 {
67     Q_OBJECT
68
69 public:
70     Compositor(WaylandCompositor *qt_compositor);
71     ~Compositor();
72
73     void frameFinished(Surface *surface = 0);
74     void setInputFocus(Surface *surface);
75     void setKeyFocus(Surface *surface);
76     Surface *keyFocus() const;
77     void setPointerFocus(Surface *surface, const QPoint &point = QPoint());
78     Surface *pointerFocus() const;
79
80     Surface *getSurfaceFromWinId(uint winId) const;
81     struct wl_client *getClientFromWinId(uint winId) const;
82     QImage image(uint winId) const;
83
84     InputDevice *inputDevice() { return m_input; }
85     InputDevice *defaultInputDevice();
86
87     void createSurface(struct wl_client *client, int id);
88     void surfaceDestroyed(Surface *surface);
89     void markSurfaceAsDirty(Surface *surface);
90
91     void destroyClientForSurface(Surface *surface);
92
93     static uint currentTimeMsecs();
94
95     QWindow *window() const;
96
97     GraphicsHardwareIntegration *graphicsHWIntegration() const;
98     void initializeHardwareIntegration();
99     void initializeWindowManagerProtocol();
100     bool setDirectRenderSurface(Surface *surface);
101     Surface *directRenderSurface() const {return m_directRenderSurface;}
102
103     QList<Surface*> surfacesForClient(wl_client* client);
104
105     WaylandCompositor *qtCompositor() const { return m_qt_compositor; }
106
107     struct wl_display *wl_display() const { return m_display->handle(); }
108
109     static Compositor *instance();
110
111     QList<struct wl_client *> clients() const;
112
113     WindowManagerServerIntegration *windowManagerIntegration() const { return m_windowManagerIntegration; }
114
115     void setScreenOrientation(Qt::ScreenOrientation orientation);
116     void setOutputGeometry(const QRect &geometry);
117
118     bool isDragging() const;
119     void sendDragMoveEvent(const QPoint &global, const QPoint &local, Surface *surface);
120     void sendDragEndEvent();
121
122 public slots:
123     void releaseBuffer(void*);
124
125 signals:
126     void clientAdded(wl_client *client);
127
128 private slots:
129     void processWaylandEvents();
130     void windowPropertyChanged(wl_client *client, wl_surface *surface, const QString &name, const QVariant &value);
131
132 private:
133     Display *m_display;
134
135     /* Input */
136     InputDevice *m_input;
137
138     /* Output */
139     //make this a list of the available screens
140     Output m_output;
141
142     Shell m_shell;
143
144     /* shm/*/
145     ShmHandler m_shm;
146
147     DataDeviceManager *m_data_device_manager;
148
149     QList<Surface *> m_surfaces;
150     QSet<Surface *> m_dirty_surfaces;
151
152     /* Render state */
153     uint32_t m_current_frame;
154     int m_last_queued_buf;
155
156     wl_event_loop *m_loop;
157
158     WaylandCompositor *m_qt_compositor;
159     Qt::ScreenOrientation m_orientation;
160
161     Surface *m_pointerFocusSurface;
162     Surface *m_keyFocusSurface;
163     Surface *m_directRenderSurface;
164
165 #ifdef QT_COMPOSITOR_WAYLAND_GL
166     GraphicsHardwareIntegration *m_graphics_hw_integration;
167 #endif
168     WindowManagerServerIntegration *m_windowManagerIntegration;
169
170     static void bind_func(struct wl_client *client, void *data,
171                           uint32_t version, uint32_t id);
172 };
173
174 }
175
176 #endif //WL_COMPOSITOR_H