~gerboland/qtubuntu/fix_1351024

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
  1. Description
  2. Running
  3. Building
  4. Native interface
  5. Properties


1. Description
--------------

  QtHybris is a Qt Platform Abstraction (QPA) plugin for Qt5 based on
  libhybris and the Ubuntu Application API. It also contains a legacy
  plugin based on libhybris and the compatibility layers.


2 Running
---------

  Considering the QPA plugin path is correctly set using either the
  QT_QPA_PLATFORM_PLUGIN_PATH environment variable or the
  "-platformpluginpath" command line switch, the following commands
  can be used to run with the Hybris plugin:

    $ qmlscene -platform hybris Foo.qml
    $ QT_QPA_PLATFORM=hybris qmlscene Foo.qml

  and the following ones to run with the Hybris legacy plugin:

    $ qmlscene -platform hybrislegacy Foo.qml
    $ QT_QPA_PLATFORM=hybrislegacy qmlscene Foo.qml

  The plugins expose the following environment variables:

    QTHYBRIS_SWAPINTERVAL: Specifies the required swap interval as an
                           integer. 1 by default.

    QTHYBRIS_MULTISAMPLE: Enables multisampling with using 4 samples
                          per fragment.

    QTHYBRIS_NO_THREADED_OPENGL: Disables QtQuick threaded OpenGL
                                 rendering.

    QTHYBRIS_NO_INPUT: Disables touchscreen and buttons.

    QTHYBRIS_INPUT_DELAY: Specifies a delay in milliseconds for input
                          initialization (hybrislegacy plugin only).


3. Building
-----------

  Here is the process to follow in order to cross-compile the project
  and deploy it to the phone. First, install PBuilder on the chroot
  host:

    $ sudo apt-get install pbuilder

  Get the pbuilder-scripts Ubuntu package hosted on Chinstrap
  (https://chinstrap.canonical.com/~mfrey/newyork/pbuilder-scripts_14_all.deb),
  and install it:

    $ sudo dpkg -i pbuilder-scripts_14_all.deb

  Create the chroot:

    $ pcreate -a armel -d quantal -e "vim apt-transport-https ca-certificates libgles2-mesa-dev libegl1-mesa-dev libudev-dev libfontconfig1-dev libfreetype6-dev libglib2.0-dev" armel-quantal

  Skip the sources.list entry edition pressing "ZZ", then login the
  chroot using the save command:

    $ ptest --save armel-quantal

  Add Manhattan repositories to Apt. See the wiki for the credentials
  (https://wiki.canonical.com/PES/Infrastructure/Repository/CustomerMirrors).

    $ echo "deb https://USER:PASSWORD@cesg.canonical.com/canonical manhattan-quantal-devel public private" >> /etc/apt/sources.list
    $ echo "deb-src https://USER:PASSWORD@cesg.canonical.com/canonical manhattan-quantal-devel public private" >> /etc/apt/sources.list
    $ apt-get update

  Then install Qt5 and the libhybris development files:

    $ apt-get install -y qtdeclarative libhybris-dev

  Exit the chroot saving the current session:

    $ exit

  Files created inside the chroot will be deleted once logging out. In
  order to write files to a filesystem on the chroot host, edit
  .pbuilderrc in your home directory and add the filesystem, for
  example "/media/data", using the BINDMOUNTS option.

    $ echo "BINDMOUNTS=\"/media/data\"" >> ~/.pbuilderrc

  Log back to the chroot and set up some environment variables to use
  the right Qt5 paths:

    $ ptest armel-quantal
    $ export PATH=/opt/qt5/bin${PATH:+:$PATH}
    $ export LD_LIBRARY_PATH=/opt/qt5/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}

  The build environment is now ready. In order to compile QtHybris, go
  to the file system set up earlier, generate the makefiles and build:

    $ cd /media/data/qthybris
    $ qmake
    $ make

  By default, QtHybris compiles a release build. To compile a debug
  build, the following command can be used:

    $ qmake "CONFIG+=debug" && make

  To deploy on the phone, open a new shell outside the chroot and push
  the files to the phone using adb (in the android-tools-adb Quantal
  package). The deploy.sh script at the root directory is meant to do
  that:

    $ ./deploy.sh


4. Native interface
-------------------

  The QPA plugin exposes a native interface allowing to retrieve
  native handles and to filter out native events. In order to retrieve
  native handles, the following code can be used:

    #include <QtGui/QGuiApplication>
    #include <qpa/qplatformnativeinterface.h>
    ...
    QQuickView* view = new QQuickView();
    ...
    QPlatformNativeInterface* native = QGuiApplication::platformNativeInterface();
    printf("app: eglcontext=%p egldisplay=%p\n",
           native->nativeResourceForContext("eglcontext", view->openglContext()),
           native->nativeResourceForWindow("egldisplay", view));

  Note that handles aren't valid until the application mainloop is started. The
  qmake .pro needs to add private gui include directories using

    QT += gui-private

  Some events exposed in the input compatibility layer can't be
  directly mapped to Qt. In order to retrieve such events, a native
  event filter needs to be installed. To do so, a
  QAbstractNativeEventFilter [1] filtering out "Event" events needs to
  be implemented and installed using
  QCoreApplication::installNativeEventFilter [2].

  [1] http://doc-snapshot.qt-project.org/5.0/qabstractnativeeventfilter.html
  [2] http://doc-snapshot.qt-project.org/5.0/qcoreapplication.html#installNativeEventFilter


5. Properties
-------------

  The QPA plugin for Hybris looks for a specific property named
  "UbuntuSurfaceRole" on the QWindow object in order to know the type
  of surface role to request. That property can be set to an integer
  representing the value of a SurfaceRole enumeration specified in the
  Ubuntu Application API. In order to request a tool support role, the
  following code can be used:

  QQuickView* view = new QQuickView();
  view->setProperty("UbuntuSurfaceRole", static_cast<int>(TOOL_SUPPORT_ACTOR_ROLE));
  ...