summaryrefslogtreecommitdiff
path: root/qt5.html
blob: 921fa8a5f0cc7cdda8456b72ef1459bc0bd1d9bc (plain)
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link href="wayland.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="generated-toc.js"></script>
<title>Qt 5 on Wayland</title>
</head>

<body>
<h1><a href="/"><img src="wayland.png" alt="Wayland logo"></a></h1>
<h1>Qt 5 on Wayland</h1>
<p>Wayland support in the Qt 5 toolkit is happening in the Qt Platform Abstraction (QPA)
<a href="https://code.qt.io/cgit/qt/qtwayland.git/">Wayland plugin</a>.
The minimum requirement for building and using QtWayland is Wayland (and
Weston) 1.0.0.</p>

<p>If you also want to build the qtwebkit
browser, you may be better off following the <a
href="https://wiki.qt.io/Building_Qt_5_from_Git">directions for
building Qt 5 from git</a>, which builds a lot more.  The init-repository
script does <i>not</i> appropriately return an error when it fails
(unfortunately frequently), so you need to run it manually and make sure
it doesn't print an error.</p>

<p>The third option is the <a
href="https://wiki.qt.io/Qt-5-Alpha-building-instructions">Qt 5
Alpha building instructions</a>, which is smaller and more reliable than
the git instructions while still including qtwebkit, but which requires
an LD_PRELOAD for Wayland clients:<br>
<tt>$ LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libfontconfig.so.1
./fancybrowser -platform wayland</tt></p>

<div id="generated-toc" class="generate_from_h2"></div>

<h2>Getting the source and compiling</h2>

<p>To try it out, first clone the qtbase:</p>

<pre>
$ mkdir qt; cd qt
$ git clone git://code.qt.io/qt/qtbase.git
</pre>

<p>You might want to set some env variables for compilation as well:</p>

<pre>
$ export QTVER=qt5
$ export QTDIR=/opt/qt/$QTVER
$ export PATH=$QTDIR/bin/:$PATH
$ export LD_LIBRARY_PATH=$QTDIR/lib/:$LD_LIBRARY_PATH
$ export PKG_CONFIG_PATH=$QTDIR/lib/pkgconfig/:$PKG_CONFIG_PATH
$ export QT_PLUGIN_PATH=$QTDIR/lib/plugins/
</pre>
<pre>
$ ./configure -confirm-license -opensource -debug -nomake examples \
   -nomake tests -nomake demos -make libs --prefix ${QTDIR}
$ make
$ sudo make install
</pre>

<p>Here you need to also clone and build qtdeclarative:</p>
<pre>
git://code.qt.io/qt/qtdeclarative.git
</pre>

<p>To build them run these commands:</p>
<pre>
$ qmake
$ make
$ sudo make install
</pre>

<p>At this point you have all needed Qt libraries and needed tools to compile
the QtWayland platform:</p>

<pre>
$ cd ../
$ git clone git://code.qt.io/qt/qtwayland.git
$ cd qtwayland/
$ qmake
$ make
$ sudo make install
</pre>

<h2>Trying it out</h2>
<p>First, don't forget to set the XDG directory, as well as the variables set
before for compiling Qt, and re-run .bashrc:</p>

<pre>
$ export XDG_RUNTIME_DIR=$HOME/.xdg
$ mkdir $HOME/.xdg
</pre>

<p>
You can jump back and forth between Wayland and X ("-platform xcb") to compare the look and feel
of the application under Wayland and X:</p>

<pre>
$ cd ../qtbase/examples/opengl/hellowindow
$ qmake
$ make
$ weston &amp;
$ ./hellowindow -platform wayland
</pre>

<h2>Porting your Qt application</h2>

<p>
Qt 5 is structured with the Lighthouse (or Qt Platform) Abstraction, which is
the windowing system and device agnostic architecture. That means Qt can load
in run-time different backend plugins for different window systems as desired.
For instance, an application developed on Qt could be run using "-platform
xcb" and "-platform wayland" for XCB or Wayland respectively (or set
the <code>QT_QPA_PLATFORM</code> environment variable) and should have a
similar behavior on both systems, without the need to recompile.
</p>

<p>
Qt abstraction exposes to applications developers two native resources of
Wayland: <code>wl_display</code> and <code>wl_surface</code>. With those types, one could access
Wayland internals to deal with special cases through the interface:
</p>
<pre>
    void *QPlatformNativeInterface::nativeResourceForWindow(const QByteArray &amp;resource, QWindow *window)
</pre>
<p>
Getting the display global handler is quite straightforward, as shown in the
following example:
</p>

<pre>
    QPlatformNativeInterface *native =
        QGuiApplication::platformNativeInterface();
    struct wl_display *wl_dpy = (struct wl_display *)
        native-&gt;nativeResourceForWindow("display", NULL);
</pre>
<p>
and for <code>wl_surface</code>:
</p>

<pre>
    QPlatformNativeInterface *native =
        QGuiApplication::platformNativeInterface();
    struct wl_surface *surface = static_cast&lt;struct wl_surface *&gt;(
        native-&gt;nativeResourceForWindow("surface", this-&gt;windowHandle()));
</pre>


<h2>Known issues</h2>
<ul>
  <li>
    See the <a href="https://bugreports.qt.io/browse/QTBUG/component/19921/?selectedTab=com.atlassian.jira.jira-projects-plugin:component-summary-panel">Qt bug tracker</a>
    for a list of QtWayland bugs.
  </li>
</ul>

<h2>Getting help and reporting issues</h2>

<p>Try the #qt-labs IRC channel on irc.freenode.net</p>

</body>
</html>