1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the plugins of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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(wl_surface *surface, 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,
157 static void mode(void *data,
158 struct wl_output *wl_output,
164 #ifdef QT_WAYLAND_GL_SUPPORT
165 QWaylandGLIntegration *mEglIntegration;
168 #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
169 QWaylandWindowManagerIntegration *mWindowManagerIntegration;
172 static void shellHandleConfigure(void *data, struct wl_shell *shell,
173 uint32_t time, uint32_t edges,
174 struct wl_surface *surface,
175 int32_t width, int32_t height);
178 #endif // QWAYLANDDISPLAY_H