1 From 1ddfa43692cabae0f552351cfbc09377e479471e Mon Sep 17 00:00:00 2001
2 From: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
3 Date: Mon, 8 Sep 2014 11:38:01 +0200
4 Subject: [PATCH 21/21] Implement initial IVI-Shell support
6 IVI-Shell provides a shell interface for Weston, which maps the GENIVI API (http://www.genivi.org) for In-Vehicle Infotainment.
8 This patch enables detecting the IVI-Shell interface at runtime, and creating compatible surfaces if found.
10 Task-number: QTBUG-XXXXX/part/2of2
12 Change-Id: I1f6c11bf56b727a54fb48faab9c076b61d635440
13 Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
15 src/client/client.pro | 5 ++
16 src/client/qwaylanddisplay.cpp | 9 ++++
17 src/client/qwaylanddisplay_p.h | 5 ++
18 src/client/qwaylandivishell.cpp | 69 +++++++++++++++++++++++++
19 src/client/qwaylandivishell_p.h | 70 +++++++++++++++++++++++++
20 src/client/qwaylandivisurface.cpp | 105 ++++++++++++++++++++++++++++++++++++++
21 src/client/qwaylandivisurface_p.h | 90 ++++++++++++++++++++++++++++++++
22 src/client/qwaylandwindow.cpp | 8 ++-
23 8 files changed, 360 insertions(+), 1 deletion(-)
24 create mode 100644 src/client/qwaylandivishell.cpp
25 create mode 100644 src/client/qwaylandivishell_p.h
26 create mode 100644 src/client/qwaylandivisurface.cpp
27 create mode 100644 src/client/qwaylandivisurface_p.h
29 diff --git a/src/client/client.pro b/src/client/client.pro
30 index 73e3b7f..adb526d 100644
31 --- a/src/client/client.pro
32 +++ b/src/client/client.pro
33 @@ -42,6 +42,7 @@ WAYLANDCLIENTSOURCES += \
34 ../extensions/windowmanager.xml \
35 ../3rdparty/protocol/text.xml \
36 ../3rdparty/protocol/xdg-shell.xml \
37 + ../3rdparty/protocol/ivi-application.xml \
39 SOURCES += qwaylandintegration.cpp \
40 qwaylandnativeinterface.cpp \
41 @@ -61,6 +62,8 @@ SOURCES += qwaylandintegration.cpp \
42 qwaylandwlshellsurface.cpp \
43 qwaylandxdgshell.cpp \
44 qwaylandxdgsurface.cpp \
45 + qwaylandivishell.cpp \
46 + qwaylandivisurface.cpp \
47 qwaylandextendedoutput.cpp \
48 qwaylandextendedsurface.cpp \
49 qwaylandsubsurface.cpp \
50 @@ -92,6 +95,8 @@ HEADERS += qwaylandintegration_p.h \
51 qwaylandwlshellsurface_p.h \
52 qwaylandxdgshell_p.h \
53 qwaylandxdgsurface_p.h \
54 + qwaylandivishell_p.h \
55 + qwaylandivisurface_p.h \
56 qwaylandextendedoutput_p.h \
57 qwaylandextendedsurface_p.h \
58 qwaylandsubsurface_p.h \
59 diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
60 index 2e25672..2a93db7 100644
61 --- a/src/client/qwaylanddisplay.cpp
62 +++ b/src/client/qwaylanddisplay.cpp
64 #include "qwaylanddatadevicemanager_p.h"
65 #include "qwaylandhardwareintegration_p.h"
66 #include "qwaylandxdgshell_p.h"
67 +#include "qwaylandivishell_p.h"
69 #include "qwaylandwindowmanagerintegration_p.h"
73 #include <QtWaylandClient/private/qwayland-text.h>
74 #include <QtWaylandClient/private/qwayland-xdg-shell.h>
75 +#include <QtWaylandClient/private/qwayland-ivi-application.h>
77 #include <QtCore/QAbstractEventDispatcher>
78 #include <QtGui/private/qguiapplication_p.h>
79 @@ -207,6 +209,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
80 mCompositor.init(registry, id);
81 } else if (interface == QStringLiteral("wl_shm")) {
82 mShm = static_cast<struct wl_shm *>(wl_registry_bind(registry, id, &wl_shm_interface,1));
83 + } else if (interface == QStringLiteral("ivi_application")) {
84 + mShellIvi.reset(new QWaylandIviShell(registry,id));
85 } else if (interface == QStringLiteral("xdg_shell")
86 && qEnvironmentVariableIsSet("QT_WAYLAND_USE_XDG_SHELL")) {
87 mShellXdg.reset(new QWaylandXdgShell(registry,id));
88 @@ -279,4 +283,9 @@ QtWayland::xdg_shell *QWaylandDisplay::shellXdg()
89 return mShellXdg.data();
92 +QtWayland::ivi_application *QWaylandDisplay::shellIvi()
94 + return mShellIvi.data();
98 diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h
99 index f1b35a7..b9c686c 100644
100 --- a/src/client/qwaylanddisplay_p.h
101 +++ b/src/client/qwaylanddisplay_p.h
103 #include <QtWaylandClient/private/qwayland-wayland.h>
104 #include <QtWaylandClient/private/qwaylandclientexport_p.h>
105 #include <QtWaylandClient/private/qwayland-xdg-shell.h>
106 +#include <QtWaylandClient/private/qwayland-ivi-application.h>
108 struct wl_cursor_image;
110 @@ -72,6 +73,7 @@ class QWaylandWindow;
111 class QWaylandEventThread;
112 class QWaylandIntegration;
113 class QWaylandHardwareIntegration;
114 +class QWaylandIviShell;
115 class QWaylandXdgShell;
117 namespace QtWayland {
118 @@ -81,6 +83,7 @@ namespace QtWayland {
119 class qt_surface_extension;
120 class wl_text_input_manager;
122 + class ivi_application;
125 typedef void (*RegistryListener)(void *data,
126 @@ -117,6 +120,7 @@ public:
128 QtWayland::wl_shell *shell() { return mShell.data(); }
129 QtWayland::xdg_shell *shellXdg();
130 + QtWayland::ivi_application *shellIvi();
132 QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; }
133 QWaylandInputDevice *defaultInputDevice() const;
134 @@ -173,6 +177,7 @@ private:
135 QWaylandEventThread *mEventThreadObject;
136 QScopedPointer<QtWayland::wl_shell> mShell;
137 QScopedPointer<QWaylandXdgShell> mShellXdg;
138 + QScopedPointer<QWaylandIviShell> mShellIvi;
139 QList<QPlatformScreen *> mScreens;
140 QList<QWaylandInputDevice *> mInputDevices;
141 QList<Listener> mRegistryListeners;
142 diff --git a/src/client/qwaylandivishell.cpp b/src/client/qwaylandivishell.cpp
144 index 0000000..9d63d0d
146 +++ b/src/client/qwaylandivishell.cpp
148 +/****************************************************************************
150 +** Copyright (C) 2014 Eurogiciel, author: <manuel.bachmann@open.eurogiciel.org>
151 +** Contact: http://www.qt-project.org/legal
153 +** This file is part of the config.tests of the Qt Toolkit.
155 +** $QT_BEGIN_LICENSE:LGPL$
156 +** Commercial License Usage
157 +** Licensees holding valid commercial Qt licenses may use this file in
158 +** accordance with the commercial license agreement provided with the
159 +** Software or, alternatively, in accordance with the terms contained in
160 +** a written agreement between you and Digia. For licensing terms and
161 +** conditions see http://qt.digia.com/licensing. For further information
162 +** use the contact form at http://qt.digia.com/contact-us.
164 +** GNU Lesser General Public License Usage
165 +** Alternatively, this file may be used under the terms of the GNU Lesser
166 +** General Public License version 2.1 as published by the Free Software
167 +** Foundation and appearing in the file LICENSE.LGPL included in the
168 +** packaging of this file. Please review the following information to
169 +** ensure the GNU Lesser General Public License version 2.1 requirements
170 +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
172 +** In addition, as a special exception, Digia gives you certain additional
173 +** rights. These rights are described in the Digia Qt LGPL Exception
174 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
176 +** GNU General Public License Usage
177 +** Alternatively, this file may be used under the terms of the GNU
178 +** General Public License version 3.0 as published by the Free Software
179 +** Foundation and appearing in the file LICENSE.GPL included in the
180 +** packaging of this file. Please review the following information to
181 +** ensure the GNU General Public License version 3.0 requirements will be
182 +** met: http://www.gnu.org/copyleft/gpl.html.
187 +****************************************************************************/
189 +#include "qwaylandivishell_p.h"
191 +#include "qwaylanddisplay_p.h"
192 +#include "qwaylandwindow_p.h"
193 +#include "qwaylandinputdevice_p.h"
194 +#include "qwaylanddecoration_p.h"
195 +#include "qwaylandscreen_p.h"
197 +#include <QtCore/QDebug>
201 +QWaylandIviShell::QWaylandIviShell(struct ::ivi_application *shell)
202 + : QtWayland::ivi_application(shell)
206 +QWaylandIviShell::QWaylandIviShell(struct ::wl_registry *registry, uint32_t id)
207 + : QtWayland::ivi_application(registry, id)
211 +QWaylandIviShell::~QWaylandIviShell()
213 + ivi_application_destroy(object());
217 diff --git a/src/client/qwaylandivishell_p.h b/src/client/qwaylandivishell_p.h
219 index 0000000..f9f6983
221 +++ b/src/client/qwaylandivishell_p.h
223 +/****************************************************************************
225 +** Copyright (C) 2014 Eurogiciel, author: <manuel.bachmann@open.eurogiciel.org>
226 +** Contact: http://www.qt-project.org/legal
228 +** This file is part of the config.tests of the Qt Toolkit.
230 +** $QT_BEGIN_LICENSE:LGPL$
231 +** Commercial License Usage
232 +** Licensees holding valid commercial Qt licenses may use this file in
233 +** accordance with the commercial license agreement provided with the
234 +** Software or, alternatively, in accordance with the terms contained in
235 +** a written agreement between you and Digia. For licensing terms and
236 +** conditions see http://qt.digia.com/licensing. For further information
237 +** use the contact form at http://qt.digia.com/contact-us.
239 +** GNU Lesser General Public License Usage
240 +** Alternatively, this file may be used under the terms of the GNU Lesser
241 +** General Public License version 2.1 as published by the Free Software
242 +** Foundation and appearing in the file LICENSE.LGPL included in the
243 +** packaging of this file. Please review the following information to
244 +** ensure the GNU Lesser General Public License version 2.1 requirements
245 +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
247 +** In addition, as a special exception, Digia gives you certain additional
248 +** rights. These rights are described in the Digia Qt LGPL Exception
249 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
251 +** GNU General Public License Usage
252 +** Alternatively, this file may be used under the terms of the GNU
253 +** General Public License version 3.0 as published by the Free Software
254 +** Foundation and appearing in the file LICENSE.GPL included in the
255 +** packaging of this file. Please review the following information to
256 +** ensure the GNU General Public License version 3.0 requirements will be
257 +** met: http://www.gnu.org/copyleft/gpl.html.
262 +****************************************************************************/
264 +#ifndef QWAYLANDIVISHELL_H
265 +#define QWAYLANDIVISHELL_H
267 +#include <QtCore/QSize>
269 +#include <wayland-client.h>
271 +#include <QtWaylandClient/private/qwayland-ivi-application.h>
272 +#include <QtWaylandClient/private/qwaylandclientexport_p.h>
273 +#include "qwaylandshellsurface_p.h"
277 +class QWaylandWindow;
278 +class QWaylandInputDevice;
281 +class Q_WAYLAND_CLIENT_EXPORT QWaylandIviShell : public QtWayland::ivi_application
284 + QWaylandIviShell(struct ::ivi_application *shell);
285 + QWaylandIviShell(struct ::wl_registry *registry, uint32_t id);
287 + virtual ~QWaylandIviShell();
292 +#endif // QWAYLANDIVISHELL_H
293 diff --git a/src/client/qwaylandivisurface.cpp b/src/client/qwaylandivisurface.cpp
295 index 0000000..a12309e
297 +++ b/src/client/qwaylandivisurface.cpp
299 +/****************************************************************************
301 +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
302 +** Contact: http://www.qt-project.org/legal
304 +** This file is part of the config.tests of the Qt Toolkit.
306 +** $QT_BEGIN_LICENSE:LGPL$
307 +** Commercial License Usage
308 +** Licensees holding valid commercial Qt licenses may use this file in
309 +** accordance with the commercial license agreement provided with the
310 +** Software or, alternatively, in accordance with the terms contained in
311 +** a written agreement between you and Digia. For licensing terms and
312 +** conditions see http://qt.digia.com/licensing. For further information
313 +** use the contact form at http://qt.digia.com/contact-us.
315 +** GNU Lesser General Public License Usage
316 +** Alternatively, this file may be used under the terms of the GNU Lesser
317 +** General Public License version 2.1 as published by the Free Software
318 +** Foundation and appearing in the file LICENSE.LGPL included in the
319 +** packaging of this file. Please review the following information to
320 +** ensure the GNU Lesser General Public License version 2.1 requirements
321 +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
323 +** In addition, as a special exception, Digia gives you certain additional
324 +** rights. These rights are described in the Digia Qt LGPL Exception
325 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
327 +** GNU General Public License Usage
328 +** Alternatively, this file may be used under the terms of the GNU
329 +** General Public License version 3.0 as published by the Free Software
330 +** Foundation and appearing in the file LICENSE.GPL included in the
331 +** packaging of this file. Please review the following information to
332 +** ensure the GNU General Public License version 3.0 requirements will be
333 +** met: http://www.gnu.org/copyleft/gpl.html.
338 +****************************************************************************/
340 +#include "qwaylandivisurface_p.h"
342 +#include "qwaylanddisplay_p.h"
343 +#include "qwaylandwindow_p.h"
344 +#include "qwaylandinputdevice_p.h"
345 +#include "qwaylanddecoration_p.h"
346 +#include "qwaylandscreen_p.h"
348 +#include <QtCore/QDebug>
352 +QWaylandIviSurface::QWaylandIviSurface(struct ::ivi_surface *ivi_surface, QWaylandWindow *window)
353 + : QtWayland::ivi_surface(ivi_surface)
358 +QWaylandIviSurface::~QWaylandIviSurface()
360 + ivi_surface_destroy(object());
363 +void QWaylandIviSurface::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
367 +void QWaylandIviSurface::move(QWaylandInputDevice *inputDevice)
371 +void QWaylandIviSurface::setMaximized()
375 +void QWaylandIviSurface::setFullscreen()
379 +void QWaylandIviSurface::setNormal()
383 +void QWaylandIviSurface::setMinimized()
387 +void QWaylandIviSurface::setTopLevel()
391 +void QWaylandIviSurface::updateTransientParent(QWindow *parent)
395 +void QWaylandIviSurface::setTitle(const QString & title)
399 +void QWaylandIviSurface::setAppId(const QString & appId)
404 diff --git a/src/client/qwaylandivisurface_p.h b/src/client/qwaylandivisurface_p.h
406 index 0000000..c6a7ce6
408 +++ b/src/client/qwaylandivisurface_p.h
410 +/****************************************************************************
412 +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
413 +** Contact: http://www.qt-project.org/legal
415 +** This file is part of the config.tests of the Qt Toolkit.
417 +** $QT_BEGIN_LICENSE:LGPL$
418 +** Commercial License Usage
419 +** Licensees holding valid commercial Qt licenses may use this file in
420 +** accordance with the commercial license agreement provided with the
421 +** Software or, alternatively, in accordance with the terms contained in
422 +** a written agreement between you and Digia. For licensing terms and
423 +** conditions see http://qt.digia.com/licensing. For further information
424 +** use the contact form at http://qt.digia.com/contact-us.
426 +** GNU Lesser General Public License Usage
427 +** Alternatively, this file may be used under the terms of the GNU Lesser
428 +** General Public License version 2.1 as published by the Free Software
429 +** Foundation and appearing in the file LICENSE.LGPL included in the
430 +** packaging of this file. Please review the following information to
431 +** ensure the GNU Lesser General Public License version 2.1 requirements
432 +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
434 +** In addition, as a special exception, Digia gives you certain additional
435 +** rights. These rights are described in the Digia Qt LGPL Exception
436 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
438 +** GNU General Public License Usage
439 +** Alternatively, this file may be used under the terms of the GNU
440 +** General Public License version 3.0 as published by the Free Software
441 +** Foundation and appearing in the file LICENSE.GPL included in the
442 +** packaging of this file. Please review the following information to
443 +** ensure the GNU General Public License version 3.0 requirements will be
444 +** met: http://www.gnu.org/copyleft/gpl.html.
449 +****************************************************************************/
451 +#ifndef QWAYLANDIVISURFACE_H
452 +#define QWAYLANDIVISURFACE_H
454 +#include <QtCore/QSize>
456 +#include <wayland-client.h>
458 +#include <QtWaylandClient/private/qwayland-ivi-application.h>
459 +#include <QtWaylandClient/private/qwaylandclientexport_p.h>
460 +#include "qwaylandshellsurface_p.h"
464 +class QWaylandWindow;
465 +class QWaylandInputDevice;
467 +class QWaylandExtendedSurface;
469 +class Q_WAYLAND_CLIENT_EXPORT QWaylandIviSurface : public QtWayland::ivi_surface
470 + , public QWaylandShellSurface
473 + QWaylandIviSurface(struct ::ivi_surface *shell_surface, QWaylandWindow *window);
474 + virtual ~QWaylandIviSurface();
476 + void resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges) Q_DECL_OVERRIDE;
477 + void move(QWaylandInputDevice *inputDevice) Q_DECL_OVERRIDE;
479 + void setTitle(const QString &title) Q_DECL_OVERRIDE;
480 + void setAppId(const QString &appId) Q_DECL_OVERRIDE;
483 + void setMaximized() Q_DECL_OVERRIDE;
484 + void setFullscreen() Q_DECL_OVERRIDE;
485 + void setNormal() Q_DECL_OVERRIDE;
486 + void setMinimized() Q_DECL_OVERRIDE;
488 + void setTopLevel() Q_DECL_OVERRIDE;
489 + void updateTransientParent(QWindow *parent) Q_DECL_OVERRIDE;
492 + QWaylandWindow *m_window;
494 + friend class QWaylandWindow;
499 +#endif // QWAYLANDIVISURFACE_H
500 diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
501 index 3fb3a49..45a58f2 100644
502 --- a/src/client/qwaylandwindow.cpp
503 +++ b/src/client/qwaylandwindow.cpp
506 ****************************************************************************/
510 #include "qwaylandwindow_p.h"
512 #include "qwaylandbuffer_p.h"
514 #include "qwaylandshellsurface_p.h"
515 #include "qwaylandwlshellsurface_p.h"
516 #include "qwaylandxdgsurface_p.h"
517 +#include "qwaylandivisurface_p.h"
518 #include "qwaylandextendedsurface_p.h"
519 #include "qwaylandsubsurface_p.h"
520 #include "qwaylanddecoration_p.h"
521 #include "qwaylandwindowmanagerintegration_p.h"
522 +#define IVI_SURFACE_ID 8000
524 #include <QtCore/QFileInfo>
525 #include <QtGui/QWindow>
526 @@ -95,7 +99,9 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
529 if (!(window->flags() & Qt::BypassWindowManagerHint)) {
530 - if (mDisplay->shellXdg()) {
531 + if (mDisplay->shellIvi()) {
532 + mShellSurface = new QWaylandIviSurface(mDisplay->shellIvi()->surface_create(IVI_SURFACE_ID + getpid(), object()), this);
533 + } else if (mDisplay->shellXdg()) {
534 if (window->type() & Qt::Window) {
535 mShellSurface = new QWaylandXdgSurface(mDisplay->shellXdg()->get_xdg_surface(object()), this);