8f0425a769bf4ce9b97a530f2bbe49ba59ec3d21
[AGL/meta-agl-demo.git] / recipes-qt / qt5 / qtwayland / 0019-xdg-shell-upgrade-to-support-current-version-weston-.patch
1 From c4219cca0febd7119e0bec776fdc2877b3448e0b Mon Sep 17 00:00:00 2001
2 From: Philippe Coval <philippe.coval@open.eurogiciel.org>
3 Date: Tue, 10 Jun 2014 16:22:17 +0200
4 Subject: [PATCH 19/21] xdg-shell: upgrade to support current version
5  (weston-1.5.0)
6
7 The protocol file is a raw copy of
8
9 Source: http://cgit.freedesktop.org/wayland/weston/plain/protocol/xdg-shell.xml?id=1.5.0
10
11 Task-number: QTBUG-38633/related
12 Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
13 Reviewed-by: Philippe Coval <rzr@gna.org>
14 Origin: https://www.qt.gitorious.org/qt/qtwayland/commit/4bac130b97fbaa565aa9883eb302557ef0185d50
15 Change-Id: I41ca2f89c09a8b6348ce2fbf6d59f44b4c81ffff
16 ---
17  src/3rdparty/protocol/xdg-shell.xml | 288 ++++++++++++++++++------------------
18  src/client/client.pro               |   2 +
19  src/client/qwaylanddisplay.cpp      |  10 +-
20  src/client/qwaylanddisplay_p.h      |   5 +-
21  src/client/qwaylandxdgshell.cpp     |  77 ++++++++++
22  src/client/qwaylandxdgshell_p.h     |  73 +++++++++
23  src/client/qwaylandxdgsurface.cpp   |  60 ++++++--
24  src/client/qwaylandxdgsurface_p.h   |  11 +-
25  8 files changed, 364 insertions(+), 162 deletions(-)
26  create mode 100644 src/client/qwaylandxdgshell.cpp
27  create mode 100644 src/client/qwaylandxdgshell_p.h
28
29 diff --git a/src/3rdparty/protocol/xdg-shell.xml b/src/3rdparty/protocol/xdg-shell.xml
30 index 4e5cff8..79a2831 100644
31 --- a/src/3rdparty/protocol/xdg-shell.xml
32 +++ b/src/3rdparty/protocol/xdg-shell.xml
33 @@ -40,19 +40,22 @@
34  
35      <enum name="version">
36        <description summary="latest protocol version">
37 -       Use this enum to check the protocol version, and it will be updated
38 -       automatically.
39 +       The 'current' member of this enum gives the version of the
40 +       protocol.  Implementations can compare this to the version
41 +       they implement using static_assert to ensure the protocol and
42 +       implementation versions match.
43        </description>
44 -      <entry name="current" value="1" summary="Always the latest version"/>
45 +      <entry name="current" value="3" summary="Always the latest version"/>
46      </enum>
47  
48  
49      <request name="use_unstable_version">
50        <description summary="enable use of this unstable version">
51 -       Use this request in order to enable use of this interface.
52 -
53 -       Understand and agree that one is using an unstable interface,
54 -       that will likely change in the future, breaking the API.
55 +       Negotiate the unstable version of the interface.  This
56 +       mechanism is in place to ensure client and server agree on the
57 +       unstable versions of the protocol that they speak or exit
58 +       cleanly if they don't agree.  This request will go away once
59 +       the xdg-shell protocol is stable.
60        </description>
61        <arg name="version" type="int"/>
62      </request>
63 @@ -84,6 +87,28 @@
64        <arg name="y" type="int"/>
65        <arg name="flags" type="uint"/>
66      </request>
67 +
68 +    <event name="ping">
69 +      <description summary="check if the client is alive">
70 +        The ping event asks the client if it's still alive. Pass the
71 +        serial specified in the event back to the compositor by sending
72 +        a "pong" request back with the specified serial.
73 +
74 +        Compositors can use this to determine if the client is still
75 +        alive. It's unspecified what will happen if the client doesn't
76 +        respond to the ping request, or in what timeframe. Clients should
77 +        try to respond in a reasonable amount of time.
78 +      </description>
79 +      <arg name="serial" type="uint" summary="pass this to the callback"/>
80 +    </event>
81 +
82 +    <request name="pong">
83 +      <description summary="respond to a ping event">
84 +       A client must respond to a ping event with a pong request or
85 +       the client may be deemed unresponsive.
86 +      </description>
87 +      <arg name="serial" type="uint" summary="serial of the ping event"/>
88 +    </request>
89    </interface>
90  
91    <interface name="xdg_surface" version="1">
92 @@ -124,6 +149,32 @@
93        <arg name="parent" type="object" interface="wl_surface" allow-null="true"/>
94      </request>
95  
96 +    <request name="set_margin">
97 +      <description summary="set the visible frame boundaries">
98 +        This tells the compositor what the visible size of the window
99 +        should be, so it can use it to determine what borders to use for
100 +        constrainment and alignment.
101 +
102 +        CSD often has invisible areas for decoration purposes, like drop
103 +        shadows. These "shadow" drawings need to be subtracted out of the
104 +        normal boundaries of the window when computing where to place
105 +        windows (e.g. to set this window so it's centered on top of another,
106 +        or to put it to the left or right of the screen.)
107 +
108 +        This value should change as little as possible at runtime, to
109 +        prevent flicker.
110 +
111 +        This value is also ignored when the window is maximized or
112 +        fullscreen, and assumed to be 0.
113 +
114 +        If never called, this value is assumed to be 0.
115 +      </description>
116 +      <arg name="left_margin" type="int"/>
117 +      <arg name="right_margin" type="int"/>
118 +      <arg name="top_margin" type="int"/>
119 +      <arg name="bottom_margin" type="int"/>
120 +    </request>
121 +
122      <request name="set_title">
123        <description summary="set surface title">
124         Set a short title for the surface.
125 @@ -150,22 +201,6 @@
126        <arg name="app_id" type="string"/>
127      </request>
128  
129 -    <request name="pong">
130 -      <description summary="respond to a ping event">
131 -       A client must respond to a ping event with a pong request or
132 -       the client may be deemed unresponsive.
133 -      </description>
134 -      <arg name="serial" type="uint" summary="serial of the ping event"/>
135 -    </request>
136 -
137 -    <event name="ping">
138 -      <description summary="ping client">
139 -       Ping a client to check if it is receiving events and sending
140 -       requests. A client is expected to reply with a pong request.
141 -      </description>
142 -      <arg name="serial" type="uint"/>
143 -    </event>
144 -
145      <request name="move">
146        <description summary="start an interactive move">
147         Start a pointer-driven move of the surface.
148 @@ -217,12 +252,6 @@
149         ignore it if it doesn't resize, pick a smaller size (to
150         satisfy aspect ratio or resize in steps of NxM pixels).
151  
152 -       The edges parameter provides a hint about how the surface
153 -       was resized. The client may use this information to decide
154 -       how to adjust its content to the new size (e.g. a scrolling
155 -       area might adjust its content position to leave the viewable
156 -       content unmoved). Valid edge values are from resize_edge enum.
157 -
158         The client is free to dismiss all but the last configure
159         event it received.
160  
161 @@ -230,7 +259,6 @@
162         in surface local coordinates.
163        </description>
164  
165 -      <arg name="edges" type="uint"/>
166        <arg name="width" type="int"/>
167        <arg name="height" type="int"/>
168      </event>
169 @@ -250,128 +278,122 @@
170        <arg name="output" type="object" interface="wl_output" allow-null="true"/>
171      </request>
172  
173 -    <event name="request_set_fullscreen">
174 -      <description summary="server requests that the client set fullscreen">
175 -       Event sent from the compositor to the client requesting that the client
176 -       goes to a fullscreen state. It's the client job to call set_fullscreen
177 -       and really trigger the fullscreen state.
178 -      </description>
179 -    </event>
180 -
181 -    <event name="request_unset_fullscreen">
182 -      <description summary="server requests that the client unset fullscreen">
183 -       Event sent from the compositor to the client requesting that the client
184 -       leaves the fullscreen state. It's the client job to call
185 -       unset_fullscreen and really leave the fullscreen state.
186 -      </description>
187 -    </event>
188 +    <enum name="state">
189 +      <description summary="types of state on the surface">
190 +        The different state values used on the surface. This is designed for
191 +        state values like maximized, fullscreen. It is paired with the
192 +        request_change_state event to ensure that both the client and the
193 +        compositor setting the state can be synchronized.
194  
195 -    <request name="set_fullscreen">
196 -      <description summary="set the surface state as fullscreen">
197 -       Set the surface as fullscreen.
198 +        States set in this way are double-buffered. They will get applied on
199 +        the next commit.
200  
201 -       After this request, the compositor should send a configure event
202 -       informing the output size.
203 +        Desktop environments may extend this enum by taking up a range of
204 +        values and documenting the range they chose in this description.
205 +        They are not required to document the values for the range that they
206 +        chose. Ideally, any good extensions from a desktop environment should
207 +        make its way into standardization into this enum.
208  
209 -       This request informs the compositor that the next attached buffer
210 -       committed will be in a fullscreen state. The buffer size should be the
211 -       same size as the size informed in the configure event, if the client
212 -       doesn't want to leave any empty area.
213 +        The current reserved ranges are:
214  
215 -       In other words: the next attached buffer after set_maximized is the new
216 -       maximized buffer. And the surface will be positioned at the maximized
217 -       position on commit.
218 -
219 -       A simple way to synchronize and wait for the correct configure event is
220 -       to use a wl_display.sync request right after the set_fullscreen
221 -       request. When the sync callback returns, the last configure event
222 -       received just before it will be the correct one, and should contain the
223 -       right size for the surface to maximize.
224 -
225 -       Setting one state won't unset another state. Use
226 -       xdg_surface.unset_fullscreen for unsetting it.
227 +        0x0000 - 0x0FFF: xdg-shell core values, documented below.
228 +        0x1000 - 0x1FFF: GNOME
229        </description>
230 -    </request>
231 +      <entry name="maximized" value="1" summary="the surface is maximized">
232 +        A non-zero value indicates the surface is maximized. Otherwise,
233 +        the surface is unmaximized.
234 +      </entry>
235 +      <entry name="fullscreen" value="2" summary="the surface is fullscreen">
236 +        A non-zero value indicates the surface is fullscreen. Otherwise,
237 +        the surface is not fullscreen.
238 +      </entry>
239 +    </enum>
240  
241 -    <request name="unset_fullscreen">
242 -      <description summary="unset the surface state as fullscreen">
243 -       Unset the surface fullscreen state.
244 +    <request name="request_change_state">
245 +      <description summary="client requests to change a surface's state">
246 +        This asks the compositor to change the state. If the compositor wants
247 +        to change the state, it will send a change_state event with the same
248 +        state_type, value, and serial, and the event flow continues as if it
249 +        it was initiated by the compositor.
250  
251 -       Same negotiation as set_fullscreen must be used.
252 +        If the compositor does not want to change the state, it will send a
253 +        change_state to the client with the old value of the state.
254        </description>
255 +      <arg name="state_type" type="uint" summary="the state to set"/>
256 +      <arg name="value" type="uint" summary="the value to change the state to"/>
257 +      <arg name="serial" type="uint" summary="an event serial">
258 +        This serial is so the client can know which change_state event corresponds
259 +        to which request_change_state request it sent out.
260 +      </arg>
261      </request>
262  
263 -    <event name="request_set_maximized">
264 -      <description summary="server requests that the client set maximized">
265 -       Event sent from the compositor to the client requesting that the client
266 -       goes to a maximized state. It's the client job to call set_maximized
267 -       and really trigger the maximized state.
268 +    <event name="change_state">
269 +      <description summary="compositor wants to change a surface's state">
270 +        This event tells the client to change a surface's state. The client
271 +        should respond with an ack_change_state request to the compositor to
272 +        guarantee that the compositor knows that the client has seen it.
273        </description>
274 -    </event>
275  
276 -    <event name="request_unset_maximized">
277 -      <description summary="server requests that the client unset maximized">
278 -       Event sent from the compositor to the client requesting that the client
279 -       leaves the maximized state. It's the client job to call unset_maximized
280 -       and really leave the maximized state.
281 -      </description>
282 +      <arg name="state_type" type="uint" summary="the state to set"/>
283 +      <arg name="value" type="uint" summary="the value to change the state to"/>
284 +      <arg name="serial" type="uint" summary="a serial for the compositor's own tracking"/>
285      </event>
286  
287 -    <request name="set_maximized">
288 -      <description summary="set the surface state as maximized">
289 -       Set the surface as maximized.
290 -
291 -       After this request, the compositor will send a configure event
292 -       informing the output size minus panel and other MW decorations.
293 -
294 -       This request informs the compositor that the next attached buffer
295 -       committed will be in a maximized state. The buffer size should be the
296 -       same size as the size informed in the configure event, if the client
297 -       doesn't want to leave any empty area.
298 +    <request name="ack_change_state">
299 +      <description summary="ack a change_state event">
300 +        When a change_state event is received, a client should then ack it
301 +        using the ack_change_state request to ensure that the compositor
302 +        knows the client has seen the event.
303  
304 -       In other words: the next attached buffer after set_maximized is the new
305 -       maximized buffer. And the surface will be positioned at the maximized
306 -       position on commit.
307 +        By this point, the state is confirmed, and the next attach should
308 +        contain the buffer drawn for the new state value.
309  
310 -       A simple way to synchronize and wait for the correct configure event is
311 -       to use a wl_display.sync request right after the set_maximized request.
312 -       When the sync callback returns, the last configure event received just
313 -       before it will be the correct one, and should contain the right size
314 -       for the surface to maximize.
315 -
316 -       Setting one state won't unset another state. Use
317 -       xdg_surface.unset_maximized for unsetting it.
318 +        The values here need to be the same as the values in the cooresponding
319 +        change_state event.
320        </description>
321 +      <arg name="state_type" type="uint" summary="the state to set"/>
322 +      <arg name="value" type="uint" summary="the value to change the state to"/>
323 +      <arg name="serial" type="uint" summary="a serial to pass to change_state"/>
324      </request>
325  
326 -    <request name="unset_maximized">
327 -      <description summary="unset the surface state as maximized">
328 -       Unset the surface maximized state.
329 -
330 -       Same negotiation as set_maximized must be used.
331 +    <request name="set_minimized">
332 +      <description summary="minimize the surface">
333 +        Minimize the surface.
334        </description>
335      </request>
336  
337 -    <request name="set_minimized">
338 -      <description summary="set the surface state as minimized">
339 -       Set the surface minimized state.
340 -
341 -       Setting one state won't unset another state.
342 +    <event name="activated">
343 +      <description summary="surface was activated">
344 +       The activated_set event is sent when this surface has been
345 +       activated, which means that the surface has user attention.
346 +        Window decorations should be updated accordingly. You should
347 +        not use this event for anything but the style of decorations
348 +        you display, use wl_keyboard.enter and wl_keyboard.leave for
349 +        determining keyboard focus.
350        </description>
351 -    </request>
352 +    </event>
353  
354 -    <event name="focused_set">
355 -      <description summary="surface was focused">
356 -       The focused_set event is sent when this surface has been
357 -       activated. Window decorations should be updated accordingly.
358 +    <event name="deactivated">
359 +      <description summary="surface was deactivated">
360 +       The deactivate event is sent when this surface has been
361 +        deactivated, which means that the surface lost user attention.
362 +        Window decorations should be updated accordingly. You should
363 +        not use this event for anything but the style of decorations
364 +        you display, use wl_keyboard.enter and wl_keyboard.leave for
365 +        determining keyboard focus.
366        </description>
367      </event>
368  
369 -    <event name="focused_unset">
370 -      <description summary="surface was unfocused">
371 -       The focused_unset event is sent when this surface has been
372 -       deactivated, because another surface has been activated. Window
373 -       decorations should be updated accordingly.
374 +    <event name="close">
375 +      <description summary="surface wants to be closed">
376 +        The close event is sent by the compositor when the user
377 +        wants the surface to be closed. This should be equivalent to
378 +        the user clicking the close button in client-side decorations,
379 +        if your application has any...
380 +
381 +        This is only a request that the user intends to close your
382 +        window. The client may choose to ignore this request, or show
383 +        a dialog to ask the user to save their data...
384        </description>
385      </event>
386    </interface>
387 @@ -409,22 +431,6 @@
388        </description>
389      </request>
390  
391 -    <request name="pong">
392 -      <description summary="respond to a ping event">
393 -       A client must respond to a ping event with a pong request or
394 -       the client may be deemed unresponsive.
395 -      </description>
396 -      <arg name="serial" type="uint" summary="serial of the ping event"/>
397 -    </request>
398 -
399 -    <event name="ping">
400 -      <description summary="ping client">
401 -       Ping a client to check if it is receiving events and sending
402 -       requests. A client is expected to reply with a pong request.
403 -      </description>
404 -      <arg name="serial" type="uint"/>
405 -    </event>
406 -
407      <event name="popup_done">
408        <description summary="popup interaction is done">
409         The popup_done event is sent out when a popup grab is broken,
410 diff --git a/src/client/client.pro b/src/client/client.pro
411 index 9ecf82f..73e3b7f 100644
412 --- a/src/client/client.pro
413 +++ b/src/client/client.pro
414 @@ -59,6 +59,7 @@ SOURCES +=  qwaylandintegration.cpp \
415              qwaylanddatasource.cpp \
416              qwaylandshellsurface.cpp \
417              qwaylandwlshellsurface.cpp \
418 +            qwaylandxdgshell.cpp \
419              qwaylandxdgsurface.cpp \
420              qwaylandextendedoutput.cpp \
421              qwaylandextendedsurface.cpp \
422 @@ -89,6 +90,7 @@ HEADERS +=  qwaylandintegration_p.h \
423              qwaylanddatasource_p.h \
424              qwaylandshellsurface_p.h \
425              qwaylandwlshellsurface_p.h \
426 +            qwaylandxdgshell_p.h \
427              qwaylandxdgsurface_p.h \
428              qwaylandextendedoutput_p.h \
429              qwaylandextendedsurface_p.h \
430 diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
431 index 7f953ad..2e25672 100644
432 --- a/src/client/qwaylanddisplay.cpp
433 +++ b/src/client/qwaylanddisplay.cpp
434 @@ -50,7 +50,7 @@
435  #include "qwaylandclipboard_p.h"
436  #include "qwaylanddatadevicemanager_p.h"
437  #include "qwaylandhardwareintegration_p.h"
438 -
439 +#include "qwaylandxdgshell_p.h"
440  
441  #include "qwaylandwindowmanagerintegration_p.h"
442  
443 @@ -209,8 +209,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
444          mShm = static_cast<struct wl_shm *>(wl_registry_bind(registry, id, &wl_shm_interface,1));
445      } else if (interface == QStringLiteral("xdg_shell")
446                 && qEnvironmentVariableIsSet("QT_WAYLAND_USE_XDG_SHELL")) {
447 -        mShellXdg.reset(new QtWayland::xdg_shell(registry, id));
448 -        mShellXdg->use_unstable_version(QtWayland::xdg_shell::version_current);
449 +        mShellXdg.reset(new QWaylandXdgShell(registry,id));
450      } else if (interface == QStringLiteral("wl_shell")){
451          mShell.reset(new QtWayland::wl_shell(registry, id));
452      } else if (interface == QStringLiteral("wl_seat")) {
453 @@ -275,4 +274,9 @@ void QWaylandDisplay::forceRoundTrip()
454      wl_display_roundtrip(mDisplay);
455  }
456  
457 +QtWayland::xdg_shell *QWaylandDisplay::shellXdg()
458 +{
459 +    return mShellXdg.data();
460 +}
461 +
462  QT_END_NAMESPACE
463 diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h
464 index cf5dfc2..f1b35a7 100644
465 --- a/src/client/qwaylanddisplay_p.h
466 +++ b/src/client/qwaylanddisplay_p.h
467 @@ -72,6 +72,7 @@ class QWaylandWindow;
468  class QWaylandEventThread;
469  class QWaylandIntegration;
470  class QWaylandHardwareIntegration;
471 +class QWaylandXdgShell;
472  
473  namespace QtWayland {
474      class qt_output_extension;
475 @@ -115,7 +116,7 @@ public:
476      QtWayland::wl_compositor *compositor() { return &mCompositor; }
477  
478      QtWayland::wl_shell *shell() { return mShell.data(); }
479 -    QtWayland::xdg_shell *shellXdg() { return mShellXdg.data(); }
480 +    QtWayland::xdg_shell *shellXdg();
481  
482      QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; }
483      QWaylandInputDevice *defaultInputDevice() const;
484 @@ -171,7 +172,7 @@ private:
485      QThread *mEventThread;
486      QWaylandEventThread *mEventThreadObject;
487      QScopedPointer<QtWayland::wl_shell> mShell;
488 -    QScopedPointer<QtWayland::xdg_shell> mShellXdg;
489 +    QScopedPointer<QWaylandXdgShell> mShellXdg;
490      QList<QPlatformScreen *> mScreens;
491      QList<QWaylandInputDevice *> mInputDevices;
492      QList<Listener> mRegistryListeners;
493 diff --git a/src/client/qwaylandxdgshell.cpp b/src/client/qwaylandxdgshell.cpp
494 new file mode 100644
495 index 0000000..eb9f91c
496 --- /dev/null
497 +++ b/src/client/qwaylandxdgshell.cpp
498 @@ -0,0 +1,77 @@
499 +/****************************************************************************
500 +**
501 +** Copyright (C) 2014 Eurogiciel, author: <philippe.coval@eurogiciel.fr>
502 +** Contact: http://www.qt-project.org/legal
503 +**
504 +** This file is part of the config.tests of the Qt Toolkit.
505 +**
506 +** $QT_BEGIN_LICENSE:LGPL$
507 +** Commercial License Usage
508 +** Licensees holding valid commercial Qt licenses may use this file in
509 +** accordance with the commercial license agreement provided with the
510 +** Software or, alternatively, in accordance with the terms contained in
511 +** a written agreement between you and Digia.  For licensing terms and
512 +** conditions see http://qt.digia.com/licensing.  For further information
513 +** use the contact form at http://qt.digia.com/contact-us.
514 +**
515 +** GNU Lesser General Public License Usage
516 +** Alternatively, this file may be used under the terms of the GNU Lesser
517 +** General Public License version 2.1 as published by the Free Software
518 +** Foundation and appearing in the file LICENSE.LGPL included in the
519 +** packaging of this file.  Please review the following information to
520 +** ensure the GNU Lesser General Public License version 2.1 requirements
521 +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
522 +**
523 +** In addition, as a special exception, Digia gives you certain additional
524 +** rights.  These rights are described in the Digia Qt LGPL Exception
525 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
526 +**
527 +** GNU General Public License Usage
528 +** Alternatively, this file may be used under the terms of the GNU
529 +** General Public License version 3.0 as published by the Free Software
530 +** Foundation and appearing in the file LICENSE.GPL included in the
531 +** packaging of this file.  Please review the following information to
532 +** ensure the GNU General Public License version 3.0 requirements will be
533 +** met: http://www.gnu.org/copyleft/gpl.html.
534 +**
535 +**
536 +** $QT_END_LICENSE$
537 +**
538 +****************************************************************************/
539 +
540 +#include "qwaylandxdgshell_p.h"
541 +
542 +#include "qwaylanddisplay_p.h"
543 +#include "qwaylandwindow_p.h"
544 +#include "qwaylandinputdevice_p.h"
545 +#include "qwaylanddecoration_p.h"
546 +#include "qwaylandscreen_p.h"
547 +
548 +#include <QtCore/QDebug>
549 +
550 +QT_BEGIN_NAMESPACE
551 +
552 +QWaylandXdgShell::QWaylandXdgShell(struct ::xdg_shell *shell)
553 +    : QtWayland::xdg_shell(shell)
554 +{
555 +}
556 +
557 +QWaylandXdgShell::QWaylandXdgShell(struct ::wl_registry *registry, uint32_t id)
558 +    : QtWayland::xdg_shell(registry, id)
559 +{
560 +    use_unstable_version(QtWayland::xdg_shell::version_current);
561 +}
562 +
563 +QWaylandXdgShell::~QWaylandXdgShell()
564 +{
565 +    xdg_shell_destroy(object());
566 +}
567 +
568 +
569 +void QWaylandXdgShell::xdg_shell_ping(uint32_t serial)
570 +{
571 +    pong(serial);
572 +}
573 +
574 +
575 +QT_END_NAMESPACE
576 diff --git a/src/client/qwaylandxdgshell_p.h b/src/client/qwaylandxdgshell_p.h
577 new file mode 100644
578 index 0000000..6a396bd
579 --- /dev/null
580 +++ b/src/client/qwaylandxdgshell_p.h
581 @@ -0,0 +1,73 @@
582 +/****************************************************************************
583 +**
584 +** Copyright (C) 2014 Eurogiciel, author: <philippe.coval@eurogiciel.fr>
585 +** Contact: http://www.qt-project.org/legal
586 +**
587 +** This file is part of the config.tests of the Qt Toolkit.
588 +**
589 +** $QT_BEGIN_LICENSE:LGPL$
590 +** Commercial License Usage
591 +** Licensees holding valid commercial Qt licenses may use this file in
592 +** accordance with the commercial license agreement provided with the
593 +** Software or, alternatively, in accordance with the terms contained in
594 +** a written agreement between you and Digia.  For licensing terms and
595 +** conditions see http://qt.digia.com/licensing.  For further information
596 +** use the contact form at http://qt.digia.com/contact-us.
597 +**
598 +** GNU Lesser General Public License Usage
599 +** Alternatively, this file may be used under the terms of the GNU Lesser
600 +** General Public License version 2.1 as published by the Free Software
601 +** Foundation and appearing in the file LICENSE.LGPL included in the
602 +** packaging of this file.  Please review the following information to
603 +** ensure the GNU Lesser General Public License version 2.1 requirements
604 +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
605 +**
606 +** In addition, as a special exception, Digia gives you certain additional
607 +** rights.  These rights are described in the Digia Qt LGPL Exception
608 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
609 +**
610 +** GNU General Public License Usage
611 +** Alternatively, this file may be used under the terms of the GNU
612 +** General Public License version 3.0 as published by the Free Software
613 +** Foundation and appearing in the file LICENSE.GPL included in the
614 +** packaging of this file.  Please review the following information to
615 +** ensure the GNU General Public License version 3.0 requirements will be
616 +** met: http://www.gnu.org/copyleft/gpl.html.
617 +**
618 +**
619 +** $QT_END_LICENSE$
620 +**
621 +****************************************************************************/
622 +
623 +#ifndef QWAYLANDXDGSHELL_H
624 +#define QWAYLANDXDGSHELL_H
625 +
626 +#include <QtCore/QSize>
627 +
628 +#include <wayland-client.h>
629 +
630 +#include <QtWaylandClient/private/qwayland-xdg-shell.h>
631 +#include <QtWaylandClient/private/qwaylandclientexport_p.h>
632 +#include "qwaylandshellsurface_p.h"
633 +
634 +QT_BEGIN_NAMESPACE
635 +
636 +class QWaylandWindow;
637 +class QWaylandInputDevice;
638 +class QWindow;
639 +
640 +class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShell : public QtWayland::xdg_shell
641 +{
642 +public:
643 +    QWaylandXdgShell(struct ::xdg_shell *shell);
644 +    QWaylandXdgShell(struct ::wl_registry *registry, uint32_t id);
645 +
646 +    virtual ~QWaylandXdgShell();
647 +
648 +private:
649 +    void xdg_shell_ping(uint32_t serial) Q_DECL_OVERRIDE;
650 +};
651 +
652 +QT_END_NAMESPACE
653 +
654 +#endif // QWAYLANDXDGSHELL_H
655 diff --git a/src/client/qwaylandxdgsurface.cpp b/src/client/qwaylandxdgsurface.cpp
656 index 1b8affa..5fb74d2 100644
657 --- a/src/client/qwaylandxdgsurface.cpp
658 +++ b/src/client/qwaylandxdgsurface.cpp
659 @@ -87,23 +87,25 @@ void QWaylandXdgSurface::move(QWaylandInputDevice *inputDevice)
660  
661  void QWaylandXdgSurface::setMaximized()
662  {
663 -    m_maximized = true;
664 -    m_size = m_window->window()->geometry().size();
665 -    set_maximized();
666 +    if (!m_maximized)
667 +        request_change_state(XDG_SURFACE_STATE_MAXIMIZED, true, 0);
668  }
669  
670  void QWaylandXdgSurface::setFullscreen()
671  {
672 -    m_fullscreen = true;
673 -    m_size = m_window->window()->geometry().size();
674 -    set_fullscreen();
675 +    if (!m_fullscreen)
676 +        request_change_state(XDG_SURFACE_STATE_FULLSCREEN, true, 0);
677  }
678  
679  void QWaylandXdgSurface::setNormal()
680  {
681      if (m_fullscreen || m_maximized  || m_minimized) {
682 -        if (m_maximized) { unset_maximized(); }
683 -        if (m_fullscreen) { unset_fullscreen(); }
684 +        if (m_maximized) {
685 +            request_change_state(XDG_SURFACE_STATE_MAXIMIZED, false, 0);
686 +        }
687 +        if (m_fullscreen) {
688 +            request_change_state(XDG_SURFACE_STATE_FULLSCREEN, false, 0);
689 +        }
690  
691          m_fullscreen = m_maximized = m_minimized = false;
692          setTopLevel();
693 @@ -158,16 +160,48 @@ void QWaylandXdgSurface::setAppId(const QString & appId)
694      return QtWayland::xdg_surface::set_app_id(appId);
695  }
696  
697 -void QWaylandXdgSurface::xdg_surface_ping(uint32_t serial)
698 +void QWaylandXdgSurface::xdg_surface_configure(int32_t width, int32_t height)
699  {
700 -    pong(serial);
701 +    m_window->configure(0 , width, height);
702  }
703  
704 -void QWaylandXdgSurface::xdg_surface_configure(uint32_t edges, int32_t width,
705 -                                               int32_t height)
706 +void QWaylandXdgSurface::xdg_surface_change_state(uint32_t state,
707 +                                                  uint32_t value,
708 +                                                  uint32_t serial)
709  {
710 -    m_window->configure(edges, width, height);
711 +
712 +    if (state == XDG_SURFACE_STATE_MAXIMIZED
713 +            || state == XDG_SURFACE_STATE_FULLSCREEN) {
714 +        if (value) {
715 +            m_size = m_window->window()->geometry().size();
716 +        } else {
717 +            QMargins m = m_window->frameMargins();
718 +            m_window->configure(0, m_size.width() + m.left() + m.right(), m_size.height() + m.top() + m.bottom());
719 +        }
720 +    }
721 +
722 +    switch (state) {
723 +    case XDG_SURFACE_STATE_MAXIMIZED:
724 +        m_maximized = value;
725 +        break;
726 +    case XDG_SURFACE_STATE_FULLSCREEN:
727 +        m_fullscreen = value;
728 +        break;
729 +    }
730 +
731 +    xdg_surface_ack_change_state(object(), state, value, serial);
732  }
733  
734 +void QWaylandXdgSurface::xdg_surface_activated()
735 +{
736 +}
737 +
738 +void QWaylandXdgSurface::xdg_surface_deactivated()
739 +{
740 +}
741 +
742 +void QWaylandXdgSurface::xdg_surface_close()
743 +{
744 +}
745  
746  QT_END_NAMESPACE
747 diff --git a/src/client/qwaylandxdgsurface_p.h b/src/client/qwaylandxdgsurface_p.h
748 index 744d3f3..d2a154e 100644
749 --- a/src/client/qwaylandxdgsurface_p.h
750 +++ b/src/client/qwaylandxdgsurface_p.h
751 @@ -93,10 +93,15 @@ private:
752      bool m_fullscreen;
753      QSize m_size;
754  
755 -    void xdg_surface_ping(uint32_t serial) Q_DECL_OVERRIDE;
756 -    void xdg_surface_configure(uint32_t edges,
757 -                               int32_t width,
758 +    void xdg_surface_configure(int32_t width,
759                                 int32_t height) Q_DECL_OVERRIDE;
760 +    void xdg_surface_change_state(uint32_t state,
761 +                                  uint32_t value,
762 +                                  uint32_t serial) Q_DECL_OVERRIDE;
763 +    void xdg_surface_activated() Q_DECL_OVERRIDE;
764 +    void xdg_surface_deactivated() Q_DECL_OVERRIDE;
765 +    void xdg_surface_close() Q_DECL_OVERRIDE;
766 +
767      friend class QWaylandWindow;
768  };
769  
770 -- 
771 1.9.1
772