Qt 4.8
qwaylanddisplay.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
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.
16 **
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.
24 **
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.
28 **
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.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QWAYLANDDISPLAY_H
43 #define QWAYLANDDISPLAY_H
44 
45 #include <QtCore/QObject>
46 #include <QtCore/QRect>
47 
48 #include <QtCore/QWaitCondition>
49 
50 #include <wayland-client.h>
51 
53 class QSocketNotifier;
54 class QWaylandBuffer;
55 class QPlatformScreen;
56 class QWaylandScreen;
59 
60 class QWaylandDisplay : public QObject {
61  Q_OBJECT
62 
63 public:
64  QWaylandDisplay(void);
65  ~QWaylandDisplay(void);
66 
68  struct wl_surface *createSurface(void *handle);
69  struct wl_buffer *createShmBuffer(int fd, int width, int height,
70  uint32_t stride,
71  struct wl_visual *visual);
72  struct wl_visual *rgbVisual();
73  struct wl_visual *argbVisual();
74  struct wl_visual *argbPremultipliedVisual();
75 
76 #ifdef QT_WAYLAND_GL_SUPPORT
77  QWaylandGLIntegration *eglIntegration();
78 #endif
79 
80 #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
81  QWaylandWindowManagerIntegration *windowManagerIntegration();
82 #endif
83 
84  void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y);
85 
86  void syncCallback(wl_display_sync_func_t func, void *data);
87  void frameCallback(wl_display_frame_func_t func, struct wl_surface *surface, void *data);
88 
89  struct wl_display *wl_display() const { return mDisplay; }
90  struct wl_shell *wl_shell() const { return mShell; }
91 
93 
94 public slots:
95  void createNewScreen(struct wl_output *output, QRect geometry);
96  void readEvents();
97  void blockingReadEvents();
98  void flushRequests();
99 
100 private:
101  void waitForScreens();
102  void displayHandleGlobal(uint32_t id,
103  const QByteArray &interface,
104  uint32_t version);
105 
107  struct wl_compositor *mCompositor;
108  struct wl_shm *mShm;
109  struct wl_shell *mShell;
112 
114  int mFd;
116 
117  uint32_t mSocketMask;
118 
120 
121  static const struct wl_output_listener outputListener;
122  static const struct wl_compositor_listener compositorListener;
123  static int sourceUpdate(uint32_t mask, void *data);
124  static void displayHandleGlobal(struct wl_display *display,
125  uint32_t id,
126  const char *interface,
127  uint32_t version, void *data);
128  static void outputHandleGeometry(void *data,
129  struct wl_output *output,
130  int32_t x, int32_t y,
131  int32_t width, int32_t height,
132  int subpixel,
133  const char *make,
134  const char *model);
135  static void mode(void *data,
136  struct wl_output *wl_output,
137  uint32_t flags,
138  int width,
139  int height,
140  int refresh);
141 
142  static void handleVisual(void *data,
143  struct wl_compositor *compositor,
144  uint32_t id, uint32_t token);
145 #ifdef QT_WAYLAND_GL_SUPPORT
146  QWaylandGLIntegration *mEglIntegration;
147 #endif
148 
149 #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
150  QWaylandWindowManagerIntegration *mWindowManagerIntegration;
151 #endif
152 
153  static void shellHandleConfigure(void *data, struct wl_shell *shell,
154  uint32_t time, uint32_t edges,
155  struct wl_surface *surface,
156  int32_t width, int32_t height);
157 
158  static const struct wl_shell_listener shellListener;
159 };
160 
161 #endif // QWAYLANDDISPLAY_H
static void mode(void *data, struct wl_output *wl_output, uint32_t flags, int width, int height, int refresh)
static const struct wl_output_listener outputListener
void createNewScreen(struct wl_output *output, QRect geometry)
The QPlatformScreen class provides an abstraction for visual displays.
void displayHandleGlobal(uint32_t id, const QByteArray &interface, uint32_t version)
struct wl_shell * mShell
struct wl_visual * rgbVisual()
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static void handleVisual(void *data, struct wl_compositor *compositor, uint32_t id, uint32_t token)
struct wl_compositor * mCompositor
struct wl_visual * argbVisual()
static void outputHandleGeometry(void *data, struct wl_output *output, int32_t x, int32_t y, int32_t width, int32_t height, int subpixel, const char *make, const char *model)
QList< QPlatformScreen * > mScreens
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
static const struct wl_shell_listener shellListener
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
struct wl_visual * argbPremultipliedVisual()
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
void frameCallback(wl_display_frame_func_t func, struct wl_surface *surface, void *data)
void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y)
struct wl_surface * createSurface(void *handle)
QList< QWaylandInputDevice * > mInputDevices
static const char * data(const QByteArray &arr)
QList< QPlatformScreen * > screens() const
static int sourceUpdate(uint32_t mask, void *data)
#define Q_OBJECT
Definition: qobjectdefs.h:157
struct wl_shm * mShm
void syncCallback(wl_display_sync_func_t func, void *data)
struct wl_shell * wl_shell() const
struct wl_visual * argb_visual
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
struct wl_visual * premultiplied_argb_visual
static void shellHandleConfigure(void *data, struct wl_shell *shell, uint32_t time, uint32_t edges, struct wl_surface *surface, int32_t width, int32_t height)
QSocketNotifier * mReadNotifier
static const struct wl_compositor_listener compositorListener
#define slots
Definition: qobjectdefs.h:68
struct wl_display * mDisplay
QList< QWaylandInputDevice * > inputDevices() const
struct wl_buffer * createShmBuffer(int fd, int width, int height, uint32_t stride, struct wl_visual *visual)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
struct wl_display * wl_display() const
struct wl_visual * rgb_visual