8723def26c3e093580265410389c087d84326a48
[AGL/meta-agl-demo.git] / recipes-qt / qt / qtwayland / 0021-Implement-initial-IVI-Shell-support.patch
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
5
6 IVI-Shell provides a shell interface for Weston, which maps the GENIVI API (http://www.genivi.org) for In-Vehicle Infotainment.
7
8 This patch enables detecting the IVI-Shell interface at runtime, and creating compatible surfaces if found.
9
10 Task-number: QTBUG-XXXXX/part/2of2
11
12 Change-Id: I1f6c11bf56b727a54fb48faab9c076b61d635440
13 Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
14 ---
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
28
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 \
38  
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
63 @@ -51,6 +51,7 @@
64  #include "qwaylanddatadevicemanager_p.h"
65  #include "qwaylandhardwareintegration_p.h"
66  #include "qwaylandxdgshell_p.h"
67 +#include "qwaylandivishell_p.h"
68  
69  #include "qwaylandwindowmanagerintegration_p.h"
70  
71 @@ -62,6 +63,7 @@
72  
73  #include <QtWaylandClient/private/qwayland-text.h>
74  #include <QtWaylandClient/private/qwayland-xdg-shell.h>
75 +#include <QtWaylandClient/private/qwayland-ivi-application.h>
76  
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();
90  }
91  
92 +QtWayland::ivi_application *QWaylandDisplay::shellIvi()
93 +{
94 +    return mShellIvi.data();
95 +}
96 +
97  QT_END_NAMESPACE
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
102 @@ -52,6 +52,7 @@
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>
107  
108  struct wl_cursor_image;
109  
110 @@ -72,6 +73,7 @@ class QWaylandWindow;
111  class QWaylandEventThread;
112  class QWaylandIntegration;
113  class QWaylandHardwareIntegration;
114 +class QWaylandIviShell;
115  class QWaylandXdgShell;
116  
117  namespace QtWayland {
118 @@ -81,6 +83,7 @@ namespace QtWayland {
119      class qt_surface_extension;
120      class wl_text_input_manager;
121      class xdg_shell;
122 +    class ivi_application;
123  }
124  
125  typedef void (*RegistryListener)(void *data,
126 @@ -117,6 +120,7 @@ public:
127  
128      QtWayland::wl_shell *shell() { return mShell.data(); }
129      QtWayland::xdg_shell *shellXdg();
130 +    QtWayland::ivi_application *shellIvi();
131  
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
143 new file mode 100644
144 index 0000000..9d63d0d
145 --- /dev/null
146 +++ b/src/client/qwaylandivishell.cpp
147 @@ -0,0 +1,69 @@
148 +/****************************************************************************
149 +**
150 +** Copyright (C) 2014 Eurogiciel, author: <manuel.bachmann@open.eurogiciel.org>
151 +** Contact: http://www.qt-project.org/legal
152 +**
153 +** This file is part of the config.tests of the Qt Toolkit.
154 +**
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.
163 +**
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.
171 +**
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.
175 +**
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.
183 +**
184 +**
185 +** $QT_END_LICENSE$
186 +**
187 +****************************************************************************/
188 +
189 +#include "qwaylandivishell_p.h"
190 +
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"
196 +
197 +#include <QtCore/QDebug>
198 +
199 +QT_BEGIN_NAMESPACE
200 +
201 +QWaylandIviShell::QWaylandIviShell(struct ::ivi_application *shell)
202 +    : QtWayland::ivi_application(shell)
203 +{
204 +}
205 +
206 +QWaylandIviShell::QWaylandIviShell(struct ::wl_registry *registry, uint32_t id)
207 +    : QtWayland::ivi_application(registry, id)
208 +{
209 +}
210 +
211 +QWaylandIviShell::~QWaylandIviShell()
212 +{
213 +    ivi_application_destroy(object());
214 +}
215 +
216 +QT_END_NAMESPACE
217 diff --git a/src/client/qwaylandivishell_p.h b/src/client/qwaylandivishell_p.h
218 new file mode 100644
219 index 0000000..f9f6983
220 --- /dev/null
221 +++ b/src/client/qwaylandivishell_p.h
222 @@ -0,0 +1,70 @@
223 +/****************************************************************************
224 +**
225 +** Copyright (C) 2014 Eurogiciel, author: <manuel.bachmann@open.eurogiciel.org>
226 +** Contact: http://www.qt-project.org/legal
227 +**
228 +** This file is part of the config.tests of the Qt Toolkit.
229 +**
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.
238 +**
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.
246 +**
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.
250 +**
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.
258 +**
259 +**
260 +** $QT_END_LICENSE$
261 +**
262 +****************************************************************************/
263 +
264 +#ifndef QWAYLANDIVISHELL_H
265 +#define QWAYLANDIVISHELL_H
266 +
267 +#include <QtCore/QSize>
268 +
269 +#include <wayland-client.h>
270 +
271 +#include <QtWaylandClient/private/qwayland-ivi-application.h>
272 +#include <QtWaylandClient/private/qwaylandclientexport_p.h>
273 +#include "qwaylandshellsurface_p.h"
274 +
275 +QT_BEGIN_NAMESPACE
276 +
277 +class QWaylandWindow;
278 +class QWaylandInputDevice;
279 +class QWindow;
280 +
281 +class Q_WAYLAND_CLIENT_EXPORT QWaylandIviShell : public QtWayland::ivi_application
282 +{
283 +public:
284 +    QWaylandIviShell(struct ::ivi_application *shell);
285 +    QWaylandIviShell(struct ::wl_registry *registry, uint32_t id);
286 +
287 +    virtual ~QWaylandIviShell();
288 +};
289 +
290 +QT_END_NAMESPACE
291 +
292 +#endif // QWAYLANDIVISHELL_H
293 diff --git a/src/client/qwaylandivisurface.cpp b/src/client/qwaylandivisurface.cpp
294 new file mode 100644
295 index 0000000..a12309e
296 --- /dev/null
297 +++ b/src/client/qwaylandivisurface.cpp
298 @@ -0,0 +1,105 @@
299 +/****************************************************************************
300 +**
301 +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
302 +** Contact: http://www.qt-project.org/legal
303 +**
304 +** This file is part of the config.tests of the Qt Toolkit.
305 +**
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.
314 +**
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.
322 +**
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.
326 +**
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.
334 +**
335 +**
336 +** $QT_END_LICENSE$
337 +**
338 +****************************************************************************/
339 +
340 +#include "qwaylandivisurface_p.h"
341 +
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"
347 +
348 +#include <QtCore/QDebug>
349 +
350 +QT_BEGIN_NAMESPACE
351 +
352 +QWaylandIviSurface::QWaylandIviSurface(struct ::ivi_surface *ivi_surface, QWaylandWindow *window)
353 +    : QtWayland::ivi_surface(ivi_surface)
354 +    , m_window(window)
355 +{
356 +}
357 +
358 +QWaylandIviSurface::~QWaylandIviSurface()
359 +{
360 +    ivi_surface_destroy(object());
361 +}
362 +
363 +void QWaylandIviSurface::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
364 +{
365 +}
366 +
367 +void QWaylandIviSurface::move(QWaylandInputDevice *inputDevice)
368 +{
369 +}
370 +
371 +void QWaylandIviSurface::setMaximized()
372 +{
373 +}
374 +
375 +void QWaylandIviSurface::setFullscreen()
376 +{
377 +}
378 +
379 +void QWaylandIviSurface::setNormal()
380 +{
381 +}
382 +
383 +void QWaylandIviSurface::setMinimized()
384 +{
385 +}
386 +
387 +void QWaylandIviSurface::setTopLevel()
388 +{
389 +}
390 +
391 +void QWaylandIviSurface::updateTransientParent(QWindow *parent)
392 +{
393 +}
394 +
395 +void QWaylandIviSurface::setTitle(const QString & title)
396 +{
397 +}
398 +
399 +void QWaylandIviSurface::setAppId(const QString & appId)
400 +{
401 +}
402 +
403 +QT_END_NAMESPACE
404 diff --git a/src/client/qwaylandivisurface_p.h b/src/client/qwaylandivisurface_p.h
405 new file mode 100644
406 index 0000000..c6a7ce6
407 --- /dev/null
408 +++ b/src/client/qwaylandivisurface_p.h
409 @@ -0,0 +1,90 @@
410 +/****************************************************************************
411 +**
412 +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
413 +** Contact: http://www.qt-project.org/legal
414 +**
415 +** This file is part of the config.tests of the Qt Toolkit.
416 +**
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.
425 +**
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.
433 +**
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.
437 +**
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.
445 +**
446 +**
447 +** $QT_END_LICENSE$
448 +**
449 +****************************************************************************/
450 +
451 +#ifndef QWAYLANDIVISURFACE_H
452 +#define QWAYLANDIVISURFACE_H
453 +
454 +#include <QtCore/QSize>
455 +
456 +#include <wayland-client.h>
457 +
458 +#include <QtWaylandClient/private/qwayland-ivi-application.h>
459 +#include <QtWaylandClient/private/qwaylandclientexport_p.h>
460 +#include "qwaylandshellsurface_p.h"
461 +
462 +QT_BEGIN_NAMESPACE
463 +
464 +class QWaylandWindow;
465 +class QWaylandInputDevice;
466 +class QWindow;
467 +class QWaylandExtendedSurface;
468 +
469 +class Q_WAYLAND_CLIENT_EXPORT QWaylandIviSurface : public QtWayland::ivi_surface
470 +        , public QWaylandShellSurface
471 +{
472 +public:
473 +    QWaylandIviSurface(struct ::ivi_surface *shell_surface, QWaylandWindow *window);
474 +    virtual ~QWaylandIviSurface();
475 +
476 +    void resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges) Q_DECL_OVERRIDE;
477 +    void move(QWaylandInputDevice *inputDevice) Q_DECL_OVERRIDE;
478 +
479 +    void setTitle(const QString &title) Q_DECL_OVERRIDE;
480 +    void setAppId(const QString &appId) Q_DECL_OVERRIDE;
481 +
482 +private:
483 +    void setMaximized() Q_DECL_OVERRIDE;
484 +    void setFullscreen() Q_DECL_OVERRIDE;
485 +    void setNormal() Q_DECL_OVERRIDE;
486 +    void setMinimized() Q_DECL_OVERRIDE;
487 +
488 +    void setTopLevel() Q_DECL_OVERRIDE;
489 +    void updateTransientParent(QWindow *parent) Q_DECL_OVERRIDE;
490 +
491 +private:
492 +    QWaylandWindow *m_window;
493 +
494 +    friend class QWaylandWindow;
495 +};
496 +
497 +QT_END_NAMESPACE
498 +
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
504 @@ -39,6 +39,8 @@
505  **
506  ****************************************************************************/
507  
508 +#include <unistd.h>
509 +
510  #include "qwaylandwindow_p.h"
511  
512  #include "qwaylandbuffer_p.h"
513 @@ -48,10 +50,12 @@
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
523  
524  #include <QtCore/QFileInfo>
525  #include <QtGui/QWindow>
526 @@ -95,7 +99,9 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
527      mWindowId = id++;
528  
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);
536              }
537 -- 
538 1.9.1
539