1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the plugins of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QWAYLANDDISPLAY_H
43 #define QWAYLANDDISPLAY_H
45 #include <QtCore/QObject>
46 #include <QtCore/QRect>
48 #include <QtCore/QWaitCondition>
50 #include <wayland-client.h>
52 class QAbstractEventDispatcher;
53 class QWaylandInputDevice;
54 class QSocketNotifier;
56 class QPlatformScreen;
58 class QWaylandGLIntegration;
59 class QWaylandWindowManagerIntegration;
60 class QWaylandDataDeviceManager;
62 class QWaylandSurfaceExtension;
63 class QWaylandSubSurfaceExtension;
64 class QWaylandOutputExtension;
65 class QWaylandTouchExtension;
66 class QWaylandQtKeyExtension;
68 class QWaylandDisplay : public QObject {
72 QWaylandDisplay(void);
73 ~QWaylandDisplay(void);
75 QList<QPlatformScreen *> screens() const { return mScreens; }
77 QWaylandScreen *screenForOutput(struct wl_output *output) const;
79 struct wl_surface *createSurface(void *handle);
81 #ifdef QT_WAYLAND_GL_SUPPORT
82 QWaylandGLIntegration *eglIntegration();
85 #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
86 QWaylandWindowManagerIntegration *windowManagerIntegration();
89 void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y);
91 struct wl_display *wl_display() const { return mDisplay; }
92 struct wl_compositor *wl_compositor() const { return mCompositor; }
94 QWaylandShell *shell() const { return mShell; }
96 QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; }
98 QWaylandInputDevice *lastKeyboardFocusInputDevice() const;
99 void setLastKeyboardFocusInputDevice(QWaylandInputDevice *device);
101 QWaylandDataDeviceManager *dndSelectionHandler() const { return mDndSelectionHandler; }
103 QWaylandSurfaceExtension *windowExtension() const { return mWindowExtension; }
104 QWaylandSubSurfaceExtension *subSurfaceExtension() const { return mSubSurfaceExtension; }
105 QWaylandOutputExtension *outputExtension() const { return mOutputExtension; }
106 QWaylandTouchExtension *touchExtension() const { return mTouchExtension; }
108 struct wl_shm *shm() const { return mShm; }
110 static uint32_t currentTimeMillisec();
112 void forceRoundTrip();
114 void createNewScreen(struct wl_output *output, QRect geometry);
116 void blockingReadEvents();
117 void flushRequests();
120 void waitForScreens();
121 void displayHandleGlobal(uint32_t id,
122 const QByteArray &interface,
125 struct wl_display *mDisplay;
126 struct wl_compositor *mCompositor;
128 QWaylandShell *mShell;
129 QList<QPlatformScreen *> mScreens;
130 QList<QWaylandInputDevice *> mInputDevices;
131 QWaylandInputDevice *mLastKeyboardFocusInputDevice;
132 QWaylandDataDeviceManager *mDndSelectionHandler;
133 QWaylandSurfaceExtension *mWindowExtension;
134 QWaylandSubSurfaceExtension *mSubSurfaceExtension;
135 QWaylandOutputExtension *mOutputExtension;
136 QWaylandTouchExtension *mTouchExtension;
137 QWaylandQtKeyExtension *mQtKeyExtension;
139 QSocketNotifier *mReadNotifier;
141 int mWritableNotificationFd;
142 bool mScreensInitialized;
144 static const struct wl_output_listener outputListener;
145 static void displayHandleGlobal(struct wl_display *display,
147 const char *interface,
148 uint32_t version, void *data);
149 static void outputHandleGeometry(void *data,
150 struct wl_output *output,
151 int32_t x, int32_t y,
152 int32_t width, int32_t height,
156 static void mode(void *data,
157 struct wl_output *wl_output,
163 #ifdef QT_WAYLAND_GL_SUPPORT
164 QWaylandGLIntegration *mEglIntegration;
167 #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
168 QWaylandWindowManagerIntegration *mWindowManagerIntegration;
171 static void shellHandleConfigure(void *data, struct wl_shell *shell,
172 uint32_t time, uint32_t edges,
173 struct wl_surface *surface,
174 int32_t width, int32_t height);
177 #endif // QWAYLANDDISPLAY_H