Add XComposite extension to wayland
[profile/ivi/qtwayland.git] / src / qt-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 "wloutput.h"
45 #include "wldisplay.h"
46 #include "wlshmbuffer.h"
47
48 #include <wayland-server.h>
49
50 class WaylandCompositor;
51 class GraphicsHardwareIntegration;
52 class QWidget;
53
54 namespace Wayland {
55
56 class Surface;
57
58 class Compositor : public QObject, public Object<struct wl_compositor>
59 {
60     Q_OBJECT
61
62 public:
63     Compositor(WaylandCompositor *qt_compositor);
64     ~Compositor();
65
66     void frameFinished();
67     void setInputFocus(Surface *surface);
68     void setKeyFocus(Surface *surface);
69     void setPointerFocus(Surface *surface, const QPoint &point = QPoint());
70
71     Surface *getSurfaceFromWinId(uint winId) const;
72     struct wl_client *getClientFromWinId(uint winId) const;
73     QImage image(uint winId) const;
74
75     const struct wl_input_device *inputDevice() const { return &m_input; }
76     struct wl_input_device *inputDevice() { return &m_input; }
77
78     void createSurface(struct wl_client *client, int id);
79     void surfaceDestroyed(Surface *surface);
80
81     void destroyClientForSurface(Surface *surface);
82
83     uint currentTimeMsecs() const;
84
85     QWidget *topLevelWidget() const;
86
87     GraphicsHardwareIntegration *graphicsHWIntegration() const;
88     void initializeHardwareIntegration();
89
90     wl_input_device *defaultInputDevice();
91 private slots:
92     void processWaylandEvents();
93
94 private:
95     Display *m_display;
96
97     /* Input */
98     struct wl_input_device m_input;
99
100     /* Output */
101     Output m_output;
102
103     struct wl_object m_shell;
104
105     /* shm/*/
106     ShmHandler m_shm;
107     QList<Surface *> m_surfaces;
108
109     /* Render state */
110     uint32_t m_current_frame;
111     int m_last_queued_buf;
112
113     wl_event_loop *m_loop;
114
115     WaylandCompositor *m_qt_compositor;
116
117     Surface *m_pointerFocusSurface;
118     Surface *m_keyFocusSurface;
119
120 #ifdef QT_COMPOSITOR_WAYLAND_GL
121     GraphicsHardwareIntegration *m_graphics_hw_integration;
122 #endif
123 };
124
125 }
126
127 #endif //WL_COMPOSITOR_H