summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/protocol/qt_attribution.json39
-rw-r--r--src/3rdparty/protocol/wayland.xml743
-rw-r--r--src/3rdparty/protocol/xdg-decoration-unstable-v1.xml156
-rw-r--r--src/3rdparty/protocol/xdg-output-unstable-v1.xml209
-rw-r--r--src/3rdparty/protocol/xdg-shell-unstable-v5.xml608
-rw-r--r--src/3rdparty/protocol/xdg-shell.xml1078
-rw-r--r--src/client/client.pro21
-rw-r--r--src/client/qwaylandcursor.cpp379
-rw-r--r--src/client/qwaylandcursor_p.h42
-rw-r--r--src/client/qwaylanddisplay.cpp67
-rw-r--r--src/client/qwaylanddisplay_p.h23
-rw-r--r--src/client/qwaylanddnd.cpp8
-rw-r--r--src/client/qwaylanddnd_p.h4
-rw-r--r--src/client/qwaylandinputdevice.cpp26
-rw-r--r--src/client/qwaylandinputdevice_p.h6
-rw-r--r--src/client/qwaylandintegration.cpp29
-rw-r--r--src/client/qwaylandintegration_p.h3
-rw-r--r--src/client/qwaylandnativeinterface.cpp15
-rw-r--r--src/client/qwaylandqtkey.cpp4
-rw-r--r--src/client/qwaylandqtkey_p.h26
-rw-r--r--src/client/qwaylandscreen.cpp72
-rw-r--r--src/client/qwaylandscreen_p.h19
-rw-r--r--src/client/qwaylandshellsurface_p.h10
-rw-r--r--src/client/qwaylandwindow.cpp145
-rw-r--r--src/client/qwaylandwindow_p.h37
-rw-r--r--src/client/qwaylandxdgsurface.cpp257
-rw-r--r--src/client/shellintegration/qwaylandshellintegration_p.h5
-rw-r--r--src/client/shellintegration/qwaylandshellintegrationfactory.cpp17
-rw-r--r--src/client/shellintegration/qwaylandshellintegrationfactory_p.h5
-rw-r--r--src/compositor/compositor_api/compositor_api.pri1
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.cpp123
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.h2
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor_p.h8
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard.cpp41
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard.h2
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard_p.h3
-rw-r--r--src/compositor/compositor_api/qwaylandkeymap.h2
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.cpp105
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.h3
-rw-r--r--src/compositor/compositor_api/qwaylandoutput_p.h3
-rw-r--r--src/compositor/compositor_api/qwaylandoutputmode.cpp12
-rw-r--r--src/compositor/compositor_api/qwaylandoutputmode.h5
-rw-r--r--src/compositor/compositor_api/qwaylandquickchildren.h100
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.cpp152
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.h4
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem_p.h9
-rw-r--r--src/compositor/compositor_api/qwaylandquickoutput.h2
-rw-r--r--src/compositor/compositor_api/qwaylandquicksurface.h2
-rw-r--r--src/compositor/compositor_api/qwaylandseat.cpp48
-rw-r--r--src/compositor/compositor_api/qwaylandseat.h1
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.cpp4
-rw-r--r--src/compositor/doc/qtwaylandcompositor.qdocconf2
-rw-r--r--src/compositor/extensions/extensions.pri15
-rw-r--r--src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5.cpp899
-rw-r--r--src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5_p.h436
-rw-r--r--src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c126
-rw-r--r--src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-server-protocol_p.h905
-rw-r--r--src/compositor/extensions/pregenerated/xdg-shell-v5.pri10
-rw-r--r--src/compositor/extensions/qwaylandivisurface.h2
-rw-r--r--src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp45
-rw-r--r--src/compositor/extensions/qwaylandquickshellsurfaceitem.h5
-rw-r--r--src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h10
-rw-r--r--src/compositor/extensions/qwaylandwlshell.h2
-rw-r--r--src/compositor/extensions/qwaylandwlshellintegration.cpp47
-rw-r--r--src/compositor/extensions/qwaylandwlshellintegration_p.h10
-rw-r--r--src/compositor/extensions/qwaylandxdgdecorationv1.cpp260
-rw-r--r--src/compositor/extensions/qwaylandxdgdecorationv1.h69
-rw-r--r--src/compositor/extensions/qwaylandxdgdecorationv1_p.h108
-rw-r--r--src/compositor/extensions/qwaylandxdgshell.cpp2090
-rw-r--r--src/compositor/extensions/qwaylandxdgshell.h275
-rw-r--r--src/compositor/extensions/qwaylandxdgshell_p.h244
-rw-r--r--src/compositor/extensions/qwaylandxdgshellintegration.cpp300
-rw-r--r--src/compositor/extensions/qwaylandxdgshellintegration_p.h144
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv5.cpp20
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv5.h3
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv5_p.h10
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv5integration.cpp12
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv6.cpp26
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv6.h2
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv6integration.cpp110
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv6integration_p.h15
-rw-r--r--src/compositor/extensions/qwlqtkey.cpp20
-rw-r--r--src/compositor/extensions/qwlqtkey_p.h4
-rw-r--r--src/compositor/wayland_wrapper/qwlregion.cpp4
-rw-r--r--src/extensions/README.md18
-rw-r--r--src/extensions/qt-key-unstable-v1.xml (renamed from src/extensions/qtkey-extension.xml)54
-rw-r--r--src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp27
-rw-r--r--src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h3
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp11
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp4
-rw-r--r--src/imports/compositor/WaylandCursorItem.qml24
-rw-r--r--src/imports/compositor/qwaylandquickcompositorplugin.cpp11
-rw-r--r--src/plugins/decorations/bradient/main.cpp164
-rw-r--r--src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp36
-rw-r--r--src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h8
-rw-r--r--src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp9
-rw-r--r--src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h3
-rw-r--r--src/plugins/shellintegration/shellintegration.pro8
-rw-r--r--src/plugins/shellintegration/wl-shell/main.cpp69
-rw-r--r--src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp (renamed from src/client/qwaylandwlshellintegration.cpp)39
-rw-r--r--src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration_p.h (renamed from src/client/qwaylandwlshellintegration_p.h)5
-rw-r--r--src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp (renamed from src/client/qwaylandwlshellsurface.cpp)116
-rw-r--r--src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h (renamed from src/client/qwaylandwlshellsurface_p.h)22
-rw-r--r--src/plugins/shellintegration/wl-shell/wl-shell.json3
-rw-r--r--src/plugins/shellintegration/wl-shell/wl-shell.pro25
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/main.cpp69
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/qwayland-xdg-shell-unstable-v5.cpp398
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/qwayland-xdg-shell-unstable-v5_p.h198
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-client-protocol_p.h1112
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c126
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/pregenerated/xdg-shell-v5.pri12
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp (renamed from src/client/qwaylandxdgpopup.cpp)22
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h (renamed from src/client/qwaylandxdgpopup_p.h)19
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp (renamed from src/client/qwaylandxdgshell.cpp)41
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5_p.h (renamed from src/client/qwaylandxdgshell_p.h)24
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp (renamed from src/client/qwaylandxdgshellintegration.cpp)40
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h80
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp237
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h (renamed from src/client/qwaylandxdgsurface_p.h)53
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.json3
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.pro29
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/main.cpp68
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp (renamed from src/client/qwaylandxdgshellv6.cpp)166
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h (renamed from src/client/qwaylandxdgshellv6_p.h)26
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp (renamed from src/client/qwaylandxdgshellv6integration.cpp)38
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h (renamed from src/client/qwaylandxdgshellv6integration_p.h)11
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.json3
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.pro25
-rw-r--r--src/plugins/shellintegration/xdg-shell/main.cpp68
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1.cpp105
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h97
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp404
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h181
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp88
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h (renamed from src/client/qwaylandxdgshellintegration_p.h)10
-rw-r--r--src/plugins/shellintegration/xdg-shell/xdg-shell.json3
-rw-r--r--src/plugins/shellintegration/xdg-shell/xdg-shell.pro28
-rw-r--r--src/qtwaylandscanner/qtwaylandscanner.cpp321
138 files changed, 13851 insertions, 1828 deletions
diff --git a/src/3rdparty/protocol/qt_attribution.json b/src/3rdparty/protocol/qt_attribution.json
index f35dec4f3..ba199812b 100644
--- a/src/3rdparty/protocol/qt_attribution.json
+++ b/src/3rdparty/protocol/qt_attribution.json
@@ -8,8 +8,8 @@
"Description": "Wayland is a protocol for a compositor to talk to its clients.",
"Homepage": "https://wayland.freedesktop.org",
- "Version": "1.6.1",
- "DownloadLocation": "https://cgit.freedesktop.org/wayland/wayland/tag/?id=1.6.1",
+ "Version": "1.10.0",
+ "DownloadLocation": "https://cgit.freedesktop.org/wayland/wayland/tag/?id=1.10.0",
"LicenseId": "HPND",
"License": "HPND License",
"LicenseFile": "HPND_LICENSE.txt",
@@ -37,11 +37,44 @@ Copyright (c) 2013 BMW Car IT GmbH"
},
{
+ "Id": "wayland-xdg-decoration-protocol",
+ "Name": "Wayland xdg-decoration Protocol",
+ "QDocModule": "qtwaylandcompositor",
+ "QtUsage": "Used in the Qt Wayland Compositor API, and the Qt Wayland platform plugin.",
+ "Files": "xdg-decoration-unstable-v1.xml",
+
+ "Description": "The xdg-decoration protocol allows a compositor to announce support for server-side decorations.",
+ "Homepage": "https://wayland.freedesktop.org",
+ "Version": "unstable v1, version 1",
+ "DownloadLocation": "https://cgit.freedesktop.org/wayland/wayland-protocols/plain/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml?h=1.16",
+ "LicenseId": "MIT",
+ "License": "MIT License",
+ "LicenseFile": "MIT_LICENSE.txt",
+ "Copyright": "Copyright © 2018 Simon Ser"
+ },
+
+ {
+ "Id": "wayland-xdg-output-protocol",
+ "Name": "Wayland XDG Output Protocol",
+ "QDocModule": "qtwaylandcompositor",
+ "QtUsage": "Used in the Qt Wayland platform plugin.",
+ "Files": "xdg-output-unstable-v1.xml",
+ "Description": "The XDG Output protocol is an extended way to describe output regions under Wayland",
+ "Homepage": "https://wayland.freedesktop.org",
+ "Version": "unstable v1, version 2",
+ "DownloadLocation": "https://cgit.freedesktop.org/wayland/wayland-protocols/plain/unstable/xdg-output/xdg-output-unstable-v1.xml?h=1.16",
+ "LicenseId": "MIT",
+ "License": "MIT License",
+ "LicenseFile": "MIT_LICENSE.txt",
+ "Copyright": "Copyright © 2017 Red Hat Inc."
+ },
+
+ {
"Id": "wayland-xdg-shell-protocol",
"Name": "Wayland XDG Shell Protocol",
"QDocModule": "qtwaylandcompositor",
"QtUsage": "Used in the Qt Wayland Compositor, and the Qt Wayland platform plugin.",
- "Files": "xdg-shell.xml",
+ "Files": " xdg-shell-unstable-v5.xml xdg-shell-unstable-v6.xml xdg-shell.xml ../../compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5.cpp ../../compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5_p.h ../../compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c ../../compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-server-protocol_p.h ../../plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/qwayland-xdg-shell-unstable-v5.cpp ../../plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/qwayland-xdg-shell-unstable-v5_p.h ../../plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-client-protocol_p.h ../../plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c",
"Description": "The XDG-Shell protocol is an extended way to manage surfaces under Wayland compositors.",
"Homepage": "https://wayland.freedesktop.org",
diff --git a/src/3rdparty/protocol/wayland.xml b/src/3rdparty/protocol/wayland.xml
index bb457bcf7..8739cd319 100644
--- a/src/3rdparty/protocol/wayland.xml
+++ b/src/3rdparty/protocol/wayland.xml
@@ -6,26 +6,26 @@
Copyright © 2010-2011 Intel Corporation
Copyright © 2012-2013 Collabora, Ltd.
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that copyright notice and this permission
- notice appear in supporting documentation, and that the name of
- the copyright holders not be used in advertising or publicity
- pertaining to distribution of the software without specific,
- written prior permission. The copyright holders make no
- representations about the suitability of this software for any
- purpose. It is provided "as is" without express or implied
- warranty.
-
- THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
- SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
- AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
- THIS SOFTWARE.
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
</copyright>
<interface name="wl_display" version="1">
@@ -176,7 +176,7 @@
</event>
</interface>
- <interface name="wl_compositor" version="3">
+ <interface name="wl_compositor" version="4">
<description summary="the compositor singleton">
A compositor. This object is a singleton global. The
compositor is in charge of combining the contents of multiple
@@ -367,7 +367,7 @@
can be used for buffers. Known formats include
argb8888 and xrgb8888.
</description>
- <arg name="format" type="uint"/>
+ <arg name="format" type="uint" enum="format"/>
</event>
</interface>
@@ -408,7 +408,7 @@
</interface>
- <interface name="wl_data_offer" version="1">
+ <interface name="wl_data_offer" version="3">
<description summary="offer to transfer data">
A wl_data_offer represents a piece of data offered for transfer
by another client (the source client). It is used by the
@@ -418,12 +418,33 @@
data directly from the source client.
</description>
+ <enum name="error">
+ <entry name="invalid_finish" value="0"
+ summary="finish request was called untimely"/>
+ <entry name="invalid_action_mask" value="1"
+ summary="action mask contains invalid values"/>
+ <entry name="invalid_action" value="2"
+ summary="action argument has an invalid value"/>
+ <entry name="invalid_offer" value="3"
+ summary="offer doesn't accept this request"/>
+ </enum>
+
<request name="accept">
<description summary="accept one of the offered mime types">
Indicate that the client can accept the given mime type, or
NULL for not accepted.
- Used for feedback during drag-and-drop.
+ For objects of version 2 or older, this request is used by the
+ client to give feedback whether the client can receive the given
+ mime type, or NULL if none is accepted; the feedback does not
+ determine whether the drag-and-drop operation succeeds or not.
+
+ For objects of version 3 or newer, this request determines the
+ final result of the drag-and-drop operation. If the end result
+ is that no mime types were accepted, the drag-and-drop operation
+ will be cancelled and the corresponding drag source will receive
+ wl_data_source.cancelled. Clients may still use this event in
+ conjunction with wl_data_source.action for feedback.
</description>
<arg name="serial" type="uint"/>
@@ -440,8 +461,13 @@
file descriptor.
The receiving client reads from the read end of the pipe until
- EOF and the closes its end, at which point the transfer is
+ EOF and then closes its end, at which point the transfer is
complete.
+
+ This request may happen multiple times for different mimetypes,
+ both before and after wl_data_device.drop. Drag-and-drop destination
+ clients may preemptively fetch data or examine it more closely to
+ determine acceptance.
</description>
<arg name="mime_type" type="string"/>
<arg name="fd" type="fd"/>
@@ -461,9 +487,115 @@
<arg name="mime_type" type="string"/>
</event>
+
+ <!-- Version 3 additions -->
+
+ <request name="finish" since="3">
+ <description summary="the offer will no longer be used">
+ Notifies the compositor that the drag destination successfully
+ finished the drag-and-drop operation.
+
+ Upon receiving this request, the compositor will emit
+ wl_data_source.dnd_finished on the drag source client.
+
+ It is a client error to perform other requests than
+ wl_data_offer.destroy after this one. It is also an error to perform
+ this request after a NULL mime type has been set in
+ wl_data_offer.accept or no action was received through
+ wl_data_offer.action.
+ </description>
+ </request>
+
+ <request name="set_actions" since="3">
+ <description summary="set the available/preferred drag-and-drop actions">
+ Sets the actions that the destination side client supports for
+ this operation. This request may trigger the emission of
+ wl_data_source.action and wl_data_offer.action events if the compositor
+ need to change the selected action.
+
+ This request can be called multiple times throughout the
+ drag-and-drop operation, typically in response to wl_data_device.enter
+ or wl_data_device.motion events.
+
+ This request determines the final result of the drag-and-drop
+ operation. If the end result is that no action is accepted,
+ the drag source will receive wl_drag_source.cancelled.
+
+ The dnd_actions argument must contain only values expressed in the
+ wl_data_device_manager.dnd_actions enum, and the preferred_action
+ argument must only contain one of those values set, otherwise it
+ will result in a protocol error.
+
+ While managing an "ask" action, the destination drag-and-drop client
+ may perform further wl_data_offer.receive requests, and is expected
+ to perform one last wl_data_offer.set_actions request with a preferred
+ action other than "ask" (and optionally wl_data_offer.accept) before
+ requesting wl_data_offer.finish, in order to convey the action selected
+ by the user. If the preferred action is not in the
+ wl_data_offer.source_actions mask, an error will be raised.
+
+ If the "ask" action is dismissed (e.g. user cancellation), the client
+ is expected to perform wl_data_offer.destroy right away.
+
+ This request can only be made on drag-and-drop offers, a protocol error
+ will be raised otherwise.
+ </description>
+ <arg name="dnd_actions" type="uint"/>
+ <arg name="preferred_action" type="uint"/>
+ </request>
+
+ <event name="source_actions" since="3">
+ <description summary="notify the source-side available actions">
+ This event indicates the actions offered by the data source. It
+ will be sent right after wl_data_device.enter, or anytime the source
+ side changes its offered actions through wl_data_source.set_actions.
+ </description>
+ <arg name="source_actions" type="uint"/>
+ </event>
+
+ <event name="action" since="3">
+ <description summary="notify the selected action">
+ This event indicates the action selected by the compositor after
+ matching the source/destination side actions. Only one action (or
+ none) will be offered here.
+
+ This event can be emitted multiple times during the drag-and-drop
+ operation in response to destination side action changes through
+ wl_data_offer.set_actions.
+
+ This event will no longer be emitted after wl_data_device.drop
+ happened on the drag-and-drop destination, the client must
+ honor the last action received, or the last preferred one set
+ through wl_data_offer.set_actions when handling an "ask" action.
+
+ Compositors may also change the selected action on the fly, mainly
+ in response to keyboard modifier changes during the drag-and-drop
+ operation.
+
+ The most recent action received is always the valid one. Prior to
+ receiving wl_data_device.drop, the chosen action may change (e.g.
+ due to keyboard modifiers being pressed). At the time of receiving
+ wl_data_device.drop the drag-and-drop destination must honor the
+ last action received.
+
+ Action changes may still happen after wl_data_device.drop,
+ especially on "ask" actions, where the drag-and-drop destination
+ may choose another action afterwards. Action changes happening
+ at this stage are always the result of inter-client negotiation, the
+ compositor shall no longer be able to induce a different action.
+
+ Upon "ask" actions, it is expected that the drag-and-drop destination
+ may potentially choose different a different action and/or mime type,
+ based on wl_data_offer.source_actions and finally chosen by the
+ user (e.g. popping up a menu with the available options). The
+ final wl_data_offer.set_actions and wl_data_offer.accept requests
+ must happen before the call to wl_data_offer.finish.
+ </description>
+ <arg name="dnd_action" type="uint"/>
+ </event>
</interface>
- <interface name="wl_data_source" version="1">
+ <interface name="wl_data_source" version="3">
<description summary="offer to transfer data">
The wl_data_source object is the source side of a wl_data_offer.
It is created by the source client in a data transfer and
@@ -471,6 +603,13 @@
to requests to transfer the data.
</description>
+ <enum name="error">
+ <entry name="invalid_action_mask" value="0"
+ summary="action mask contains invalid values"/>
+ <entry name="invalid_source" value="1"
+ summary="source doesn't accept this request"/>
+ </enum>
+
<request name="offer">
<description summary="add an offered mime type">
This request adds a mime type to the set of mime types
@@ -510,14 +649,108 @@
<event name="cancelled">
<description summary="selection was cancelled">
- This data source has been replaced by another data source.
+ This data source is no longer valid. There are several reasons why
+ this could happen:
+
+ - The data source has been replaced by another data source.
+ - The drag-and-drop operation was performed, but the drop destination
+ did not accept any of the mimetypes offered through
+ wl_data_source.target.
+ - The drag-and-drop operation was performed, but the drop destination
+ did not select any of the actions present in the mask offered through
+ wl_data_source.action.
+ - The drag-and-drop operation was performed but didn't happen over a
+ surface.
+ - The compositor cancelled the drag-and-drop operation (e.g. compositor
+ dependent timeouts to avoid stale drag-and-drop transfers).
+
The client should clean up and destroy this data source.
+
+ For objects of version 2 or older, wl_data_source.cancelled will
+ only be emitted if the data source was replaced by another data
+ source.
+ </description>
+ </event>
+
+ <!-- Version 3 additions -->
+
+ <request name="set_actions" since="3">
+ <description summary="set the available drag-and-drop actions">
+ Sets the actions that the source side client supports for this
+ operation. This request may trigger wl_data_source.action and
+ wl_data_offer.action events if the compositor needs to change the
+ selected action.
+
+ The dnd_actions argument must contain only values expressed in the
+ wl_data_device_manager.dnd_actions enum, otherwise it will result
+ in a protocol error.
+
+ This request must be made once only, and can only be made on sources
+ used in drag-and-drop, so it must be performed before
+ wl_data_device.start_drag. Attempting to use the source other than
+ for drag-and-drop will raise a protocol error.
+ </description>
+ <arg name="dnd_actions" type="uint"/>
+ </request>
+
+ <event name="dnd_drop_performed" since="3">
+ <description summary="the drag-and-drop operation physically finished">
+ The user performed the drop action. This event does not indicate
+ acceptance, wl_data_source.cancelled may still be emitted afterwards
+ if the drop destination does not accept any mimetype.
+
+ However, this event might however not be received if the compositor
+ cancelled the drag-and-drop operation before this event could happen.
+
+ Note that the data_source may still be used in the future and should
+ not be destroyed here.
</description>
</event>
+ <event name="dnd_finished" since="3">
+ <description summary="the drag-and-drop operation concluded">
+ The drop destination finished interoperating with this data
+ source, so the client is now free to destroy this data source and
+ free all associated data.
+
+ If the action used to perform the operation was "move", the
+ source can now delete the transferred data.
+ </description>
+ </event>
+
+ <event name="action" since="3">
+ <description summary="notify the selected action">
+ This event indicates the action selected by the compositor after
+ matching the source/destination side actions. Only one action (or
+ none) will be offered here.
+
+ This event can be emitted multiple times during the drag-and-drop
+ operation, mainly in response to destination side changes through
+ wl_data_offer.set_actions, and as the data device enters/leaves
+ surfaces.
+
+ It is only possible to receive this event after
+ wl_data_source.dnd_drop_performed if the drag-and-drop operation
+ ended in an "ask" action, in which case the final wl_data_source.action
+ event will happen immediately before wl_data_source.dnd_finished.
+
+ Compositors may also change the selected action on the fly, mainly
+ in response to keyboard modifier changes during the drag-and-drop
+ operation.
+
+ The most recent action received is always the valid one. The chosen
+ action may change alongside negotiation (e.g. an "ask" action can turn
+ into a "move" operation), so the effects of the final action must
+ always be applied in wl_data_offer.dnd_finished.
+
+ Clients can trigger cursor surface changes from this point, so
+ they reflect the current action.
+ </description>
+ <arg name="dnd_action" type="uint"/>
+ </event>
</interface>
- <interface name="wl_data_device" version="1">
+ <interface name="wl_data_device" version="3">
<description summary="data transfer device">
There is one wl_data_device per seat which can be obtained
from the global wl_data_device_manager singleton.
@@ -525,6 +758,11 @@
A wl_data_device provides access to inter-client data transfer
mechanisms such as copy-and-paste and drag-and-drop.
</description>
+
+ <enum name="error">
+ <entry name="role" value="0" summary="given wl_surface has another role"/>
+ </enum>
+
<request name="start_drag">
<description summary="start drag-and-drop operation">
This request asks the compositor to start a drag-and-drop
@@ -545,7 +783,9 @@
the top-left corner of the icon surface is placed at the cursor
hotspot, but subsequent wl_surface.attach request can move the
relative position. Attach requests must be confirmed with
- wl_surface.commit as usual.
+ wl_surface.commit as usual. The icon surface is given the role of
+ a drag-and-drop icon. If the icon surface already has another role,
+ it raises a protocol error.
The current and pending input regions of the icon wl_surface are
cleared, and wl_surface.set_input_region is ignored until the
@@ -623,6 +863,17 @@
<description summary="end drag-and-drag session successfully">
The event is sent when a drag-and-drop operation is ended
because the implicit grab is removed.
+
+ The drag-and-drop destination is expected to honor the last action
+ received through wl_data_offer.action, if the resulting action is
+ "copy" or "move", the destination can still perform
+ wl_data_offer.receive requests, and is expected to end all
+ transfers with a wl_data_offer.finish request.
+
+ If the resulting action is "ask", the action will not be considered
+ final. The drag-and-drop destination is expected to perform one last
+ wl_data_offer.set_actions request, or wl_data_offer.destroy in order
+ to cancel the operation.
</description>
</event>
@@ -636,19 +887,34 @@
immediately before receiving keyboard focus and when a new
selection is set while the client has keyboard focus. The
data_offer is valid until a new data_offer or NULL is received
- or until the client loses keyboard focus.
+ or until the client loses keyboard focus. The client must
+ destroy the previous selection data_offer, if any, upon receiving
+ this event.
</description>
<arg name="id" type="object" interface="wl_data_offer" allow-null="true"/>
</event>
+
+ <!-- Version 2 additions -->
+
+ <request name="release" type="destructor" since="2">
+ <description summary="destroy data device">
+ This request destroys the data device.
+ </description>
+ </request>
</interface>
- <interface name="wl_data_device_manager" version="1">
+ <interface name="wl_data_device_manager" version="3">
<description summary="data transfer interface">
The wl_data_device_manager is a singleton global object that
provides access to inter-client data transfer mechanisms such as
copy-and-paste and drag-and-drop. These mechanisms are tied to
a wl_seat and this interface lets a client get a wl_data_device
corresponding to a wl_seat.
+
+ Depending on the version bound, the objects created from the bound
+ wl_data_device_manager object will have different requirements for
+ functioning properly. See wl_data_source.set_actions,
+ wl_data_offer.accept and wl_data_offer.finish for details.
</description>
<request name="create_data_source">
@@ -665,6 +931,40 @@
<arg name="id" type="new_id" interface="wl_data_device"/>
<arg name="seat" type="object" interface="wl_seat"/>
</request>
+
+ <!-- Version 3 additions -->
+
+ <enum name="dnd_action" bitfield="true" since="3">
+ <description summary="drag and drop actions">
+ This is a bitmask of the available/preferred actions in a
+ drag-and-drop operation.
+
+ In the compositor, the selected action is a result of matching the
+ actions offered by the source and destination sides. "action" events
+ with a "none" action will be sent to both source and destination if
+ there is no match. All further checks will effectively happen on
+ (source actions ∩ destination actions).
+
+ In addition, compositors may also pick different actions in
+ reaction to key modifiers being pressed, one common design that
+ is used in major toolkits (and the behavior recommended for
+ compositors) is:
+
+ - If no modifiers are pressed, the first match (in bit order)
+ will be used.
+ - Pressing Shift selects "move", if enabled in the mask.
+ - Pressing Control selects "copy", if enabled in the mask.
+
+ Behavior beyond that is considered implementation-dependent.
+ Compositors may for example bind other modifiers (like Alt/Meta)
+ or drags initiated with other buttons than BTN_LEFT to specific
+ actions (e.g. "ask").
+ </description>
+ <entry name="none" value="0"/>
+ <entry name="copy" value="1"/>
+ <entry name="move" value="2"/>
+ <entry name="ask" value="4"/>
+ </enum>
</interface>
<interface name="wl_shell" version="1">
@@ -676,9 +976,15 @@
a basic surface.
</description>
+ <enum name="error">
+ <entry name="role" value="0" summary="given wl_surface has another role"/>
+ </enum>
+
<request name="get_shell_surface">
<description summary="create a shell surface from a surface">
- Create a shell surface for an existing surface.
+ Create a shell surface for an existing surface. This gives
+ the wl_surface the role of a shell surface. If the wl_surface
+ already has another role, it raises a protocol error.
Only one shell surface can be associated with a given surface.
</description>
@@ -723,7 +1029,7 @@
<arg name="serial" type="uint" summary="serial of the implicit grab on the pointer"/>
</request>
- <enum name="resize">
+ <enum name="resize" bitfield="true">
<description summary="edge values for resizing">
These values are used to indicate which edge of a surface
is being dragged in a resize operation. The server may
@@ -751,7 +1057,7 @@
</description>
<arg name="seat" type="object" interface="wl_seat" summary="the wl_seat whose pointer is used"/>
<arg name="serial" type="uint" summary="serial of the implicit grab on the pointer"/>
- <arg name="edges" type="uint" summary="which edge or corner is being dragged"/>
+ <arg name="edges" type="uint" enum="resize" summary="which edge or corner is being dragged"/>
</request>
<request name="set_toplevel">
@@ -762,7 +1068,7 @@
</description>
</request>
- <enum name="transient">
+ <enum name="transient" bitfield="true">
<description summary="details of transient behaviour">
These flags specify details of the expected behaviour
of transient surfaces. Used in the set_transient request.
@@ -784,7 +1090,7 @@
<arg name="parent" type="object" interface="wl_surface"/>
<arg name="x" type="int"/>
<arg name="y" type="int"/>
- <arg name="flags" type="uint"/>
+ <arg name="flags" type="uint" enum="transient"/>
</request>
<enum name="fullscreen_method">
@@ -835,7 +1141,7 @@
with the dimensions for the output on which the surface will
be made fullscreen.
</description>
- <arg name="method" type="uint"/>
+ <arg name="method" type="uint" enum="fullscreen_method"/>
<arg name="framerate" type="uint"/>
<arg name="output" type="object" interface="wl_output" allow-null="true"/>
</request>
@@ -868,7 +1174,7 @@
<arg name="parent" type="object" interface="wl_surface"/>
<arg name="x" type="int"/>
<arg name="y" type="int"/>
- <arg name="flags" type="uint"/>
+ <arg name="flags" type="uint" enum="transient"/>
</request>
<request name="set_maximized">
@@ -949,7 +1255,7 @@
in surface local coordinates.
</description>
- <arg name="edges" type="uint"/>
+ <arg name="edges" type="uint" enum="resize"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
</event>
@@ -963,7 +1269,7 @@
</event>
</interface>
- <interface name="wl_surface" version="3">
+ <interface name="wl_surface" version="4">
<description summary="an onscreen surface">
A surface is a rectangular area that is displayed on the screen.
It has a location, size and pixel contents.
@@ -973,8 +1279,37 @@
local coordinates of the pixel content, in case a buffer_transform
or a buffer_scale is used.
- Surfaces are also used for some special purposes, e.g. as
- cursor images for pointers, drag icons, etc.
+ A surface without a "role" is fairly useless, a compositor does
+ not know where, when or how to present it. The role is the
+ purpose of a wl_surface. Examples of roles are a cursor for a
+ pointer (as set by wl_pointer.set_cursor), a drag icon
+ (wl_data_device.start_drag), a sub-surface
+ (wl_subcompositor.get_subsurface), and a window as defined by a
+ shell protocol (e.g. wl_shell.get_shell_surface).
+
+ A surface can have only one role at a time. Initially a
+ wl_surface does not have a role. Once a wl_surface is given a
+ role, it is set permanently for the whole lifetime of the
+ wl_surface object. Giving the current role again is allowed,
+ unless explicitly forbidden by the relevant interface
+ specification.
+
+ Surface roles are given by requests in other interfaces such as
+ wl_pointer.set_cursor. The request should explicitly mention
+ that this request gives a role to a wl_surface. Often, this
+ request also creates a new protocol object that represents the
+ role and adds additional functionality to wl_surface. When a
+ client wants to destroy a wl_surface, they must destroy this 'role
+ object' before the wl_surface.
+
+ Destroying the role object does not remove the role from the
+ wl_surface, but it may stop the wl_surface from "playing the role".
+ For instance, if a wl_subsurface object is destroyed, the wl_surface
+ it was created for will be unmapped and forget its position and
+ z-order. It is allowed to create a wl_subsurface for the same
+ wl_surface again, but it is not allowed to use the wl_surface as
+ a cursor (cursor is a different role than sub-surface, and role
+ switching is not allowed).
</description>
<enum name="error">
@@ -1043,10 +1378,8 @@
<description summary="mark part of the surface damaged">
This request is used to describe the regions where the pending
buffer is different from the current surface contents, and where
- the surface therefore needs to be repainted. The pending buffer
- must be set by wl_surface.attach before sending damage. The
- compositor ignores the parts of the damage that fall outside of
- the surface.
+ the surface therefore needs to be repainted. The compositor
+ ignores the parts of the damage that fall outside of the surface.
Damage is double-buffered state, see wl_surface.commit.
@@ -1059,6 +1392,10 @@
wl_surface.commit assigns pending damage as the current damage,
and clears pending damage. The server will clear the current
damage as it repaints the surface.
+
+ Alternatively, damage can be posted with wl_surface.damage_buffer
+ which uses buffer co-ordinates instead of surface co-ordinates,
+ and is probably the preferred and intuitive way of doing this.
</description>
<arg name="x" type="int"/>
@@ -1275,9 +1612,51 @@
</description>
<arg name="scale" type="int"/>
</request>
+
+ <!-- Version 4 additions -->
+ <request name="damage_buffer" since="4">
+ <description summary="mark part of the surface damaged using buffer co-ordinates">
+ This request is used to describe the regions where the pending
+ buffer is different from the current surface contents, and where
+ the surface therefore needs to be repainted. The compositor
+ ignores the parts of the damage that fall outside of the surface.
+
+ Damage is double-buffered state, see wl_surface.commit.
+
+ The damage rectangle is specified in buffer coordinates.
+
+ The initial value for pending damage is empty: no damage.
+ wl_surface.damage_buffer adds pending damage: the new pending
+ damage is the union of old pending damage and the given rectangle.
+
+ wl_surface.commit assigns pending damage as the current damage,
+ and clears pending damage. The server will clear the current
+ damage as it repaints the surface.
+
+ This request differs from wl_surface.damage in only one way - it
+ takes damage in buffer co-ordinates instead of surface local
+ co-ordinates. While this generally is more intuitive than surface
+ co-ordinates, it is especially desirable when using wp_viewport
+ or when a drawing library (like EGL) is unaware of buffer scale
+ and buffer transform.
+
+ Note: Because buffer transformation changes and damage requests may
+ be interleaved in the protocol stream, It is impossible to determine
+ the actual mapping between surface and buffer damage until
+ wl_surface.commit time. Therefore, compositors wishing to take both
+ kinds of damage into account will have to accumulate damage from the
+ two requests separately and only transform from one to the other
+ after receiving the wl_surface.commit.
+ </description>
+
+ <arg name="x" type="int"/>
+ <arg name="y" type="int"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </request>
</interface>
- <interface name="wl_seat" version="4">
+ <interface name="wl_seat" version="5">
<description summary="group of input devices">
A seat is a group of keyboards, pointer and touch devices. This
object is published as a global during start up, or when such a
@@ -1285,7 +1664,7 @@
maintains a keyboard focus and a pointer focus.
</description>
- <enum name="capability">
+ <enum name="capability" bitfield="true">
<description summary="seat capability bitmask">
This is a bitmask of capabilities this seat has; if a member is
set, then it is present on the seat.
@@ -1297,47 +1676,74 @@
<event name="capabilities">
<description summary="seat capabilities changed">
- This is emitted whenever a seat gains or loses the pointer,
+ This is emitted whenever a seat gains or loses the pointer,
keyboard or touch capabilities. The argument is a capability
enum containing the complete set of capabilities this seat has.
+
+ When the pointer capability is added, a client may create a
+ wl_pointer object using the wl_seat.get_pointer request. This object
+ will receive pointer events until the capability is removed in the
+ future.
+
+ When the pointer capability is removed, a client should destroy the
+ wl_pointer objects associated with the seat where the capability was
+ removed, using the wl_pointer.release request. No further pointer
+ events will be received on these objects.
+
+ In some compositors, if a seat regains the pointer capability and a
+ client has a previously obtained wl_pointer object of version 4 or
+ less, that object may start sending pointer events again. This
+ behavior is considered a misinterpretation of the intended behavior
+ and must not be relied upon by the client. wl_pointer objects of
+ version 5 or later must not send events if created before the most
+ recent event notifying the client of an added pointer capability.
+
+ The above behavior also applies to wl_keyboard and wl_touch with the
+ keyboard and touch capabilities, respectively.
</description>
- <arg name="capabilities" type="uint"/>
+ <arg name="capabilities" type="uint" enum="capability"/>
</event>
<request name="get_pointer">
<description summary="return pointer object">
- The ID provided will be initialized to the wl_pointer interface
+ The ID provided will be initialized to the wl_pointer interface
for this seat.
- This request only takes effect if the seat has the pointer
- capability.
+ This request only takes effect if the seat has the pointer
+ capability, or has had the pointer capability in the past.
+ It is a protocol violation to issue this request on a seat that has
+ never had the pointer capability.
</description>
<arg name="id" type="new_id" interface="wl_pointer"/>
</request>
<request name="get_keyboard">
<description summary="return keyboard object">
- The ID provided will be initialized to the wl_keyboard interface
+ The ID provided will be initialized to the wl_keyboard interface
for this seat.
- This request only takes effect if the seat has the keyboard
- capability.
+ This request only takes effect if the seat has the keyboard
+ capability, or has had the keyboard capability in the past.
+ It is a protocol violation to issue this request on a seat that has
+ never had the keyboard capability.
</description>
<arg name="id" type="new_id" interface="wl_keyboard"/>
</request>
<request name="get_touch">
<description summary="return touch object">
- The ID provided will be initialized to the wl_touch interface
+ The ID provided will be initialized to the wl_touch interface
for this seat.
- This request only takes effect if the seat has the touch
- capability.
+ This request only takes effect if the seat has the touch
+ capability, or has had the touch capability in the past.
+ It is a protocol violation to issue this request on a seat that has
+ never had the touch capability.
</description>
<arg name="id" type="new_id" interface="wl_touch"/>
</request>
- <!-- Version 2 of additions -->
+ <!-- Version 2 additions -->
<event name="name" since="2">
<description summary="unique identifier for this seat">
@@ -1348,9 +1754,18 @@
<arg name="name" type="string"/>
</event>
+ <!-- Version 5 additions -->
+
+ <request name="release" type="destructor" since="5">
+ <description summary="release the seat object">
+ Using this request client can tell the server that it is not going to
+ use the seat object anymore.
+ </description>
+ </request>
+
</interface>
- <interface name="wl_pointer" version="3">
+ <interface name="wl_pointer" version="5">
<description summary="pointer input device">
The wl_pointer interface represents one or more input devices,
such as mice, which control the pointer location and pointer_focus
@@ -1362,10 +1777,18 @@
and scrolling.
</description>
+ <enum name="error">
+ <entry name="role" value="0" summary="given wl_surface has another role"/>
+ </enum>
+
<request name="set_cursor">
<description summary="set the pointer surface">
Set the pointer surface, i.e., the surface that contains the
- pointer image (cursor). This request only takes effect if the pointer
+ pointer image (cursor). This request gives the surface the role
+ of a cursor. If the surface already has another role, it raises
+ a protocol error.
+
+ The cursor actually changes only if the pointer
focus for this device is one of the requesting client's surfaces
or the surface parameter is the current pointer surface. If
there was a previous surface set with this request it is
@@ -1461,7 +1884,7 @@
<arg name="serial" type="uint"/>
<arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
<arg name="button" type="uint"/>
- <arg name="state" type="uint"/>
+ <arg name="state" type="uint" enum="button_state"/>
</event>
<enum name="axis">
@@ -1493,19 +1916,169 @@
</description>
<arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
- <arg name="axis" type="uint"/>
+ <arg name="axis" type="uint" enum="axis"/>
<arg name="value" type="fixed"/>
</event>
<!-- Version 3 additions -->
<request name="release" type="destructor" since="3">
- <description summary="release the pointer object"/>
+ <description summary="release the pointer object">
+ Using this request client can tell the server that it is not going to
+ use the pointer object anymore.
+
+ This request destroys the pointer proxy object, so user must not call
+ wl_pointer_destroy() after using this request.
+ </description>
</request>
+ <!-- Version 5 additions -->
+
+ <event name="frame" since="5">
+ <description summary="end of a pointer event sequence">
+ Indicates the end of a set of events that logically belong together.
+ A client is expected to accumulate the data in all events within the
+ frame before proceeding.
+
+ All wl_pointer events before a wl_pointer.frame event belong
+ logically together. For example, in a diagonal scroll motion the
+ compositor will send an optional wl_pointer.axis_source event, two
+ wl_pointer.axis events (horizontal and vertical) and finally a
+ wl_pointer.frame event. The client may use this information to
+ calculate a diagonal vector for scrolling.
+
+ When multiple wl_pointer.axis events occur within the same frame,
+ the motion vector is the combined motion of all events.
+ When a wl_pointer.axis and a wl_pointer.axis_stop event occur within
+ the same frame, this indicates that axis movement in one axis has
+ stopped but continues in the other axis.
+ When multiple wl_pointer.axis_stop events occur within in the same
+ frame, this indicates that these axes stopped in the same instance.
+
+ A wl_pointer.frame event is sent for every logical event group,
+ even if the group only contains a single wl_pointer event.
+ Specifically, a client may get a sequence: motion, frame, button,
+ frame, axis, frame, axis_stop, frame.
+
+ The wl_pointer.enter and wl_pointer.leave events are logical events
+ generated by the compositor and not the hardware. These events are
+ also grouped by a wl_pointer.frame. When a pointer moves from one
+ surface to the another, a compositor should group the
+ wl_pointer.leave event within the same wl_pointer.frame.
+ However, a client must not rely on wl_pointer.leave and
+ wl_pointer.enter being in the same wl_pointer.frame.
+ Compositor-specific policies may require the wl_pointer.leave and
+ wl_pointer.enter event being split across multiple wl_pointer.frame
+ groups.
+ </description>
+ </event>
+
+ <enum name="axis_source">
+ <description summary="axis source types">
+ Describes the source types for axis events. This indicates to the
+ client how an axis event was physically generated; a client may
+ adjust the user interface accordingly. For example, scroll events
+ from a "finger" source may be in a smooth coordinate space with
+ kinetic scrolling whereas a "wheel" source may be in discrete steps
+ of a number of lines.
+
+ The "continuous" axis source is a device generating events in a
+ continuous coordinate space, but using something other than a
+ finger. One example for this source is button-based scrolling where
+ the vertical motion of a device is converted to scroll events while
+ a button is held down.
+ </description>
+ <entry name="wheel" value="0" summary="A physical wheel" />
+ <entry name="finger" value="1" summary="Finger on a touch surface" />
+ <entry name="continuous" value="2" summary="Continuous coordinate space"/>
+ </enum>
+
+ <event name="axis_source" since="5">
+ <description summary="axis source event">
+ Source information for scroll and other axes.
+
+ This event does not occur on its own. It is sent before a
+ wl_pointer.frame event and carries the source information for
+ all events within that frame.
+
+ The source specifies how this event was generated. If the source is
+ wl_pointer.axis_source.finger, a wl_pointer.axis_stop event will be
+ sent when the user lifts the finger off the device.
+
+ If the source is wl_pointer axis_source.wheel or
+ wl_pointer.axis_source.continuous, a wl_pointer.axis_stop event may
+ or may not be sent. Whether a compositor sends a axis_stop event
+ for these sources is hardware-specific and implementation-dependent;
+ clients must not rely on receiving an axis_stop event for these
+ scroll sources and should treat scroll sequences from these scroll
+ sources as unterminated by default.
+
+ This event is optional. If the source is unknown for a particular
+ axis event sequence, no event is sent.
+ Only one wl_pointer.axis_source event is permitted per frame.
+
+ The order of wl_pointer.axis_discrete and wl_pointer.axis_source is
+ not guaranteed.
+ </description>
+ <arg name="axis_source" type="uint" enum="axis_source"/>
+ </event>
+
+ <event name="axis_stop" since="5">
+ <description summary="axis stop event">
+ Stop notification for scroll and other axes.
+
+ For some wl_pointer.axis_source types, a wl_pointer.axis_stop event
+ is sent to notify a client that the axis sequence has terminated.
+ This enables the client to implement kinetic scrolling.
+ See the wl_pointer.axis_source documentation for information on when
+ this event may be generated.
+
+ Any wl_pointer.axis events with the same axis_source after this
+ event should be considered as the start of a new axis motion.
+
+ The timestamp is to be interpreted identical to the timestamp in the
+ wl_pointer.axis event. The timestamp value may be the same as a
+ preceeding wl_pointer.axis event.
+ </description>
+ <arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
+ <arg name="axis" type="uint" enum="axis" summary="the axis stopped with this event"/>
+ </event>
+
+ <event name="axis_discrete" since="5">
+ <description summary="axis click event">
+ Discrete step information for scroll and other axes.
+
+ This event carries the axis value of the wl_pointer.axis event in
+ discrete steps (e.g. mouse wheel clicks).
+
+ This event does not occur on its own, it is coupled with a
+ wl_pointer.axis event that represents this axis value on a
+ continuous scale. The protocol guarantees that each axis_discrete
+ event is always followed by exactly one axis event with the same
+ axis number within the same wl_pointer.frame. Note that the protocol
+ allows for other events to occur between the axis_discrete and
+ its coupled axis event, including other axis_discrete or axis
+ events.
+
+ This event is optional; continuous scrolling devices
+ like two-finger scrolling on touchpads do not have discrete
+ steps and do not generate this event.
+
+ The discrete value carries the directional information. e.g. a value
+ of -2 is two steps towards the negative direction of this axis.
+
+ The axis number is identical to the axis number in the associate
+ axis event.
+
+ The order of wl_pointer.axis_discrete and wl_pointer.axis_source is
+ not guaranteed.
+ </description>
+ <arg name="axis" type="uint" enum="axis" />
+ <arg name="discrete" type="int"/>
+ </event>
</interface>
- <interface name="wl_keyboard" version="4">
+ <interface name="wl_keyboard" version="5">
<description summary="keyboard input device">
The wl_keyboard interface represents one or more keyboards
associated with a seat.
@@ -1527,7 +2100,7 @@
This event provides a file descriptor to the client which can be
memory-mapped to provide a keyboard mapping description.
</description>
- <arg name="format" type="uint"/>
+ <arg name="format" type="uint" enum="keymap_format"/>
<arg name="fd" type="fd"/>
<arg name="size" type="uint"/>
</event>
@@ -1572,7 +2145,7 @@
<arg name="serial" type="uint"/>
<arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
<arg name="key" type="uint"/>
- <arg name="state" type="uint"/>
+ <arg name="state" type="uint" enum="key_state"/>
</event>
<event name="modifiers">
@@ -1619,7 +2192,7 @@
</event>
</interface>
- <interface name="wl_touch" version="3">
+ <interface name="wl_touch" version="5">
<description summary="touchscreen input device">
The wl_touch interface represents a touchscreen
associated with a seat.
@@ -1704,7 +2277,7 @@
<enum name="subpixel">
<description summary="subpixel geometry information">
This enumeration describes how the physical
- pixels on an output are layed out.
+ pixels on an output are laid out.
</description>
<entry name="unknown" value="0"/>
<entry name="none" value="1"/>
@@ -1753,17 +2326,17 @@
summary="width in millimeters of the output"/>
<arg name="physical_height" type="int"
summary="height in millimeters of the output"/>
- <arg name="subpixel" type="int"
+ <arg name="subpixel" type="int" enum="subpixel"
summary="subpixel orientation of the output"/>
<arg name="make" type="string"
summary="textual description of the manufacturer"/>
<arg name="model" type="string"
summary="textual description of the model"/>
- <arg name="transform" type="int"
+ <arg name="transform" type="int" enum="transform"
summary="transform that maps framebuffer to output"/>
</event>
- <enum name="mode">
+ <enum name="mode" bitfield="true">
<description summary="mode information">
These flags describe properties of an output mode.
They are used in the flags bitfield of the mode event.
@@ -1790,7 +2363,7 @@
the output may be scaled, as described in wl_output.scale,
or transformed , as described in wl_output.transform.
</description>
- <arg name="flags" type="uint" summary="bitfield of mode flags"/>
+ <arg name="flags" type="uint" enum="mode" summary="bitfield of mode flags"/>
<arg name="width" type="int" summary="width of the mode in hardware units"/>
<arg name="height" type="int" summary="height of the mode in hardware units"/>
<arg name="refresh" type="int" summary="vertical refresh rate in mHz"/>
@@ -1911,9 +2484,9 @@
associate it with the given parent surface. This turns a
plain wl_surface into a sub-surface.
- The to-be sub-surface must not already have a dedicated
- purpose, like any shell surface type, cursor image, drag icon,
- or sub-surface. Otherwise a protocol error is raised.
+ The to-be sub-surface must not already have another role, and it
+ must not have an existing wl_subsurface object. Otherwise a protocol
+ error is raised.
</description>
<arg name="id" type="new_id" interface="wl_subsurface"
@@ -2001,8 +2574,10 @@
coordinate system. The coordinates are not restricted to the parent
surface area. Negative values are allowed.
- The next wl_surface.commit on the parent surface will reset
- the sub-surface's position to the scheduled coordinates.
+ The scheduled coordinates will take effect whenever the state of the
+ parent surface is applied. When this happens depends on whether the
+ parent surface is in synchronized mode or not. See
+ wl_subsurface.set_sync and wl_subsurface.set_desync for details.
If more than one set_position request is invoked by the client before
the commit of the parent surface, the position of a new request always
@@ -2024,9 +2599,11 @@
will cause a protocol error.
The z-order is double-buffered. Requests are handled in order and
- applied immediately to a pending state, then committed to the active
- state on the next commit of the parent surface.
- See wl_surface.commit and wl_subcompositor.get_subsurface.
+ applied immediately to a pending state. The final pending state is
+ copied to the active state the next time the state of the parent
+ surface is applied. When this happens depends on whether the parent
+ surface is in synchronized mode or not. See wl_subsurface.set_sync and
+ wl_subsurface.set_desync for details.
A new sub-surface is initially added as the top-most in the stack
of its siblings and parent.
@@ -2049,7 +2626,7 @@
<request name="set_sync">
<description summary="set sub-surface to synchronized mode">
Change the commit behaviour of the sub-surface to synchronized
- mode, also described as the parent dependant mode.
+ mode, also described as the parent dependent mode.
In synchronized mode, wl_surface.commit on a sub-surface will
accumulate the committed state in a cache, but the state will
diff --git a/src/3rdparty/protocol/xdg-decoration-unstable-v1.xml b/src/3rdparty/protocol/xdg-decoration-unstable-v1.xml
new file mode 100644
index 000000000..378e8ff4b
--- /dev/null
+++ b/src/3rdparty/protocol/xdg-decoration-unstable-v1.xml
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="xdg_decoration_unstable_v1">
+ <copyright>
+ Copyright © 2018 Simon Ser
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ </copyright>
+
+ <interface name="zxdg_decoration_manager_v1" version="1">
+ <description summary="window decoration manager">
+ This interface allows a compositor to announce support for server-side
+ decorations.
+
+ A window decoration is a set of window controls as deemed appropriate by
+ the party managing them, such as user interface components used to move,
+ resize and change a window's state.
+
+ A client can use this protocol to request being decorated by a supporting
+ compositor.
+
+ If compositor and client do not negotiate the use of a server-side
+ decoration using this protocol, clients continue to self-decorate as they
+ see fit.
+
+ Warning! The protocol described in this file is experimental and
+ backward incompatible changes may be made. Backward compatible changes
+ may be added together with the corresponding interface version bump.
+ Backward incompatible changes are done by bumping the version number in
+ the protocol and interface names and resetting the interface version.
+ Once the protocol is to be declared stable, the 'z' prefix and the
+ version number in the protocol and interface names are removed and the
+ interface version number is reset.
+ </description>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy the decoration manager object">
+ Destroy the decoration manager. This doesn't destroy objects created
+ with the manager.
+ </description>
+ </request>
+
+ <request name="get_toplevel_decoration">
+ <description summary="create a new toplevel decoration object">
+ Create a new decoration object associated with the given toplevel.
+
+ Creating an xdg_toplevel_decoration from an xdg_toplevel which has a
+ buffer attached or committed is a client error, and any attempts by a
+ client to attach or manipulate a buffer prior to the first
+ xdg_toplevel_decoration.configure event must also be treated as
+ errors.
+ </description>
+ <arg name="id" type="new_id" interface="zxdg_toplevel_decoration_v1"/>
+ <arg name="toplevel" type="object" interface="xdg_toplevel"/>
+ </request>
+ </interface>
+
+ <interface name="zxdg_toplevel_decoration_v1" version="1">
+ <description summary="decoration object for a toplevel surface">
+ The decoration object allows the compositor to toggle server-side window
+ decorations for a toplevel surface. The client can request to switch to
+ another mode.
+
+ The xdg_toplevel_decoration object must be destroyed before its
+ xdg_toplevel.
+ </description>
+
+ <enum name="error">
+ <entry name="unconfigured_buffer" value="0"
+ summary="xdg_toplevel has a buffer attached before configure"/>
+ <entry name="already_constructed" value="1"
+ summary="xdg_toplevel already has a decoration object"/>
+ <entry name="orphaned" value="2"
+ summary="xdg_toplevel destroyed before the decoration object"/>
+ </enum>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy the decoration object">
+ Switch back to a mode without any server-side decorations at the next
+ commit.
+ </description>
+ </request>
+
+ <enum name="mode">
+ <description summary="window decoration modes">
+ These values describe window decoration modes.
+ </description>
+ <entry name="client_side" value="1"
+ summary="no server-side window decoration"/>
+ <entry name="server_side" value="2"
+ summary="server-side window decoration"/>
+ </enum>
+
+ <request name="set_mode">
+ <description summary="set the decoration mode">
+ Set the toplevel surface decoration mode. This informs the compositor
+ that the client prefers the provided decoration mode.
+
+ After requesting a decoration mode, the compositor will respond by
+ emitting a xdg_surface.configure event. The client should then update
+ its content, drawing it without decorations if the received mode is
+ server-side decorations. The client must also acknowledge the configure
+ when committing the new content (see xdg_surface.ack_configure).
+
+ The compositor can decide not to use the client's mode and enforce a
+ different mode instead.
+
+ Clients whose decoration mode depend on the xdg_toplevel state may send
+ a set_mode request in response to a xdg_surface.configure event and wait
+ for the next xdg_surface.configure event to prevent unwanted state.
+ Such clients are responsible for preventing configure loops and must
+ make sure not to send multiple successive set_mode requests with the
+ same decoration mode.
+ </description>
+ <arg name="mode" type="uint" enum="mode" summary="the decoration mode"/>
+ </request>
+
+ <request name="unset_mode">
+ <description summary="unset the decoration mode">
+ Unset the toplevel surface decoration mode. This informs the compositor
+ that the client doesn't prefer a particular decoration mode.
+
+ This request has the same semantics as set_mode.
+ </description>
+ </request>
+
+ <event name="configure">
+ <description summary="suggest a surface change">
+ The configure event asks the client to change its decoration mode. The
+ configured state should not be applied immediately. Clients must send an
+ ack_configure in response to this event. See xdg_surface.configure and
+ xdg_surface.ack_configure for details.
+
+ A configure event can be sent at any time. The specified mode must be
+ obeyed by the client.
+ </description>
+ <arg name="mode" type="uint" enum="mode" summary="the decoration mode"/>
+ </event>
+ </interface>
+</protocol>
diff --git a/src/3rdparty/protocol/xdg-output-unstable-v1.xml b/src/3rdparty/protocol/xdg-output-unstable-v1.xml
new file mode 100644
index 000000000..ccbfe1c9a
--- /dev/null
+++ b/src/3rdparty/protocol/xdg-output-unstable-v1.xml
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="xdg_output_unstable_v1">
+
+ <copyright>
+ Copyright © 2017 Red Hat Inc.
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ </copyright>
+
+ <description summary="Protocol to describe output regions">
+ This protocol aims at describing outputs in a way which is more in line
+ with the concept of an output on desktop oriented systems.
+
+ Some information are more specific to the concept of an output for
+ a desktop oriented system and may not make sense in other applications,
+ such as IVI systems for example.
+
+ Typically, the global compositor space on a desktop system is made of
+ a contiguous or overlapping set of rectangular regions.
+
+ Some of the information provided in this protocol might be identical
+ to their counterparts already available from wl_output, in which case
+ the information provided by this protocol should be preferred to their
+ equivalent in wl_output. The goal is to move the desktop specific
+ concepts (such as output location within the global compositor space,
+ the connector name and types, etc.) out of the core wl_output protocol.
+
+ Warning! The protocol described in this file is experimental and
+ backward incompatible changes may be made. Backward compatible
+ changes may be added together with the corresponding interface
+ version bump.
+ Backward incompatible changes are done by bumping the version
+ number in the protocol and interface names and resetting the
+ interface version. Once the protocol is to be declared stable,
+ the 'z' prefix and the version number in the protocol and
+ interface names are removed and the interface version number is
+ reset.
+ </description>
+
+ <interface name="zxdg_output_manager_v1" version="2">
+ <description summary="manage xdg_output objects">
+ A global factory interface for xdg_output objects.
+ </description>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy the xdg_output_manager object">
+ Using this request a client can tell the server that it is not
+ going to use the xdg_output_manager object anymore.
+
+ Any objects already created through this instance are not affected.
+ </description>
+ </request>
+
+ <request name="get_xdg_output">
+ <description summary="create an xdg output from a wl_output">
+ This creates a new xdg_output object for the given wl_output.
+ </description>
+ <arg name="id" type="new_id" interface="zxdg_output_v1"/>
+ <arg name="output" type="object" interface="wl_output"/>
+ </request>
+ </interface>
+
+ <interface name="zxdg_output_v1" version="2">
+ <description summary="compositor logical output region">
+ An xdg_output describes part of the compositor geometry.
+
+ This typically corresponds to a monitor that displays part of the
+ compositor space.
+ </description>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy the xdg_output object">
+ Using this request a client can tell the server that it is not
+ going to use the xdg_output object anymore.
+ </description>
+ </request>
+
+ <event name="logical_position">
+ <description summary="position of the output within the global compositor space">
+ The position event describes the location of the wl_output within
+ the global compositor space.
+
+ The logical_position event is sent after creating an xdg_output
+ (see xdg_output_manager.get_xdg_output) and whenever the location
+ of the output changes within the global compositor space.
+ </description>
+ <arg name="x" type="int"
+ summary="x position within the global compositor space"/>
+ <arg name="y" type="int"
+ summary="y position within the global compositor space"/>
+ </event>
+
+ <event name="logical_size">
+ <description summary="size of the output in the global compositor space">
+ The logical_size event describes the size of the output in the
+ global compositor space.
+
+ For example, a surface without any buffer scale, transformation
+ nor rotation set, with the size matching the logical_size will
+ have the same size as the corresponding output when displayed.
+
+ Most regular Wayland clients should not pay attention to the
+ logical size and would rather rely on xdg_shell interfaces.
+
+ Some clients such as Xwayland, however, need this to configure
+ their surfaces in the global compositor space as the compositor
+ may apply a different scale from what is advertised by the output
+ scaling property (to achieve fractional scaling, for example).
+
+ For example, for a wl_output mode 3840×2160 and a scale factor 2:
+
+ - A compositor not scaling the surface buffers will advertise a
+ logical size of 3840×2160,
+
+ - A compositor automatically scaling the surface buffers will
+ advertise a logical size of 1920×1080,
+
+ - A compositor using a fractional scale of 1.5 will advertise a
+ logical size to 2560×1620.
+
+ For example, for a wl_output mode 1920×1080 and a 90 degree rotation,
+ the compositor will advertise a logical size of 1080x1920.
+
+ The logical_size event is sent after creating an xdg_output
+ (see xdg_output_manager.get_xdg_output) and whenever the logical
+ size of the output changes, either as a result of a change in the
+ applied scale or because of a change in the corresponding output
+ mode(see wl_output.mode) or transform (see wl_output.transform).
+ </description>
+ <arg name="width" type="int"
+ summary="width in global compositor space"/>
+ <arg name="height" type="int"
+ summary="height in global compositor space"/>
+ </event>
+
+ <event name="done">
+ <description summary="all information about the output have been sent">
+ This event is sent after all other properties of an xdg_output
+ have been sent.
+
+ This allows changes to the xdg_output properties to be seen as
+ atomic, even if they happen via multiple events.
+ </description>
+ </event>
+
+ <!-- Version 2 additions -->
+
+ <event name="name" since="2">
+ <description summary="name of this output">
+ Many compositors will assign names to their outputs, show them to the
+ user, allow them to be configured by name, etc. The client may wish to
+ know this name as well to offer the user similar behaviors.
+
+ The naming convention is compositor defined, but limited to
+ alphanumeric characters and dashes (-). Each name is unique among all
+ wl_output globals, but if a wl_output global is destroyed the same name
+ may be reused later. The names will also remain consistent across
+ sessions with the same hardware and software configuration.
+
+ Examples of names include 'HDMI-A-1', 'WL-1', 'X11-1', etc. However, do
+ not assume that the name is a reflection of an underlying DRM
+ connector, X11 connection, etc.
+
+ The name event is sent after creating an xdg_output (see
+ xdg_output_manager.get_xdg_output). This event is only sent once per
+ xdg_output, and the name does not change over the lifetime of the
+ wl_output global.
+ </description>
+ <arg name="name" type="string" summary="output name"/>
+ </event>
+
+ <event name="description" since="2">
+ <description summary="human-readable description of this output">
+ Many compositors can produce human-readable descriptions of their
+ outputs. The client may wish to know this description as well, to
+ communicate the user for various purposes.
+
+ The description is a UTF-8 string with no convention defined for its
+ contents. Examples might include 'Foocorp 11" Display' or 'Virtual X11
+ output via :1'.
+
+ The description event is sent after creating an xdg_output (see
+ xdg_output_manager.get_xdg_output). This event is only sent once per
+ xdg_output, and the description does not change over the lifetime of
+ the wl_output global. The description is optional, and may not be sent
+ at all.
+ </description>
+ <arg name="description" type="string" summary="output description"/>
+ </event>
+
+ </interface>
+</protocol>
diff --git a/src/3rdparty/protocol/xdg-shell-unstable-v5.xml b/src/3rdparty/protocol/xdg-shell-unstable-v5.xml
new file mode 100644
index 000000000..89c9d58c5
--- /dev/null
+++ b/src/3rdparty/protocol/xdg-shell-unstable-v5.xml
@@ -0,0 +1,608 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="xdg_shell_unstable_v5">
+
+ <copyright>
+ Copyright © 2008-2013 Kristian Høgsberg
+ Copyright © 2013 Rafael Antognolli
+ Copyright © 2013 Jasper St. Pierre
+ Copyright © 2010-2013 Intel Corporation
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ </copyright>
+
+ <interface name="xdg_shell" version="1">
+ <description summary="create desktop-style surfaces">
+ xdg_shell allows clients to turn a wl_surface into a "real window"
+ which can be dragged, resized, stacked, and moved around by the
+ user. Everything about this interface is suited towards traditional
+ desktop environments.
+ </description>
+
+ <enum name="version">
+ <description summary="latest protocol version">
+ The 'current' member of this enum gives the version of the
+ protocol. Implementations can compare this to the version
+ they implement using static_assert to ensure the protocol and
+ implementation versions match.
+ </description>
+ <entry name="current" value="5" summary="Always the latest version"/>
+ </enum>
+
+ <enum name="error">
+ <entry name="role" value="0" summary="given wl_surface has another role"/>
+ <entry name="defunct_surfaces" value="1" summary="xdg_shell was destroyed before children"/>
+ <entry name="not_the_topmost_popup" value="2" summary="the client tried to map or destroy a non-topmost popup"/>
+ <entry name="invalid_popup_parent" value="3" summary="the client specified an invalid popup parent surface"/>
+ </enum>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy xdg_shell">
+ Destroy this xdg_shell object.
+
+ Destroying a bound xdg_shell object while there are surfaces
+ still alive created by this xdg_shell object instance is illegal
+ and will result in a protocol error.
+ </description>
+ </request>
+
+ <request name="use_unstable_version">
+ <description summary="enable use of this unstable version">
+ Negotiate the unstable version of the interface. This
+ mechanism is in place to ensure client and server agree on the
+ unstable versions of the protocol that they speak or exit
+ cleanly if they don't agree. This request will go away once
+ the xdg-shell protocol is stable.
+ </description>
+ <arg name="version" type="int"/>
+ </request>
+
+ <request name="get_xdg_surface">
+ <description summary="create a shell surface from a surface">
+ This creates an xdg_surface for the given surface and gives it the
+ xdg_surface role. A wl_surface can only be given an xdg_surface role
+ once. If get_xdg_surface is called with a wl_surface that already has
+ an active xdg_surface associated with it, or if it had any other role,
+ an error is raised.
+
+ See the documentation of xdg_surface for more details about what an
+ xdg_surface is and how it is used.
+ </description>
+ <arg name="id" type="new_id" interface="xdg_surface"/>
+ <arg name="surface" type="object" interface="wl_surface"/>
+ </request>
+
+ <request name="get_xdg_popup">
+ <description summary="create a popup for a surface">
+ This creates an xdg_popup for the given surface and gives it the
+ xdg_popup role. A wl_surface can only be given an xdg_popup role
+ once. If get_xdg_popup is called with a wl_surface that already has
+ an active xdg_popup associated with it, or if it had any other role,
+ an error is raised.
+
+ This request must be used in response to some sort of user action
+ like a button press, key press, or touch down event.
+
+ See the documentation of xdg_popup for more details about what an
+ xdg_popup is and how it is used.
+ </description>
+ <arg name="id" type="new_id" interface="xdg_popup"/>
+ <arg name="surface" type="object" interface="wl_surface"/>
+ <arg name="parent" type="object" interface="wl_surface"/>
+ <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
+ <arg name="serial" type="uint" summary="the serial of the user event"/>
+ <arg name="x" type="int"/>
+ <arg name="y" type="int"/>
+ </request>
+
+ <event name="ping">
+ <description summary="check if the client is alive">
+ The ping event asks the client if it's still alive. Pass the
+ serial specified in the event back to the compositor by sending
+ a "pong" request back with the specified serial.
+
+ Compositors can use this to determine if the client is still
+ alive. It's unspecified what will happen if the client doesn't
+ respond to the ping request, or in what timeframe. Clients should
+ try to respond in a reasonable amount of time.
+
+ A compositor is free to ping in any way it wants, but a client must
+ always respond to any xdg_shell object it created.
+ </description>
+ <arg name="serial" type="uint" summary="pass this to the pong request"/>
+ </event>
+
+ <request name="pong">
+ <description summary="respond to a ping event">
+ A client must respond to a ping event with a pong request or
+ the client may be deemed unresponsive.
+ </description>
+ <arg name="serial" type="uint" summary="serial of the ping event"/>
+ </request>
+ </interface>
+
+ <interface name="xdg_surface" version="1">
+ <description summary="A desktop window">
+ An interface that may be implemented by a wl_surface, for
+ implementations that provide a desktop-style user interface.
+
+ It provides requests to treat surfaces like windows, allowing to set
+ properties like maximized, fullscreen, minimized, and to move and resize
+ them, and associate metadata like title and app id.
+
+ The client must call wl_surface.commit on the corresponding wl_surface
+ for the xdg_surface state to take effect. Prior to committing the new
+ state, it can set up initial configuration, such as maximizing or setting
+ a window geometry.
+
+ Even without attaching a buffer the compositor must respond to initial
+ committed configuration, for instance sending a configure event with
+ expected window geometry if the client maximized its surface during
+ initialization.
+
+ For a surface to be mapped by the compositor the client must have
+ committed both an xdg_surface state and a buffer.
+ </description>
+
+ <request name="destroy" type="destructor">
+ <description summary="Destroy the xdg_surface">
+ Unmap and destroy the window. The window will be effectively
+ hidden from the user's point of view, and all state like
+ maximization, fullscreen, and so on, will be lost.
+ </description>
+ </request>
+
+ <request name="set_parent">
+ <description summary="set the parent of this surface">
+ Set the "parent" of this surface. This window should be stacked
+ above a parent. The parent surface must be mapped as long as this
+ surface is mapped.
+
+ Parent windows should be set on dialogs, toolboxes, or other
+ "auxiliary" surfaces, so that the parent is raised when the dialog
+ is raised.
+ </description>
+ <arg name="parent" type="object" interface="xdg_surface" allow-null="true"/>
+ </request>
+
+ <request name="set_title">
+ <description summary="set surface title">
+ Set a short title for the surface.
+
+ This string may be used to identify the surface in a task bar,
+ window list, or other user interface elements provided by the
+ compositor.
+
+ The string must be encoded in UTF-8.
+ </description>
+ <arg name="title" type="string"/>
+ </request>
+
+ <request name="set_app_id">
+ <description summary="set application ID">
+ Set an application identifier for the surface.
+
+ The app ID identifies the general class of applications to which
+ the surface belongs. The compositor can use this to group multiple
+ surfaces together, or to determine how to launch a new application.
+
+ For D-Bus activatable applications, the app ID is used as the D-Bus
+ service name.
+
+ The compositor shell will try to group application surfaces together
+ by their app ID. As a best practice, it is suggested to select app
+ ID's that match the basename of the application's .desktop file.
+ For example, "org.freedesktop.FooViewer" where the .desktop file is
+ "org.freedesktop.FooViewer.desktop".
+
+ See the desktop-entry specification [0] for more details on
+ application identifiers and how they relate to well-known D-Bus
+ names and .desktop files.
+
+ [0] http://standards.freedesktop.org/desktop-entry-spec/
+ </description>
+ <arg name="app_id" type="string"/>
+ </request>
+
+ <request name="show_window_menu">
+ <description summary="show the window menu">
+ Clients implementing client-side decorations might want to show
+ a context menu when right-clicking on the decorations, giving the
+ user a menu that they can use to maximize or minimize the window.
+
+ This request asks the compositor to pop up such a window menu at
+ the given position, relative to the local surface coordinates of
+ the parent surface. There are no guarantees as to what menu items
+ the window menu contains.
+
+ This request must be used in response to some sort of user action
+ like a button press, key press, or touch down event.
+ </description>
+
+ <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
+ <arg name="serial" type="uint" summary="the serial of the user event"/>
+ <arg name="x" type="int" summary="the x position to pop up the window menu at"/>
+ <arg name="y" type="int" summary="the y position to pop up the window menu at"/>
+ </request>
+
+ <request name="move">
+ <description summary="start an interactive move">
+ Start an interactive, user-driven move of the surface.
+
+ This request must be used in response to some sort of user action
+ like a button press, key press, or touch down event. The passed
+ serial is used to determine the type of interactive move (touch,
+ pointer, etc).
+
+ The server may ignore move requests depending on the state of
+ the surface (e.g. fullscreen or maximized), or if the passed serial
+ is no longer valid.
+
+ If triggered, the surface will lose the focus of the device
+ (wl_pointer, wl_touch, etc) used for the move. It is up to the
+ compositor to visually indicate that the move is taking place, such as
+ updating a pointer cursor, during the move. There is no guarantee
+ that the device focus will return when the move is completed.
+ </description>
+ <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
+ <arg name="serial" type="uint" summary="the serial of the user event"/>
+ </request>
+
+ <enum name="resize_edge">
+ <description summary="edge values for resizing">
+ These values are used to indicate which edge of a surface
+ is being dragged in a resize operation.
+ </description>
+ <entry name="none" value="0"/>
+ <entry name="top" value="1"/>
+ <entry name="bottom" value="2"/>
+ <entry name="left" value="4"/>
+ <entry name="top_left" value="5"/>
+ <entry name="bottom_left" value="6"/>
+ <entry name="right" value="8"/>
+ <entry name="top_right" value="9"/>
+ <entry name="bottom_right" value="10"/>
+ </enum>
+
+ <request name="resize">
+ <description summary="start an interactive resize">
+ Start a user-driven, interactive resize of the surface.
+
+ This request must be used in response to some sort of user action
+ like a button press, key press, or touch down event. The passed
+ serial is used to determine the type of interactive resize (touch,
+ pointer, etc).
+
+ The server may ignore resize requests depending on the state of
+ the surface (e.g. fullscreen or maximized).
+
+ If triggered, the client will receive configure events with the
+ "resize" state enum value and the expected sizes. See the "resize"
+ enum value for more details about what is required. The client
+ must also acknowledge configure events using "ack_configure". After
+ the resize is completed, the client will receive another "configure"
+ event without the resize state.
+
+ If triggered, the surface also will lose the focus of the device
+ (wl_pointer, wl_touch, etc) used for the resize. It is up to the
+ compositor to visually indicate that the resize is taking place,
+ such as updating a pointer cursor, during the resize. There is no
+ guarantee that the device focus will return when the resize is
+ completed.
+
+ The edges parameter specifies how the surface should be resized,
+ and is one of the values of the resize_edge enum. The compositor
+ may use this information to update the surface position for
+ example when dragging the top left corner. The compositor may also
+ use this information to adapt its behavior, e.g. choose an
+ appropriate cursor image.
+ </description>
+ <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
+ <arg name="serial" type="uint" summary="the serial of the user event"/>
+ <arg name="edges" type="uint" summary="which edge or corner is being dragged"/>
+ </request>
+
+ <enum name="state">
+ <description summary="types of state on the surface">
+ The different state values used on the surface. This is designed for
+ state values like maximized, fullscreen. It is paired with the
+ configure event to ensure that both the client and the compositor
+ setting the state can be synchronized.
+
+ States set in this way are double-buffered. They will get applied on
+ the next commit.
+
+ Desktop environments may extend this enum by taking up a range of
+ values and documenting the range they chose in this description.
+ They are not required to document the values for the range that they
+ chose. Ideally, any good extensions from a desktop environment should
+ make its way into standardization into this enum.
+
+ The current reserved ranges are:
+
+ 0x0000 - 0x0FFF: xdg-shell core values, documented below.
+ 0x1000 - 0x1FFF: GNOME
+ </description>
+ <entry name="maximized" value="1" summary="the surface is maximized">
+ The surface is maximized. The window geometry specified in the configure
+ event must be obeyed by the client.
+ </entry>
+ <entry name="fullscreen" value="2" summary="the surface is fullscreen">
+ The surface is fullscreen. The window geometry specified in the configure
+ event must be obeyed by the client.
+ </entry>
+ <entry name="resizing" value="3">
+ The surface is being resized. The window geometry specified in the
+ configure event is a maximum; the client cannot resize beyond it.
+ Clients that have aspect ratio or cell sizing configuration can use
+ a smaller size, however.
+ </entry>
+ <entry name="activated" value="4">
+ Client window decorations should be painted as if the window is
+ active. Do not assume this means that the window actually has
+ keyboard or pointer focus.
+ </entry>
+ </enum>
+
+ <event name="configure">
+ <description summary="suggest a surface change">
+ The configure event asks the client to resize its surface or to
+ change its state.
+
+ The width and height arguments specify a hint to the window
+ about how its surface should be resized in window geometry
+ coordinates. See set_window_geometry.
+
+ If the width or height arguments are zero, it means the client
+ should decide its own window dimension. This may happen when the
+ compositor need to configure the state of the surface but doesn't
+ have any information about any previous or expected dimension.
+
+ The states listed in the event specify how the width/height
+ arguments should be interpreted, and possibly how it should be
+ drawn.
+
+ Clients should arrange their surface for the new size and
+ states, and then send a ack_configure request with the serial
+ sent in this configure event at some point before committing
+ the new surface.
+
+ If the client receives multiple configure events before it
+ can respond to one, it is free to discard all but the last
+ event it received.
+ </description>
+
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ <arg name="states" type="array"/>
+ <arg name="serial" type="uint"/>
+ </event>
+
+ <request name="ack_configure">
+ <description summary="ack a configure event">
+ When a configure event is received, if a client commits the
+ surface in response to the configure event, then the client
+ must make a ack_configure request before the commit request,
+ passing along the serial of the configure event.
+
+ For instance, the compositor might use this information to move
+ a surface to the top left only when the client has drawn itself
+ for the maximized or fullscreen state.
+
+ If the client receives multiple configure events before it
+ can respond to one, it only has to ack the last configure event.
+ </description>
+ <arg name="serial" type="uint" summary="the serial from the configure event"/>
+ </request>
+
+ <request name="set_window_geometry">
+ <description summary="set the new window geometry">
+ The window geometry of a window is its "visible bounds" from the
+ user's perspective. Client-side decorations often have invisible
+ portions like drop-shadows which should be ignored for the
+ purposes of aligning, placing and constraining windows.
+
+ The window geometry is double buffered, and will be applied at the
+ time wl_surface.commit of the corresponding wl_surface is called.
+
+ Once the window geometry of the surface is set once, it is not
+ possible to unset it, and it will remain the same until
+ set_window_geometry is called again, even if a new subsurface or
+ buffer is attached.
+
+ If never set, the value is the full bounds of the surface,
+ including any subsurfaces. This updates dynamically on every
+ commit. This unset mode is meant for extremely simple clients.
+
+ If responding to a configure event, the window geometry in here
+ must respect the sizing negotiations specified by the states in
+ the configure event.
+
+ The arguments are given in the surface local coordinate space of
+ the wl_surface associated with this xdg_surface.
+
+ The width and height must be greater than zero.
+ </description>
+ <arg name="x" type="int"/>
+ <arg name="y" type="int"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </request>
+
+ <request name="set_maximized">
+ <description summary="maximize the window">
+ Maximize the surface.
+
+ After requesting that the surface should be maximized, the compositor
+ will respond by emitting a configure event with the "maximized" state
+ and the required window geometry. The client should then update its
+ content, drawing it in a maximized state, i.e. without shadow or other
+ decoration outside of the window geometry. The client must also
+ acknowledge the configure when committing the new content (see
+ ack_configure).
+
+ It is up to the compositor to decide how and where to maximize the
+ surface, for example which output and what region of the screen should
+ be used.
+
+ If the surface was already maximized, the compositor will still emit
+ a configure event with the "maximized" state.
+ </description>
+ </request>
+
+ <request name="unset_maximized">
+ <description summary="unmaximize the window">
+ Unmaximize the surface.
+
+ After requesting that the surface should be unmaximized, the compositor
+ will respond by emitting a configure event without the "maximized"
+ state. If available, the compositor will include the window geometry
+ dimensions the window had prior to being maximized in the configure
+ request. The client must then update its content, drawing it in a
+ regular state, i.e. potentially with shadow, etc. The client must also
+ acknowledge the configure when committing the new content (see
+ ack_configure).
+
+ It is up to the compositor to position the surface after it was
+ unmaximized; usually the position the surface had before maximizing, if
+ applicable.
+
+ If the surface was already not maximized, the compositor will still
+ emit a configure event without the "maximized" state.
+ </description>
+ </request>
+
+ <request name="set_fullscreen">
+ <description summary="set the window as fullscreen on a monitor">
+ Make the surface fullscreen.
+
+ You can specify an output that you would prefer to be fullscreen.
+ If this value is NULL, it's up to the compositor to choose which
+ display will be used to map this surface.
+
+ If the surface doesn't cover the whole output, the compositor will
+ position the surface in the center of the output and compensate with
+ black borders filling the rest of the output.
+ </description>
+ <arg name="output" type="object" interface="wl_output" allow-null="true"/>
+ </request>
+ <request name="unset_fullscreen" />
+
+ <request name="set_minimized">
+ <description summary="set the window as minimized">
+ Request that the compositor minimize your surface. There is no
+ way to know if the surface is currently minimized, nor is there
+ any way to unset minimization on this surface.
+
+ If you are looking to throttle redrawing when minimized, please
+ instead use the wl_surface.frame event for this, as this will
+ also work with live previews on windows in Alt-Tab, Expose or
+ similar compositor features.
+ </description>
+ </request>
+
+ <event name="close">
+ <description summary="surface wants to be closed">
+ The close event is sent by the compositor when the user
+ wants the surface to be closed. This should be equivalent to
+ the user clicking the close button in client-side decorations,
+ if your application has any...
+
+ This is only a request that the user intends to close your
+ window. The client may choose to ignore this request, or show
+ a dialog to ask the user to save their data...
+ </description>
+ </event>
+ </interface>
+
+ <interface name="xdg_popup" version="1">
+ <description summary="short-lived, popup surfaces for menus">
+ A popup surface is a short-lived, temporary surface that can be
+ used to implement menus. It takes an explicit grab on the surface
+ that will be dismissed when the user dismisses the popup. This can
+ be done by the user clicking outside the surface, using the keyboard,
+ or even locking the screen through closing the lid or a timeout.
+
+ When the popup is dismissed, a popup_done event will be sent out,
+ and at the same time the surface will be unmapped. The xdg_popup
+ object is now inert and cannot be reactivated, so clients should
+ destroy it. Explicitly destroying the xdg_popup object will also
+ dismiss the popup and unmap the surface.
+
+ Clients will receive events for all their surfaces during this
+ grab (which is an "owner-events" grab in X11 parlance). This is
+ done so that users can navigate through submenus and other
+ "nested" popup windows without having to dismiss the topmost
+ popup.
+
+ Clients that want to dismiss the popup when another surface of
+ their own is clicked should dismiss the popup using the destroy
+ request.
+
+ The parent surface must have either an xdg_surface or xdg_popup
+ role.
+
+ Specifying an xdg_popup for the parent means that the popups are
+ nested, with this popup now being the topmost popup. Nested
+ popups must be destroyed in the reverse order they were created
+ in, e.g. the only popup you are allowed to destroy at all times
+ is the topmost one.
+
+ If there is an existing popup when creating a new popup, the
+ parent must be the current topmost popup.
+
+ A parent surface must be mapped before the new popup is mapped.
+
+ When compositors choose to dismiss a popup, they will likely
+ dismiss every nested popup as well. When a compositor dismisses
+ popups, it will follow the same dismissing order as required
+ from the client.
+
+ The x and y arguments passed when creating the popup object specify
+ where the top left of the popup should be placed, relative to the
+ local surface coordinates of the parent surface. See
+ xdg_shell.get_xdg_popup.
+
+ The client must call wl_surface.commit on the corresponding wl_surface
+ for the xdg_popup state to take effect.
+
+ For a surface to be mapped by the compositor the client must have
+ committed both the xdg_popup state and a buffer.
+ </description>
+
+ <request name="destroy" type="destructor">
+ <description summary="remove xdg_popup interface">
+ This destroys the popup. Explicitly destroying the xdg_popup
+ object will also dismiss the popup, and unmap the surface.
+
+ If this xdg_popup is not the "topmost" popup, a protocol error
+ will be sent.
+ </description>
+ </request>
+
+ <event name="popup_done">
+ <description summary="popup interaction is done">
+ The popup_done event is sent out when a popup is dismissed by the
+ compositor. The client should destroy the xdg_popup object at this
+ point.
+ </description>
+ </event>
+
+ </interface>
+</protocol>
diff --git a/src/3rdparty/protocol/xdg-shell.xml b/src/3rdparty/protocol/xdg-shell.xml
index f98e760d4..d524ea9e2 100644
--- a/src/3rdparty/protocol/xdg-shell.xml
+++ b/src/3rdparty/protocol/xdg-shell.xml
@@ -6,6 +6,8 @@
Copyright © 2013 Rafael Antognolli
Copyright © 2013 Jasper St. Pierre
Copyright © 2010-2013 Intel Corporation
+ Copyright © 2015-2017 Samsung Electronics Co., Ltd
+ Copyright © 2015-2017 Red Hat Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@@ -27,59 +29,58 @@
DEALINGS IN THE SOFTWARE.
</copyright>
- <interface name="xdg_shell" version="1">
+ <interface name="xdg_wm_base" version="1">
<description summary="create desktop-style surfaces">
- xdg_shell allows clients to turn a wl_surface into a "real window"
- which can be dragged, resized, stacked, and moved around by the
- user. Everything about this interface is suited towards traditional
- desktop environments.
+ The xdg_wm_base interface is exposed as a global object enabling clients
+ to turn their wl_surfaces into windows in a desktop environment. It
+ defines the basic functionality needed for clients and the compositor to
+ create windows that can be dragged, resized, maximized, etc, as well as
+ creating transient windows such as popup menus.
</description>
- <enum name="version">
- <description summary="latest protocol version">
- The 'current' member of this enum gives the version of the
- protocol. Implementations can compare this to the version
- they implement using static_assert to ensure the protocol and
- implementation versions match.
- </description>
- <entry name="current" value="5" summary="Always the latest version"/>
- </enum>
-
<enum name="error">
<entry name="role" value="0" summary="given wl_surface has another role"/>
- <entry name="defunct_surfaces" value="1" summary="xdg_shell was destroyed before children"/>
- <entry name="not_the_topmost_popup" value="2" summary="the client tried to map or destroy a non-topmost popup"/>
- <entry name="invalid_popup_parent" value="3" summary="the client specified an invalid popup parent surface"/>
+ <entry name="defunct_surfaces" value="1"
+ summary="xdg_wm_base was destroyed before children"/>
+ <entry name="not_the_topmost_popup" value="2"
+ summary="the client tried to map or destroy a non-topmost popup"/>
+ <entry name="invalid_popup_parent" value="3"
+ summary="the client specified an invalid popup parent surface"/>
+ <entry name="invalid_surface_state" value="4"
+ summary="the client provided an invalid surface state"/>
+ <entry name="invalid_positioner" value="5"
+ summary="the client provided an invalid positioner"/>
</enum>
<request name="destroy" type="destructor">
- <description summary="destroy xdg_shell">
- Destroy this xdg_shell object.
+ <description summary="destroy xdg_wm_base">
+ Destroy this xdg_wm_base object.
- Destroying a bound xdg_shell object while there are surfaces
- still alive created by this xdg_shell object instance is illegal
- and will result in a protocol error.
+ Destroying a bound xdg_wm_base object while there are surfaces
+ still alive created by this xdg_wm_base object instance is illegal
+ and will result in a protocol error.
</description>
</request>
- <request name="use_unstable_version">
- <description summary="enable use of this unstable version">
- Negotiate the unstable version of the interface. This
- mechanism is in place to ensure client and server agree on the
- unstable versions of the protocol that they speak or exit
- cleanly if they don't agree. This request will go away once
- the xdg-shell protocol is stable.
+ <request name="create_positioner">
+ <description summary="create a positioner object">
+ Create a positioner object. A positioner object is used to position
+ surfaces relative to some parent surface. See the interface description
+ and xdg_surface.get_popup for details.
</description>
- <arg name="version" type="int"/>
+ <arg name="id" type="new_id" interface="xdg_positioner"/>
</request>
<request name="get_xdg_surface">
<description summary="create a shell surface from a surface">
- This creates an xdg_surface for the given surface and gives it the
- xdg_surface role. A wl_surface can only be given an xdg_surface role
- once. If get_xdg_surface is called with a wl_surface that already has
- an active xdg_surface associated with it, or if it had any other role,
- an error is raised.
+ This creates an xdg_surface for the given surface. While xdg_surface
+ itself is not a role, the corresponding surface may only be assigned
+ a role extending xdg_surface, such as xdg_toplevel or xdg_popup.
+
+ This creates an xdg_surface for the given surface. An xdg_surface is
+ used as basis to define a role to a given surface, such as xdg_toplevel
+ or xdg_popup. It also manages functionality shared between xdg_surface
+ based surface roles.
See the documentation of xdg_surface for more details about what an
xdg_surface is and how it is used.
@@ -88,97 +89,489 @@
<arg name="surface" type="object" interface="wl_surface"/>
</request>
- <request name="get_xdg_popup">
- <description summary="create a popup for a surface">
- This creates an xdg_popup for the given surface and gives it the
- xdg_popup role. A wl_surface can only be given an xdg_popup role
- once. If get_xdg_popup is called with a wl_surface that already has
- an active xdg_popup associated with it, or if it had any other role,
- an error is raised.
-
- This request must be used in response to some sort of user action
- like a button press, key press, or touch down event.
-
- See the documentation of xdg_popup for more details about what an
- xdg_popup is and how it is used.
+ <request name="pong">
+ <description summary="respond to a ping event">
+ A client must respond to a ping event with a pong request or
+ the client may be deemed unresponsive. See xdg_wm_base.ping.
</description>
- <arg name="id" type="new_id" interface="xdg_popup"/>
- <arg name="surface" type="object" interface="wl_surface"/>
- <arg name="parent" type="object" interface="wl_surface"/>
- <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
- <arg name="serial" type="uint" summary="the serial of the user event"/>
- <arg name="x" type="int"/>
- <arg name="y" type="int"/>
+ <arg name="serial" type="uint" summary="serial of the ping event"/>
</request>
<event name="ping">
<description summary="check if the client is alive">
- The ping event asks the client if it's still alive. Pass the
- serial specified in the event back to the compositor by sending
- a "pong" request back with the specified serial.
+ The ping event asks the client if it's still alive. Pass the
+ serial specified in the event back to the compositor by sending
+ a "pong" request back with the specified serial. See xdg_wm_base.ping.
- Compositors can use this to determine if the client is still
- alive. It's unspecified what will happen if the client doesn't
- respond to the ping request, or in what timeframe. Clients should
- try to respond in a reasonable amount of time.
+ Compositors can use this to determine if the client is still
+ alive. It's unspecified what will happen if the client doesn't
+ respond to the ping request, or in what timeframe. Clients should
+ try to respond in a reasonable amount of time.
- A compositor is free to ping in any way it wants, but a client must
- always respond to any xdg_shell object it created.
+ A compositor is free to ping in any way it wants, but a client must
+ always respond to any xdg_wm_base object it created.
</description>
<arg name="serial" type="uint" summary="pass this to the pong request"/>
</event>
+ </interface>
- <request name="pong">
- <description summary="respond to a ping event">
- A client must respond to a ping event with a pong request or
- the client may be deemed unresponsive.
+ <interface name="xdg_positioner" version="1">
+ <description summary="child surface positioner">
+ The xdg_positioner provides a collection of rules for the placement of a
+ child surface relative to a parent surface. Rules can be defined to ensure
+ the child surface remains within the visible area's borders, and to
+ specify how the child surface changes its position, such as sliding along
+ an axis, or flipping around a rectangle. These positioner-created rules are
+ constrained by the requirement that a child surface must intersect with or
+ be at least partially adjacent to its parent surface.
+
+ See the various requests for details about possible rules.
+
+ At the time of the request, the compositor makes a copy of the rules
+ specified by the xdg_positioner. Thus, after the request is complete the
+ xdg_positioner object can be destroyed or reused; further changes to the
+ object will have no effect on previous usages.
+
+ For an xdg_positioner object to be considered complete, it must have a
+ non-zero size set by set_size, and a non-zero anchor rectangle set by
+ set_anchor_rect. Passing an incomplete xdg_positioner object when
+ positioning a surface raises an error.
+ </description>
+
+ <enum name="error">
+ <entry name="invalid_input" value="0" summary="invalid input provided"/>
+ </enum>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy the xdg_positioner object">
+ Notify the compositor that the xdg_positioner will no longer be used.
</description>
- <arg name="serial" type="uint" summary="serial of the ping event"/>
+ </request>
+
+ <request name="set_size">
+ <description summary="set the size of the to-be positioned rectangle">
+ Set the size of the surface that is to be positioned with the positioner
+ object. The size is in surface-local coordinates and corresponds to the
+ window geometry. See xdg_surface.set_window_geometry.
+
+ If a zero or negative size is set the invalid_input error is raised.
+ </description>
+ <arg name="width" type="int" summary="width of positioned rectangle"/>
+ <arg name="height" type="int" summary="height of positioned rectangle"/>
+ </request>
+
+ <request name="set_anchor_rect">
+ <description summary="set the anchor rectangle within the parent surface">
+ Specify the anchor rectangle within the parent surface that the child
+ surface will be placed relative to. The rectangle is relative to the
+ window geometry as defined by xdg_surface.set_window_geometry of the
+ parent surface.
+
+ When the xdg_positioner object is used to position a child surface, the
+ anchor rectangle may not extend outside the window geometry of the
+ positioned child's parent surface.
+
+ If a negative size is set the invalid_input error is raised.
+ </description>
+ <arg name="x" type="int" summary="x position of anchor rectangle"/>
+ <arg name="y" type="int" summary="y position of anchor rectangle"/>
+ <arg name="width" type="int" summary="width of anchor rectangle"/>
+ <arg name="height" type="int" summary="height of anchor rectangle"/>
+ </request>
+
+ <enum name="anchor">
+ <entry name="none" value="0"/>
+ <entry name="top" value="1"/>
+ <entry name="bottom" value="2"/>
+ <entry name="left" value="3"/>
+ <entry name="right" value="4"/>
+ <entry name="top_left" value="5"/>
+ <entry name="bottom_left" value="6"/>
+ <entry name="top_right" value="7"/>
+ <entry name="bottom_right" value="8"/>
+ </enum>
+
+ <request name="set_anchor">
+ <description summary="set anchor rectangle anchor">
+ Defines the anchor point for the anchor rectangle. The specified anchor
+ is used derive an anchor point that the child surface will be
+ positioned relative to. If a corner anchor is set (e.g. 'top_left' or
+ 'bottom_right'), the anchor point will be at the specified corner;
+ otherwise, the derived anchor point will be centered on the specified
+ edge, or in the center of the anchor rectangle if no edge is specified.
+ </description>
+ <arg name="anchor" type="uint" enum="anchor"
+ summary="anchor"/>
+ </request>
+
+ <enum name="gravity">
+ <entry name="none" value="0"/>
+ <entry name="top" value="1"/>
+ <entry name="bottom" value="2"/>
+ <entry name="left" value="3"/>
+ <entry name="right" value="4"/>
+ <entry name="top_left" value="5"/>
+ <entry name="bottom_left" value="6"/>
+ <entry name="top_right" value="7"/>
+ <entry name="bottom_right" value="8"/>
+ </enum>
+
+ <request name="set_gravity">
+ <description summary="set child surface gravity">
+ Defines in what direction a surface should be positioned, relative to
+ the anchor point of the parent surface. If a corner gravity is
+ specified (e.g. 'bottom_right' or 'top_left'), then the child surface
+ will be placed towards the specified gravity; otherwise, the child
+ surface will be centered over the anchor point on any axis that had no
+ gravity specified.
+ </description>
+ <arg name="gravity" type="uint" enum="gravity"
+ summary="gravity direction"/>
+ </request>
+
+ <enum name="constraint_adjustment" bitfield="true">
+ <description summary="constraint adjustments">
+ The constraint adjustment value define ways the compositor will adjust
+ the position of the surface, if the unadjusted position would result
+ in the surface being partly constrained.
+
+ Whether a surface is considered 'constrained' is left to the compositor
+ to determine. For example, the surface may be partly outside the
+ compositor's defined 'work area', thus necessitating the child surface's
+ position be adjusted until it is entirely inside the work area.
+
+ The adjustments can be combined, according to a defined precedence: 1)
+ Flip, 2) Slide, 3) Resize.
+ </description>
+ <entry name="none" value="0">
+ <description summary="don't move the child surface when constrained">
+ Don't alter the surface position even if it is constrained on some
+ axis, for example partially outside the edge of an output.
+ </description>
+ </entry>
+ <entry name="slide_x" value="1">
+ <description summary="move along the x axis until unconstrained">
+ Slide the surface along the x axis until it is no longer constrained.
+
+ First try to slide towards the direction of the gravity on the x axis
+ until either the edge in the opposite direction of the gravity is
+ unconstrained or the edge in the direction of the gravity is
+ constrained.
+
+ Then try to slide towards the opposite direction of the gravity on the
+ x axis until either the edge in the direction of the gravity is
+ unconstrained or the edge in the opposite direction of the gravity is
+ constrained.
+ </description>
+ </entry>
+ <entry name="slide_y" value="2">
+ <description summary="move along the y axis until unconstrained">
+ Slide the surface along the y axis until it is no longer constrained.
+
+ First try to slide towards the direction of the gravity on the y axis
+ until either the edge in the opposite direction of the gravity is
+ unconstrained or the edge in the direction of the gravity is
+ constrained.
+
+ Then try to slide towards the opposite direction of the gravity on the
+ y axis until either the edge in the direction of the gravity is
+ unconstrained or the edge in the opposite direction of the gravity is
+ constrained.
+ </description>
+ </entry>
+ <entry name="flip_x" value="4">
+ <description summary="invert the anchor and gravity on the x axis">
+ Invert the anchor and gravity on the x axis if the surface is
+ constrained on the x axis. For example, if the left edge of the
+ surface is constrained, the gravity is 'left' and the anchor is
+ 'left', change the gravity to 'right' and the anchor to 'right'.
+
+ If the adjusted position also ends up being constrained, the resulting
+ position of the flip_x adjustment will be the one before the
+ adjustment.
+ </description>
+ </entry>
+ <entry name="flip_y" value="8">
+ <description summary="invert the anchor and gravity on the y axis">
+ Invert the anchor and gravity on the y axis if the surface is
+ constrained on the y axis. For example, if the bottom edge of the
+ surface is constrained, the gravity is 'bottom' and the anchor is
+ 'bottom', change the gravity to 'top' and the anchor to 'top'.
+
+ The adjusted position is calculated given the original anchor
+ rectangle and offset, but with the new flipped anchor and gravity
+ values.
+
+ If the adjusted position also ends up being constrained, the resulting
+ position of the flip_y adjustment will be the one before the
+ adjustment.
+ </description>
+ </entry>
+ <entry name="resize_x" value="16">
+ <description summary="horizontally resize the surface">
+ Resize the surface horizontally so that it is completely
+ unconstrained.
+ </description>
+ </entry>
+ <entry name="resize_y" value="32">
+ <description summary="vertically resize the surface">
+ Resize the surface vertically so that it is completely unconstrained.
+ </description>
+ </entry>
+ </enum>
+
+ <request name="set_constraint_adjustment">
+ <description summary="set the adjustment to be done when constrained">
+ Specify how the window should be positioned if the originally intended
+ position caused the surface to be constrained, meaning at least
+ partially outside positioning boundaries set by the compositor. The
+ adjustment is set by constructing a bitmask describing the adjustment to
+ be made when the surface is constrained on that axis.
+
+ If no bit for one axis is set, the compositor will assume that the child
+ surface should not change its position on that axis when constrained.
+
+ If more than one bit for one axis is set, the order of how adjustments
+ are applied is specified in the corresponding adjustment descriptions.
+
+ The default adjustment is none.
+ </description>
+ <arg name="constraint_adjustment" type="uint"
+ summary="bit mask of constraint adjustments"/>
+ </request>
+
+ <request name="set_offset">
+ <description summary="set surface position offset">
+ Specify the surface position offset relative to the position of the
+ anchor on the anchor rectangle and the anchor on the surface. For
+ example if the anchor of the anchor rectangle is at (x, y), the surface
+ has the gravity bottom|right, and the offset is (ox, oy), the calculated
+ surface position will be (x + ox, y + oy). The offset position of the
+ surface is the one used for constraint testing. See
+ set_constraint_adjustment.
+
+ An example use case is placing a popup menu on top of a user interface
+ element, while aligning the user interface element of the parent surface
+ with some user interface element placed somewhere in the popup surface.
+ </description>
+ <arg name="x" type="int" summary="surface position x offset"/>
+ <arg name="y" type="int" summary="surface position y offset"/>
</request>
</interface>
<interface name="xdg_surface" version="1">
- <description summary="A desktop window">
+ <description summary="desktop user interface surface base interface">
An interface that may be implemented by a wl_surface, for
implementations that provide a desktop-style user interface.
- It provides requests to treat surfaces like windows, allowing to set
- properties like maximized, fullscreen, minimized, and to move and resize
- them, and associate metadata like title and app id.
+ It provides a base set of functionality required to construct user
+ interface elements requiring management by the compositor, such as
+ toplevel windows, menus, etc. The types of functionality are split into
+ xdg_surface roles.
+
+ Creating an xdg_surface does not set the role for a wl_surface. In order
+ to map an xdg_surface, the client must create a role-specific object
+ using, e.g., get_toplevel, get_popup. The wl_surface for any given
+ xdg_surface can have at most one role, and may not be assigned any role
+ not based on xdg_surface.
+
+ A role must be assigned before any other requests are made to the
+ xdg_surface object.
The client must call wl_surface.commit on the corresponding wl_surface
- for the xdg_surface state to take effect. Prior to committing the new
- state, it can set up initial configuration, such as maximizing or setting
- a window geometry.
+ for the xdg_surface state to take effect.
+
+ Creating an xdg_surface from a wl_surface which has a buffer attached or
+ committed is a client error, and any attempts by a client to attach or
+ manipulate a buffer prior to the first xdg_surface.configure call must
+ also be treated as errors.
+
+ Mapping an xdg_surface-based role surface is defined as making it
+ possible for the surface to be shown by the compositor. Note that
+ a mapped surface is not guaranteed to be visible once it is mapped.
+
+ For an xdg_surface to be mapped by the compositor, the following
+ conditions must be met:
+ (1) the client has assigned an xdg_surface-based role to the surface
+ (2) the client has set and committed the xdg_surface state and the
+ role-dependent state to the surface
+ (3) the client has committed a buffer to the surface
+
+ A newly-unmapped surface is considered to have met condition (1) out
+ of the 3 required conditions for mapping a surface if its role surface
+ has not been destroyed.
+ </description>
+
+ <enum name="error">
+ <entry name="not_constructed" value="1"/>
+ <entry name="already_constructed" value="2"/>
+ <entry name="unconfigured_buffer" value="3"/>
+ </enum>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy the xdg_surface">
+ Destroy the xdg_surface object. An xdg_surface must only be destroyed
+ after its role object has been destroyed.
+ </description>
+ </request>
+
+ <request name="get_toplevel">
+ <description summary="assign the xdg_toplevel surface role">
+ This creates an xdg_toplevel object for the given xdg_surface and gives
+ the associated wl_surface the xdg_toplevel role.
+
+ See the documentation of xdg_toplevel for more details about what an
+ xdg_toplevel is and how it is used.
+ </description>
+ <arg name="id" type="new_id" interface="xdg_toplevel"/>
+ </request>
+
+ <request name="get_popup">
+ <description summary="assign the xdg_popup surface role">
+ This creates an xdg_popup object for the given xdg_surface and gives
+ the associated wl_surface the xdg_popup role.
+
+ If null is passed as a parent, a parent surface must be specified using
+ some other protocol, before committing the initial state.
+
+ See the documentation of xdg_popup for more details about what an
+ xdg_popup is and how it is used.
+ </description>
+ <arg name="id" type="new_id" interface="xdg_popup"/>
+ <arg name="parent" type="object" interface="xdg_surface" allow-null="true"/>
+ <arg name="positioner" type="object" interface="xdg_positioner"/>
+ </request>
+
+ <request name="set_window_geometry">
+ <description summary="set the new window geometry">
+ The window geometry of a surface is its "visible bounds" from the
+ user's perspective. Client-side decorations often have invisible
+ portions like drop-shadows which should be ignored for the
+ purposes of aligning, placing and constraining windows.
+
+ The window geometry is double buffered, and will be applied at the
+ time wl_surface.commit of the corresponding wl_surface is called.
+
+ When maintaining a position, the compositor should treat the (x, y)
+ coordinate of the window geometry as the top left corner of the window.
+ A client changing the (x, y) window geometry coordinate should in
+ general not alter the position of the window.
+
+ Once the window geometry of the surface is set, it is not possible to
+ unset it, and it will remain the same until set_window_geometry is
+ called again, even if a new subsurface or buffer is attached.
+
+ If never set, the value is the full bounds of the surface,
+ including any subsurfaces. This updates dynamically on every
+ commit. This unset is meant for extremely simple clients.
+
+ The arguments are given in the surface-local coordinate space of
+ the wl_surface associated with this xdg_surface.
+
+ The width and height must be greater than zero. Setting an invalid size
+ will raise an error. When applied, the effective window geometry will be
+ the set window geometry clamped to the bounding rectangle of the
+ combined geometry of the surface of the xdg_surface and the associated
+ subsurfaces.
+ </description>
+ <arg name="x" type="int"/>
+ <arg name="y" type="int"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </request>
+
+ <request name="ack_configure">
+ <description summary="ack a configure event">
+ When a configure event is received, if a client commits the
+ surface in response to the configure event, then the client
+ must make an ack_configure request sometime before the commit
+ request, passing along the serial of the configure event.
+
+ For instance, for toplevel surfaces the compositor might use this
+ information to move a surface to the top left only when the client has
+ drawn itself for the maximized or fullscreen state.
+
+ If the client receives multiple configure events before it
+ can respond to one, it only has to ack the last configure event.
+
+ A client is not required to commit immediately after sending
+ an ack_configure request - it may even ack_configure several times
+ before its next surface commit.
+
+ A client may send multiple ack_configure requests before committing, but
+ only the last request sent before a commit indicates which configure
+ event the client really is responding to.
+ </description>
+ <arg name="serial" type="uint" summary="the serial from the configure event"/>
+ </request>
- Even without attaching a buffer the compositor must respond to initial
- committed configuration, for instance sending a configure event with
- expected window geometry if the client maximized its surface during
- initialization.
+ <event name="configure">
+ <description summary="suggest a surface change">
+ The configure event marks the end of a configure sequence. A configure
+ sequence is a set of one or more events configuring the state of the
+ xdg_surface, including the final xdg_surface.configure event.
+
+ Where applicable, xdg_surface surface roles will during a configure
+ sequence extend this event as a latched state sent as events before the
+ xdg_surface.configure event. Such events should be considered to make up
+ a set of atomically applied configuration states, where the
+ xdg_surface.configure commits the accumulated state.
+
+ Clients should arrange their surface for the new states, and then send
+ an ack_configure request with the serial sent in this configure event at
+ some point before committing the new surface.
+
+ If the client receives multiple configure events before it can respond
+ to one, it is free to discard all but the last event it received.
+ </description>
+ <arg name="serial" type="uint" summary="serial of the configure event"/>
+ </event>
+ </interface>
- For a surface to be mapped by the compositor the client must have
- committed both an xdg_surface state and a buffer.
+ <interface name="xdg_toplevel" version="1">
+ <description summary="toplevel surface">
+ This interface defines an xdg_surface role which allows a surface to,
+ among other things, set window-like properties such as maximize,
+ fullscreen, and minimize, set application-specific metadata like title and
+ id, and well as trigger user interactive operations such as interactive
+ resize and move.
+
+ Unmapping an xdg_toplevel means that the surface cannot be shown
+ by the compositor until it is explicitly mapped again.
+ All active operations (e.g., move, resize) are canceled and all
+ attributes (e.g. title, state, stacking, ...) are discarded for
+ an xdg_toplevel surface when it is unmapped.
+
+ Attaching a null buffer to a toplevel unmaps the surface.
</description>
<request name="destroy" type="destructor">
- <description summary="Destroy the xdg_surface">
- Unmap and destroy the window. The window will be effectively
- hidden from the user's point of view, and all state like
- maximization, fullscreen, and so on, will be lost.
+ <description summary="destroy the xdg_toplevel">
+ This request destroys the role surface and unmaps the surface;
+ see "Unmapping" behavior in interface section for details.
</description>
</request>
<request name="set_parent">
<description summary="set the parent of this surface">
- Set the "parent" of this surface. This window should be stacked
- above a parent. The parent surface must be mapped as long as this
- surface is mapped.
+ Set the "parent" of this surface. This surface should be stacked
+ above the parent surface and all other ancestor surfaces.
Parent windows should be set on dialogs, toolboxes, or other
"auxiliary" surfaces, so that the parent is raised when the dialog
is raised.
+
+ Setting a null parent for a child window removes any parent-child
+ relationship for the child. Setting a null parent for a window which
+ currently has no parent is a no-op.
+
+ If the parent is unmapped then its children are managed as
+ though the parent of the now-unmapped parent has become the
+ parent of this surface. If no parent exists for the now-unmapped
+ parent then the children are managed as though they have no
+ parent surface.
</description>
- <arg name="parent" type="object" interface="xdg_surface" allow-null="true"/>
+ <arg name="parent" type="object" interface="xdg_toplevel" allow-null="true"/>
</request>
<request name="set_title">
@@ -206,7 +599,7 @@
service name.
The compositor shell will try to group application surfaces together
- by their app ID. As a best practice, it is suggested to select app
+ by their app ID. As a best practice, it is suggested to select app
ID's that match the basename of the application's .desktop file.
For example, "org.freedesktop.FooViewer" where the .desktop file is
"org.freedesktop.FooViewer.desktop".
@@ -222,19 +615,18 @@
<request name="show_window_menu">
<description summary="show the window menu">
- Clients implementing client-side decorations might want to show
- a context menu when right-clicking on the decorations, giving the
- user a menu that they can use to maximize or minimize the window.
+ Clients implementing client-side decorations might want to show
+ a context menu when right-clicking on the decorations, giving the
+ user a menu that they can use to maximize or minimize the window.
- This request asks the compositor to pop up such a window menu at
- the given position, relative to the local surface coordinates of
- the parent surface. There are no guarantees as to what menu items
- the window menu contains.
+ This request asks the compositor to pop up such a window menu at
+ the given position, relative to the local surface coordinates of
+ the parent surface. There are no guarantees as to what menu items
+ the window menu contains.
- This request must be used in response to some sort of user action
- like a button press, key press, or touch down event.
+ This request must be used in response to some sort of user action
+ like a button press, key press, or touch down event.
</description>
-
<arg name="seat" type="object" interface="wl_seat" summary="the wl_seat of the user event"/>
<arg name="serial" type="uint" summary="the serial of the user event"/>
<arg name="x" type="int" summary="the x position to pop up the window menu at"/>
@@ -320,189 +712,228 @@
<enum name="state">
<description summary="types of state on the surface">
- The different state values used on the surface. This is designed for
- state values like maximized, fullscreen. It is paired with the
- configure event to ensure that both the client and the compositor
- setting the state can be synchronized.
-
- States set in this way are double-buffered. They will get applied on
- the next commit.
-
- Desktop environments may extend this enum by taking up a range of
- values and documenting the range they chose in this description.
- They are not required to document the values for the range that they
- chose. Ideally, any good extensions from a desktop environment should
- make its way into standardization into this enum.
-
- The current reserved ranges are:
+ The different state values used on the surface. This is designed for
+ state values like maximized, fullscreen. It is paired with the
+ configure event to ensure that both the client and the compositor
+ setting the state can be synchronized.
- 0x0000 - 0x0FFF: xdg-shell core values, documented below.
- 0x1000 - 0x1FFF: GNOME
+ States set in this way are double-buffered. They will get applied on
+ the next commit.
</description>
<entry name="maximized" value="1" summary="the surface is maximized">
- The surface is maximized. The window geometry specified in the configure
- event must be obeyed by the client.
+ <description summary="the surface is maximized">
+ The surface is maximized. The window geometry specified in the configure
+ event must be obeyed by the client.
+ </description>
</entry>
<entry name="fullscreen" value="2" summary="the surface is fullscreen">
- The surface is fullscreen. The window geometry specified in the configure
- event must be obeyed by the client.
+ <description summary="the surface is fullscreen">
+ The surface is fullscreen. The window geometry specified in the
+ configure event is a maximum; the client cannot resize beyond it. For
+ a surface to cover the whole fullscreened area, the geometry
+ dimensions must be obeyed by the client. For more details, see
+ xdg_toplevel.set_fullscreen.
+ </description>
</entry>
- <entry name="resizing" value="3">
- The surface is being resized. The window geometry specified in the
- configure event is a maximum; the client cannot resize beyond it.
- Clients that have aspect ratio or cell sizing configuration can use
- a smaller size, however.
+ <entry name="resizing" value="3" summary="the surface is being resized">
+ <description summary="the surface is being resized">
+ The surface is being resized. The window geometry specified in the
+ configure event is a maximum; the client cannot resize beyond it.
+ Clients that have aspect ratio or cell sizing configuration can use
+ a smaller size, however.
+ </description>
</entry>
- <entry name="activated" value="4">
- Client window decorations should be painted as if the window is
- active. Do not assume this means that the window actually has
- keyboard or pointer focus.
+ <entry name="activated" value="4" summary="the surface is now activated">
+ <description summary="the surface is now activated">
+ Client window decorations should be painted as if the window is
+ active. Do not assume this means that the window actually has
+ keyboard or pointer focus.
+ </description>
</entry>
</enum>
- <event name="configure">
- <description summary="suggest a surface change">
- The configure event asks the client to resize its surface or to
- change its state.
+ <request name="set_max_size">
+ <description summary="set the maximum size">
+ Set a maximum size for the window.
- The width and height arguments specify a hint to the window
- about how its surface should be resized in window geometry
- coordinates. See set_window_geometry.
+ The client can specify a maximum size so that the compositor does
+ not try to configure the window beyond this size.
- If the width or height arguments are zero, it means the client
- should decide its own window dimension. This may happen when the
- compositor need to configure the state of the surface but doesn't
- have any information about any previous or expected dimension.
+ The width and height arguments are in window geometry coordinates.
+ See xdg_surface.set_window_geometry.
- The states listed in the event specify how the width/height
- arguments should be interpreted, and possibly how it should be
- drawn.
+ Values set in this way are double-buffered. They will get applied
+ on the next commit.
- Clients should arrange their surface for the new size and
- states, and then send a ack_configure request with the serial
- sent in this configure event at some point before committing
- the new surface.
+ The compositor can use this information to allow or disallow
+ different states like maximize or fullscreen and draw accurate
+ animations.
- If the client receives multiple configure events before it
- can respond to one, it is free to discard all but the last
- event it received.
- </description>
+ Similarly, a tiling window manager may use this information to
+ place and resize client windows in a more effective way.
- <arg name="width" type="int"/>
- <arg name="height" type="int"/>
- <arg name="states" type="array"/>
- <arg name="serial" type="uint"/>
- </event>
+ The client should not rely on the compositor to obey the maximum
+ size. The compositor may decide to ignore the values set by the
+ client and request a larger size.
- <request name="ack_configure">
- <description summary="ack a configure event">
- When a configure event is received, if a client commits the
- surface in response to the configure event, then the client
- must make a ack_configure request before the commit request,
- passing along the serial of the configure event.
+ If never set, or a value of zero in the request, means that the
+ client has no expected maximum size in the given dimension.
+ As a result, a client wishing to reset the maximum size
+ to an unspecified state can use zero for width and height in the
+ request.
- For instance, the compositor might use this information to move
- a surface to the top left only when the client has drawn itself
- for the maximized or fullscreen state.
+ Requesting a maximum size to be smaller than the minimum size of
+ a surface is illegal and will result in a protocol error.
- If the client receives multiple configure events before it
- can respond to one, it only has to ack the last configure event.
+ The width and height must be greater than or equal to zero. Using
+ strictly negative values for width and height will result in a
+ protocol error.
</description>
- <arg name="serial" type="uint" summary="the serial from the configure event"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
</request>
- <request name="set_window_geometry">
- <description summary="set the new window geometry">
- The window geometry of a window is its "visible bounds" from the
- user's perspective. Client-side decorations often have invisible
- portions like drop-shadows which should be ignored for the
- purposes of aligning, placing and constraining windows.
+ <request name="set_min_size">
+ <description summary="set the minimum size">
+ Set a minimum size for the window.
+
+ The client can specify a minimum size so that the compositor does
+ not try to configure the window below this size.
+
+ The width and height arguments are in window geometry coordinates.
+ See xdg_surface.set_window_geometry.
+
+ Values set in this way are double-buffered. They will get applied
+ on the next commit.
- The window geometry is double buffered, and will be applied at the
- time wl_surface.commit of the corresponding wl_surface is called.
+ The compositor can use this information to allow or disallow
+ different states like maximize or fullscreen and draw accurate
+ animations.
- Once the window geometry of the surface is set once, it is not
- possible to unset it, and it will remain the same until
- set_window_geometry is called again, even if a new subsurface or
- buffer is attached.
+ Similarly, a tiling window manager may use this information to
+ place and resize client windows in a more effective way.
- If never set, the value is the full bounds of the surface,
- including any subsurfaces. This updates dynamically on every
- commit. This unset mode is meant for extremely simple clients.
+ The client should not rely on the compositor to obey the minimum
+ size. The compositor may decide to ignore the values set by the
+ client and request a smaller size.
- If responding to a configure event, the window geometry in here
- must respect the sizing negotiations specified by the states in
- the configure event.
+ If never set, or a value of zero in the request, means that the
+ client has no expected minimum size in the given dimension.
+ As a result, a client wishing to reset the minimum size
+ to an unspecified state can use zero for width and height in the
+ request.
- The arguments are given in the surface local coordinate space of
- the wl_surface associated with this xdg_surface.
+ Requesting a minimum size to be larger than the maximum size of
+ a surface is illegal and will result in a protocol error.
- The width and height must be greater than zero.
+ The width and height must be greater than or equal to zero. Using
+ strictly negative values for width and height will result in a
+ protocol error.
</description>
- <arg name="x" type="int"/>
- <arg name="y" type="int"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
</request>
<request name="set_maximized">
<description summary="maximize the window">
- Maximize the surface.
-
- After requesting that the surface should be maximized, the compositor
- will respond by emitting a configure event with the "maximized" state
- and the required window geometry. The client should then update its
- content, drawing it in a maximized state, i.e. without shadow or other
- decoration outside of the window geometry. The client must also
- acknowledge the configure when committing the new content (see
- ack_configure).
-
- It is up to the compositor to decide how and where to maximize the
- surface, for example which output and what region of the screen should
- be used.
-
- If the surface was already maximized, the compositor will still emit
- a configure event with the "maximized" state.
+ Maximize the surface.
+
+ After requesting that the surface should be maximized, the compositor
+ will respond by emitting a configure event with the "maximized" state
+ and the required window geometry. The client should then update its
+ content, drawing it in a maximized state, i.e. without shadow or other
+ decoration outside of the window geometry. The client must also
+ acknowledge the configure when committing the new content (see
+ ack_configure).
+
+ It is up to the compositor to decide how and where to maximize the
+ surface, for example which output and what region of the screen should
+ be used.
+
+ If the surface was already maximized, the compositor will still emit
+ a configure event with the "maximized" state.
+
+ If the surface is in a fullscreen state, this request has no direct
+ effect. It will alter the state the surface is returned to when
+ unmaximized if not overridden by the compositor.
</description>
</request>
<request name="unset_maximized">
<description summary="unmaximize the window">
- Unmaximize the surface.
-
- After requesting that the surface should be unmaximized, the compositor
- will respond by emitting a configure event without the "maximized"
- state. If available, the compositor will include the window geometry
- dimensions the window had prior to being maximized in the configure
- request. The client must then update its content, drawing it in a
- regular state, i.e. potentially with shadow, etc. The client must also
- acknowledge the configure when committing the new content (see
- ack_configure).
-
- It is up to the compositor to position the surface after it was
- unmaximized; usually the position the surface had before maximizing, if
- applicable.
-
- If the surface was already not maximized, the compositor will still
- emit a configure event without the "maximized" state.
+ Unmaximize the surface.
+
+ After requesting that the surface should be unmaximized, the compositor
+ will respond by emitting a configure event without the "maximized"
+ state. If available, the compositor will include the window geometry
+ dimensions the window had prior to being maximized in the configure
+ event. The client must then update its content, drawing it in a
+ regular state, i.e. potentially with shadow, etc. The client must also
+ acknowledge the configure when committing the new content (see
+ ack_configure).
+
+ It is up to the compositor to position the surface after it was
+ unmaximized; usually the position the surface had before maximizing, if
+ applicable.
+
+ If the surface was already not maximized, the compositor will still
+ emit a configure event without the "maximized" state.
+
+ If the surface is in a fullscreen state, this request has no direct
+ effect. It will alter the state the surface is returned to when
+ unmaximized if not overridden by the compositor.
</description>
</request>
<request name="set_fullscreen">
- <description summary="set the window as fullscreen on a monitor">
+ <description summary="set the window as fullscreen on an output">
Make the surface fullscreen.
- You can specify an output that you would prefer to be fullscreen.
- If this value is NULL, it's up to the compositor to choose which
- display will be used to map this surface.
-
- If the surface doesn't cover the whole output, the compositor will
- position the surface in the center of the output and compensate with
- black borders filling the rest of the output.
+ After requesting that the surface should be fullscreened, the
+ compositor will respond by emitting a configure event with the
+ "fullscreen" state and the fullscreen window geometry. The client must
+ also acknowledge the configure when committing the new content (see
+ ack_configure).
+
+ The output passed by the request indicates the client's preference as
+ to which display it should be set fullscreen on. If this value is NULL,
+ it's up to the compositor to choose which display will be used to map
+ this surface.
+
+ If the surface doesn't cover the whole output, the compositor will
+ position the surface in the center of the output and compensate with
+ with border fill covering the rest of the output. The content of the
+ border fill is undefined, but should be assumed to be in some way that
+ attempts to blend into the surrounding area (e.g. solid black).
+
+ If the fullscreened surface is not opaque, the compositor must make
+ sure that other screen content not part of the same surface tree (made
+ up of subsurfaces, popups or similarly coupled surfaces) are not
+ visible below the fullscreened surface.
</description>
<arg name="output" type="object" interface="wl_output" allow-null="true"/>
</request>
- <request name="unset_fullscreen" />
+
+ <request name="unset_fullscreen">
+ <description summary="unset the window as fullscreen">
+ Make the surface no longer fullscreen.
+
+ After requesting that the surface should be unfullscreened, the
+ compositor will respond by emitting a configure event without the
+ "fullscreen" state.
+
+ Making a surface unfullscreen sets states for the surface based on the following:
+ * the state(s) it may have had before becoming fullscreen
+ * any state(s) decided by the compositor
+ * any state(s) requested by the client while the surface was fullscreen
+
+ The compositor may include the previous window geometry dimensions in
+ the configure event, if applicable.
+
+ The client must also acknowledge the configure when committing the new
+ content (see ack_configure).
+ </description>
+ </request>
<request name="set_minimized">
<description summary="set the window as minimized">
@@ -517,75 +948,89 @@
</description>
</request>
+ <event name="configure">
+ <description summary="suggest a surface change">
+ This configure event asks the client to resize its toplevel surface or
+ to change its state. The configured state should not be applied
+ immediately. See xdg_surface.configure for details.
+
+ The width and height arguments specify a hint to the window
+ about how its surface should be resized in window geometry
+ coordinates. See set_window_geometry.
+
+ If the width or height arguments are zero, it means the client
+ should decide its own window dimension. This may happen when the
+ compositor needs to configure the state of the surface but doesn't
+ have any information about any previous or expected dimension.
+
+ The states listed in the event specify how the width/height
+ arguments should be interpreted, and possibly how it should be
+ drawn.
+
+ Clients must send an ack_configure in response to this event. See
+ xdg_surface.configure and xdg_surface.ack_configure for details.
+ </description>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ <arg name="states" type="array"/>
+ </event>
+
<event name="close">
<description summary="surface wants to be closed">
- The close event is sent by the compositor when the user
- wants the surface to be closed. This should be equivalent to
- the user clicking the close button in client-side decorations,
- if your application has any...
-
- This is only a request that the user intends to close your
- window. The client may choose to ignore this request, or show
- a dialog to ask the user to save their data...
+ The close event is sent by the compositor when the user
+ wants the surface to be closed. This should be equivalent to
+ the user clicking the close button in client-side decorations,
+ if your application has any.
+
+ This is only a request that the user intends to close the
+ window. The client may choose to ignore this request, or show
+ a dialog to ask the user to save their data, etc.
</description>
</event>
</interface>
<interface name="xdg_popup" version="1">
<description summary="short-lived, popup surfaces for menus">
- A popup surface is a short-lived, temporary surface that can be
- used to implement menus. It takes an explicit grab on the surface
- that will be dismissed when the user dismisses the popup. This can
- be done by the user clicking outside the surface, using the keyboard,
- or even locking the screen through closing the lid or a timeout.
-
- When the popup is dismissed, a popup_done event will be sent out,
- and at the same time the surface will be unmapped. The xdg_popup
- object is now inert and cannot be reactivated, so clients should
- destroy it. Explicitly destroying the xdg_popup object will also
- dismiss the popup and unmap the surface.
-
- Clients will receive events for all their surfaces during this
- grab (which is an "owner-events" grab in X11 parlance). This is
- done so that users can navigate through submenus and other
- "nested" popup windows without having to dismiss the topmost
- popup.
-
- Clients that want to dismiss the popup when another surface of
- their own is clicked should dismiss the popup using the destroy
- request.
+ A popup surface is a short-lived, temporary surface. It can be used to
+ implement for example menus, popovers, tooltips and other similar user
+ interface concepts.
- The parent surface must have either an xdg_surface or xdg_popup
- role.
+ A popup can be made to take an explicit grab. See xdg_popup.grab for
+ details.
- Specifying an xdg_popup for the parent means that the popups are
- nested, with this popup now being the topmost popup. Nested
- popups must be destroyed in the reverse order they were created
- in, e.g. the only popup you are allowed to destroy at all times
- is the topmost one.
+ When the popup is dismissed, a popup_done event will be sent out, and at
+ the same time the surface will be unmapped. See the xdg_popup.popup_done
+ event for details.
- If there is an existing popup when creating a new popup, the
- parent must be the current topmost popup.
+ Explicitly destroying the xdg_popup object will also dismiss the popup and
+ unmap the surface. Clients that want to dismiss the popup when another
+ surface of their own is clicked should dismiss the popup using the destroy
+ request.
- A parent surface must be mapped before the new popup is mapped.
+ The parent surface must have either the xdg_toplevel or xdg_popup surface
+ role.
- When compositors choose to dismiss a popup, they will likely
- dismiss every nested popup as well. When a compositor dismisses
- popups, it will follow the same dismissing order as required
- from the client.
+ A newly created xdg_popup will be stacked on top of all previously created
+ xdg_popup surfaces associated with the same xdg_toplevel.
+
+ The parent of an xdg_popup must be mapped (see the xdg_surface
+ description) before the xdg_popup itself.
The x and y arguments passed when creating the popup object specify
where the top left of the popup should be placed, relative to the
local surface coordinates of the parent surface. See
- xdg_shell.get_xdg_popup.
+ xdg_surface.get_popup. An xdg_popup must intersect with or be at least
+ partially adjacent to its parent surface.
The client must call wl_surface.commit on the corresponding wl_surface
for the xdg_popup state to take effect.
-
- For a surface to be mapped by the compositor the client must have
- committed both the xdg_popup state and a buffer.
</description>
+ <enum name="error">
+ <entry name="invalid_grab" value="0"
+ summary="tried to grab after being mapped"/>
+ </enum>
+
<request name="destroy" type="destructor">
<description summary="remove xdg_popup interface">
This destroys the popup. Explicitly destroying the xdg_popup
@@ -596,6 +1041,73 @@
</description>
</request>
+ <request name="grab">
+ <description summary="make the popup take an explicit grab">
+ This request makes the created popup take an explicit grab. An explicit
+ grab will be dismissed when the user dismisses the popup, or when the
+ client destroys the xdg_popup. This can be done by the user clicking
+ outside the surface, using the keyboard, or even locking the screen
+ through closing the lid or a timeout.
+
+ If the compositor denies the grab, the popup will be immediately
+ dismissed.
+
+ This request must be used in response to some sort of user action like a
+ button press, key press, or touch down event. The serial number of the
+ event should be passed as 'serial'.
+
+ The parent of a grabbing popup must either be an xdg_toplevel surface or
+ another xdg_popup with an explicit grab. If the parent is another
+ xdg_popup it means that the popups are nested, with this popup now being
+ the topmost popup.
+
+ Nested popups must be destroyed in the reverse order they were created
+ in, e.g. the only popup you are allowed to destroy at all times is the
+ topmost one.
+
+ When compositors choose to dismiss a popup, they may dismiss every
+ nested grabbing popup as well. When a compositor dismisses popups, it
+ will follow the same dismissing order as required from the client.
+
+ The parent of a grabbing popup must either be another xdg_popup with an
+ active explicit grab, or an xdg_popup or xdg_toplevel, if there are no
+ explicit grabs already taken.
+
+ If the topmost grabbing popup is destroyed, the grab will be returned to
+ the parent of the popup, if that parent previously had an explicit grab.
+
+ If the parent is a grabbing popup which has already been dismissed, this
+ popup will be immediately dismissed. If the parent is a popup that did
+ not take an explicit grab, an error will be raised.
+
+ During a popup grab, the client owning the grab will receive pointer
+ and touch events for all their surfaces as normal (similar to an
+ "owner-events" grab in X11 parlance), while the top most grabbing popup
+ will always have keyboard focus.
+ </description>
+ <arg name="seat" type="object" interface="wl_seat"
+ summary="the wl_seat of the user event"/>
+ <arg name="serial" type="uint" summary="the serial of the user event"/>
+ </request>
+
+ <event name="configure">
+ <description summary="configure the popup surface">
+ This event asks the popup surface to configure itself given the
+ configuration. The configured state should not be applied immediately.
+ See xdg_surface.configure for details.
+
+ The x and y arguments represent the position the popup was placed at
+ given the xdg_positioner rule, relative to the upper left corner of the
+ window geometry of the parent surface.
+ </description>
+ <arg name="x" type="int"
+ summary="x position relative to parent surface window geometry"/>
+ <arg name="y" type="int"
+ summary="y position relative to parent surface window geometry"/>
+ <arg name="width" type="int" summary="window geometry width"/>
+ <arg name="height" type="int" summary="window geometry height"/>
+ </event>
+
<event name="popup_done">
<description summary="popup interaction is done">
The popup_done event is sent out when a popup is dismissed by the
diff --git a/src/client/client.pro b/src/client/client.pro
index eae7ad52e..45bbb976b 100644
--- a/src/client/client.pro
+++ b/src/client/client.pro
@@ -25,11 +25,10 @@ INCLUDEPATH += $$PWD/../shared
WAYLANDCLIENTSOURCES += \
../extensions/surface-extension.xml \
../extensions/touch-extension.xml \
- ../extensions/qtkey-extension.xml \
+ ../extensions/qt-key-unstable-v1.xml \
../extensions/qt-windowmanager.xml \
../3rdparty/protocol/text-input-unstable-v2.xml \
- ../3rdparty/protocol/xdg-shell.xml \
- ../3rdparty/protocol/xdg-shell-unstable-v6.xml \
+ ../3rdparty/protocol/xdg-output-unstable-v1.xml \
WAYLANDCLIENTSOURCES_SYSTEM += \
../3rdparty/protocol/wayland.xml \
@@ -43,14 +42,6 @@ SOURCES += qwaylandintegration.cpp \
qwaylandscreen.cpp \
qwaylandshmwindow.cpp \
qwaylandshellsurface.cpp \
- qwaylandwlshellsurface.cpp \
- qwaylandwlshellintegration.cpp \
- qwaylandxdgshell.cpp \
- qwaylandxdgsurface.cpp \
- qwaylandxdgpopup.cpp \
- qwaylandxdgshellintegration.cpp \
- qwaylandxdgshellv6.cpp \
- qwaylandxdgshellv6integration.cpp \
qwaylandextendedsurface.cpp \
qwaylandsubsurface.cpp \
qwaylandtouch.cpp \
@@ -76,14 +67,6 @@ HEADERS += qwaylandintegration_p.h \
qwaylandbuffer_p.h \
qwaylandshmwindow_p.h \
qwaylandshellsurface_p.h \
- qwaylandwlshellsurface_p.h \
- qwaylandwlshellintegration_p.h \
- qwaylandxdgshell_p.h \
- qwaylandxdgsurface_p.h \
- qwaylandxdgpopup_p.h \
- qwaylandxdgshellintegration_p.h \
- qwaylandxdgshellv6_p.h \
- qwaylandxdgshellv6integration_p.h \
qwaylandextendedsurface_p.h \
qwaylandsubsurface_p.h \
qwaylandtouch_p.h \
diff --git a/src/client/qwaylandcursor.cpp b/src/client/qwaylandcursor.cpp
index 21a6c0811..6947e97f1 100644
--- a/src/client/qwaylandcursor.cpp
+++ b/src/client/qwaylandcursor.cpp
@@ -53,65 +53,203 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-QWaylandCursor::QWaylandCursor(QWaylandScreen *screen)
- : mDisplay(screen->display())
+QWaylandCursorTheme *QWaylandCursorTheme::create(QWaylandShm *shm, int size)
{
- //TODO: Make wl_cursor_theme_load arguments configurable here
- QByteArray cursorTheme = qgetenv("XCURSOR_THEME");
- if (cursorTheme.isEmpty())
- cursorTheme = QByteArray("default");
- QByteArray cursorSizeFromEnv = qgetenv("XCURSOR_SIZE");
- bool hasCursorSize = false;
- int cursorSize = cursorSizeFromEnv.toInt(&hasCursorSize);
- if (!hasCursorSize || cursorSize <= 0)
- cursorSize = 32;
- mCursorTheme = wl_cursor_theme_load(cursorTheme, cursorSize, mDisplay->shm()->object());
- if (!mCursorTheme)
- qDebug() << "Could not load theme" << cursorTheme;
- initCursorMap();
+ static QString themeName = qEnvironmentVariable("XCURSOR_THEME", QStringLiteral("default"));
+ return create(shm, size, themeName);
}
-QWaylandCursor::~QWaylandCursor()
+QWaylandCursorTheme *QWaylandCursorTheme::create(QWaylandShm *shm, int size, const QString &themeName)
{
- if (mCursorTheme)
- wl_cursor_theme_destroy(mCursorTheme);
+ QByteArray nameBytes = themeName.toLocal8Bit();
+ struct ::wl_cursor_theme *theme = wl_cursor_theme_load(nameBytes.constData(), size, shm->object());
+
+ if (!theme) {
+ qCWarning(lcQpaWayland) << "Could not load cursor theme" << themeName << "size" << size;
+ return nullptr;
+ }
+
+ return new QWaylandCursorTheme(theme);
}
-struct wl_cursor_image *QWaylandCursor::cursorImage(Qt::CursorShape newShape)
+QWaylandCursorTheme::~QWaylandCursorTheme()
{
- struct wl_cursor *waylandCursor = nullptr;
+ wl_cursor_theme_destroy(m_theme);
+}
- /* Hide cursor */
- if (newShape == Qt::BlankCursor)
- {
- mDisplay->setCursor(nullptr, nullptr);
- return nullptr;
+wl_cursor *QWaylandCursorTheme::requestCursor(WaylandCursor shape)
+{
+ if (struct wl_cursor *cursor = m_cursors.value(shape, nullptr))
+ return cursor;
+
+ static const QMultiMap<WaylandCursor, QByteArray>cursorNamesMap {
+ {ArrowCursor, "left_ptr"},
+ {ArrowCursor, "default"},
+ {ArrowCursor, "top_left_arrow"},
+ {ArrowCursor, "left_arrow"},
+
+ {UpArrowCursor, "up_arrow"},
+
+ {CrossCursor, "cross"},
+
+ {WaitCursor, "wait"},
+ {WaitCursor, "watch"},
+ {WaitCursor, "0426c94ea35c87780ff01dc239897213"},
+
+ {IBeamCursor, "ibeam"},
+ {IBeamCursor, "text"},
+ {IBeamCursor, "xterm"},
+
+ {SizeVerCursor, "size_ver"},
+ {SizeVerCursor, "ns-resize"},
+ {SizeVerCursor, "v_double_arrow"},
+ {SizeVerCursor, "00008160000006810000408080010102"},
+
+ {SizeHorCursor, "size_hor"},
+ {SizeHorCursor, "ew-resize"},
+ {SizeHorCursor, "h_double_arrow"},
+ {SizeHorCursor, "028006030e0e7ebffc7f7070c0600140"},
+
+ {SizeBDiagCursor, "size_bdiag"},
+ {SizeBDiagCursor, "nesw-resize"},
+ {SizeBDiagCursor, "50585d75b494802d0151028115016902"},
+ {SizeBDiagCursor, "fcf1c3c7cd4491d801f1e1c78f100000"},
+
+ {SizeFDiagCursor, "size_fdiag"},
+ {SizeFDiagCursor, "nwse-resize"},
+ {SizeFDiagCursor, "38c5dff7c7b8962045400281044508d2"},
+ {SizeFDiagCursor, "c7088f0f3e6c8088236ef8e1e3e70000"},
+
+ {SizeAllCursor, "size_all"},
+
+ {SplitVCursor, "split_v"},
+ {SplitVCursor, "row-resize"},
+ {SplitVCursor, "sb_v_double_arrow"},
+ {SplitVCursor, "2870a09082c103050810ffdffffe0204"},
+ {SplitVCursor, "c07385c7190e701020ff7ffffd08103c"},
+
+ {SplitHCursor, "split_h"},
+ {SplitHCursor, "col-resize"},
+ {SplitHCursor, "sb_h_double_arrow"},
+ {SplitHCursor, "043a9f68147c53184671403ffa811cc5"},
+ {SplitHCursor, "14fef782d02440884392942c11205230"},
+
+ {PointingHandCursor, "pointing_hand"},
+ {PointingHandCursor, "pointer"},
+ {PointingHandCursor, "hand1"},
+ {PointingHandCursor, "e29285e634086352946a0e7090d73106"},
+
+ {ForbiddenCursor, "forbidden"},
+ {ForbiddenCursor, "not-allowed"},
+ {ForbiddenCursor, "crossed_circle"},
+ {ForbiddenCursor, "circle"},
+ {ForbiddenCursor, "03b6e0fcb3499374a867c041f52298f0"},
+
+ {WhatsThisCursor, "whats_this"},
+ {WhatsThisCursor, "help"},
+ {WhatsThisCursor, "question_arrow"},
+ {WhatsThisCursor, "5c6cd98b3f3ebcb1f9c7f1c204630408"},
+ {WhatsThisCursor, "d9ce0ab605698f320427677b458ad60b"},
+
+ {BusyCursor, "left_ptr_watch"},
+ {BusyCursor, "half-busy"},
+ {BusyCursor, "progress"},
+ {BusyCursor, "00000000000000020006000e7e9ffc3f"},
+ {BusyCursor, "08e8e1c95fe2fc01f976f1e063a24ccd"},
+
+ {OpenHandCursor, "openhand"},
+ {OpenHandCursor, "fleur"},
+ {OpenHandCursor, "5aca4d189052212118709018842178c0"},
+ {OpenHandCursor, "9d800788f1b08800ae810202380a0822"},
+
+ {ClosedHandCursor, "closedhand"},
+ {ClosedHandCursor, "grabbing"},
+ {ClosedHandCursor, "208530c400c041818281048008011002"},
+
+ {DragCopyCursor, "dnd-copy"},
+ {DragCopyCursor, "copy"},
+
+ {DragMoveCursor, "dnd-move"},
+ {DragMoveCursor, "move"},
+
+ {DragLinkCursor, "dnd-link"},
+ {DragLinkCursor, "link"},
+
+ {ResizeNorthCursor, "n-resize"},
+ {ResizeNorthCursor, "top_side"},
+
+ {ResizeSouthCursor, "s-resize"},
+ {ResizeSouthCursor, "bottom_side"},
+
+ {ResizeEastCursor, "e-resize"},
+ {ResizeEastCursor, "right_side"},
+
+ {ResizeWestCursor, "w-resize"},
+ {ResizeWestCursor, "left_side"},
+
+ {ResizeNorthWestCursor, "nw-resize"},
+ {ResizeNorthWestCursor, "top_left_corner"},
+
+ {ResizeSouthEastCursor, "se-resize"},
+ {ResizeSouthEastCursor, "bottom_right_corner"},
+
+ {ResizeNorthEastCursor, "ne-resize"},
+ {ResizeNorthEastCursor, "top_right_corner"},
+
+ {ResizeSouthWestCursor, "sw-resize"},
+ {ResizeSouthWestCursor, "bottom_left_corner"},
+ };
+
+ QList<QByteArray> cursorNames = cursorNamesMap.values(shape);
+ for (auto &name : qAsConst(cursorNames)) {
+ if (wl_cursor *cursor = wl_cursor_theme_get_cursor(m_theme, name.constData())) {
+ m_cursors.insert(shape, cursor);
+ return cursor;
+ }
}
- if (newShape < Qt::BitmapCursor) {
- waylandCursor = requestCursor((WaylandCursor)newShape);
- } else if (newShape == Qt::BitmapCursor) {
- // cannot create a wl_cursor_image for a CursorShape
+ // Fallback to arrow cursor
+ if (shape != ArrowCursor)
+ return requestCursor(ArrowCursor);
+
+ // Give up
+ return nullptr;
+}
+
+struct wl_cursor_image *QWaylandCursorTheme::cursorImage(Qt::CursorShape shape)
+{
+ struct wl_cursor *waylandCursor = nullptr;
+
+ if (shape < Qt::BitmapCursor) {
+ waylandCursor = requestCursor(WaylandCursor(shape));
+ } else if (shape == Qt::BitmapCursor) {
+ qCWarning(lcQpaWayland) << "cannot create a wl_cursor_image for a CursorShape";
return nullptr;
} else {
//TODO: Custom cursor logic (for resize arrows)
}
if (!waylandCursor) {
- qDebug("Could not find cursor for shape %d", newShape);
+ qCWarning(lcQpaWayland) << "Could not find cursor for shape" << shape;
return nullptr;
}
struct wl_cursor_image *image = waylandCursor->images[0];
struct wl_buffer *buffer = wl_cursor_image_get_buffer(image);
if (!buffer) {
- qDebug("Could not find buffer for cursor");
+ qCWarning(lcQpaWayland) << "Could not find buffer for cursor";
return nullptr;
}
return image;
}
+QWaylandCursor::QWaylandCursor(QWaylandScreen *screen)
+ : mDisplay(screen->display())
+ , mCursorTheme(mDisplay->loadCursorTheme(screen->devicePixelRatio()))
+{
+}
+
QSharedPointer<QWaylandBuffer> QWaylandCursor::cursorBitmapImage(const QCursor *cursor)
{
if (cursor->shape() != Qt::BitmapCursor)
@@ -123,24 +261,39 @@ QSharedPointer<QWaylandBuffer> QWaylandCursor::cursorBitmapImage(const QCursor *
return buffer;
}
-void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window)
+struct wl_cursor_image *QWaylandCursor::cursorImage(Qt::CursorShape shape)
{
- Q_UNUSED(window)
+ if (!mCursorTheme)
+ return nullptr;
+ return mCursorTheme->cursorImage(shape);
+}
+void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window)
+{
const Qt::CursorShape newShape = cursor ? cursor->shape() : Qt::ArrowCursor;
+ if (newShape == Qt::BlankCursor) {
+ mDisplay->setCursor(nullptr, nullptr, 1);
+ return;
+ }
+
if (newShape == Qt::BitmapCursor) {
- mDisplay->setCursor(cursorBitmapImage(cursor), cursor->hotSpot());
+ mDisplay->setCursor(cursorBitmapImage(cursor), cursor->hotSpot(), window->screen()->devicePixelRatio());
return;
}
- struct wl_cursor_image *image = cursorImage(newShape);
- if (!image) {
+ if (!mCursorTheme) {
+ qCWarning(lcQpaWayland) << "Can't set cursor from shape with no cursor theme";
return;
}
- struct wl_buffer *buffer = wl_cursor_image_get_buffer(image);
- mDisplay->setCursor(buffer, image);
+ if (struct ::wl_cursor_image *image = mCursorTheme->cursorImage(newShape)) {
+ struct wl_buffer *buffer = wl_cursor_image_get_buffer(image);
+ mDisplay->setCursor(buffer, image, window->screen()->devicePixelRatio());
+ return;
+ }
+
+ qCWarning(lcQpaWayland) << "Unable to change to cursor" << cursor;
}
void QWaylandCursor::pointerEvent(const QMouseEvent &event)
@@ -156,155 +309,7 @@ QPoint QWaylandCursor::pos() const
void QWaylandCursor::setPos(const QPoint &pos)
{
Q_UNUSED(pos);
- qWarning() << "QWaylandCursor::setPos: not implemented";
-}
-
-wl_cursor *QWaylandCursor::requestCursor(WaylandCursor shape)
-{
- struct wl_cursor *cursor = mCursors.value(shape, 0);
-
- //If the cursor has not been loaded already, load it
- if (!cursor) {
- if (!mCursorTheme)
- return nullptr;
-
- QList<QByteArray> cursorNames = mCursorNamesMap.values(shape);
- foreach (const QByteArray &name, cursorNames) {
- cursor = wl_cursor_theme_get_cursor(mCursorTheme, name.constData());
- if (cursor) {
- mCursors.insert(shape, cursor);
- break;
- }
- }
- }
-
- //If there still no cursor for a shape, use the default cursor
- if (!cursor && shape != ArrowCursor) {
- cursor = requestCursor(ArrowCursor);
- }
-
- return cursor;
-}
-
-
-void QWaylandCursor::initCursorMap()
-{
- //Fill the cursor name map will the table of xcursor names
- mCursorNamesMap.insert(ArrowCursor, "left_ptr");
- mCursorNamesMap.insert(ArrowCursor, "default");
- mCursorNamesMap.insert(ArrowCursor, "top_left_arrow");
- mCursorNamesMap.insert(ArrowCursor, "left_arrow");
-
- mCursorNamesMap.insert(UpArrowCursor, "up_arrow");
-
- mCursorNamesMap.insert(CrossCursor, "cross");
-
- mCursorNamesMap.insert(WaitCursor, "wait");
- mCursorNamesMap.insert(WaitCursor, "watch");
- mCursorNamesMap.insert(WaitCursor, "0426c94ea35c87780ff01dc239897213");
-
- mCursorNamesMap.insert(IBeamCursor, "ibeam");
- mCursorNamesMap.insert(IBeamCursor, "text");
- mCursorNamesMap.insert(IBeamCursor, "xterm");
-
- mCursorNamesMap.insert(SizeVerCursor, "size_ver");
- mCursorNamesMap.insert(SizeVerCursor, "ns-resize");
- mCursorNamesMap.insert(SizeVerCursor, "v_double_arrow");
- mCursorNamesMap.insert(SizeVerCursor, "00008160000006810000408080010102");
-
- mCursorNamesMap.insert(SizeHorCursor, "size_hor");
- mCursorNamesMap.insert(SizeHorCursor, "ew-resize");
- mCursorNamesMap.insert(SizeHorCursor, "h_double_arrow");
- mCursorNamesMap.insert(SizeHorCursor, "028006030e0e7ebffc7f7070c0600140");
-
- mCursorNamesMap.insert(SizeBDiagCursor, "size_bdiag");
- mCursorNamesMap.insert(SizeBDiagCursor, "nesw-resize");
- mCursorNamesMap.insert(SizeBDiagCursor, "50585d75b494802d0151028115016902");
- mCursorNamesMap.insert(SizeBDiagCursor, "fcf1c3c7cd4491d801f1e1c78f100000");
-
- mCursorNamesMap.insert(SizeFDiagCursor, "size_fdiag");
- mCursorNamesMap.insert(SizeFDiagCursor, "nwse-resize");
- mCursorNamesMap.insert(SizeFDiagCursor, "38c5dff7c7b8962045400281044508d2");
- mCursorNamesMap.insert(SizeFDiagCursor, "c7088f0f3e6c8088236ef8e1e3e70000");
-
- mCursorNamesMap.insert(SizeAllCursor, "size_all");
-
- mCursorNamesMap.insert(SplitVCursor, "split_v");
- mCursorNamesMap.insert(SplitVCursor, "row-resize");
- mCursorNamesMap.insert(SplitVCursor, "sb_v_double_arrow");
- mCursorNamesMap.insert(SplitVCursor, "2870a09082c103050810ffdffffe0204");
- mCursorNamesMap.insert(SplitVCursor, "c07385c7190e701020ff7ffffd08103c");
-
- mCursorNamesMap.insert(SplitHCursor, "split_h");
- mCursorNamesMap.insert(SplitHCursor, "col-resize");
- mCursorNamesMap.insert(SplitHCursor, "sb_h_double_arrow");
- mCursorNamesMap.insert(SplitHCursor, "043a9f68147c53184671403ffa811cc5");
- mCursorNamesMap.insert(SplitHCursor, "14fef782d02440884392942c11205230");
-
- mCursorNamesMap.insert(PointingHandCursor, "pointing_hand");
- mCursorNamesMap.insert(PointingHandCursor, "pointer");
- mCursorNamesMap.insert(PointingHandCursor, "hand1");
- mCursorNamesMap.insert(PointingHandCursor, "e29285e634086352946a0e7090d73106");
-
- mCursorNamesMap.insert(ForbiddenCursor, "forbidden");
- mCursorNamesMap.insert(ForbiddenCursor, "not-allowed");
- mCursorNamesMap.insert(ForbiddenCursor, "crossed_circle");
- mCursorNamesMap.insert(ForbiddenCursor, "circle");
- mCursorNamesMap.insert(ForbiddenCursor, "03b6e0fcb3499374a867c041f52298f0");
-
- mCursorNamesMap.insert(WhatsThisCursor, "whats_this");
- mCursorNamesMap.insert(WhatsThisCursor, "help");
- mCursorNamesMap.insert(WhatsThisCursor, "question_arrow");
- mCursorNamesMap.insert(WhatsThisCursor, "5c6cd98b3f3ebcb1f9c7f1c204630408");
- mCursorNamesMap.insert(WhatsThisCursor, "d9ce0ab605698f320427677b458ad60b");
-
- mCursorNamesMap.insert(BusyCursor, "left_ptr_watch");
- mCursorNamesMap.insert(BusyCursor, "half-busy");
- mCursorNamesMap.insert(BusyCursor, "progress");
- mCursorNamesMap.insert(BusyCursor, "00000000000000020006000e7e9ffc3f");
- mCursorNamesMap.insert(BusyCursor, "08e8e1c95fe2fc01f976f1e063a24ccd");
-
- mCursorNamesMap.insert(OpenHandCursor, "openhand");
- mCursorNamesMap.insert(OpenHandCursor, "fleur");
- mCursorNamesMap.insert(OpenHandCursor, "5aca4d189052212118709018842178c0");
- mCursorNamesMap.insert(OpenHandCursor, "9d800788f1b08800ae810202380a0822");
-
- mCursorNamesMap.insert(ClosedHandCursor, "closedhand");
- mCursorNamesMap.insert(ClosedHandCursor, "grabbing");
- mCursorNamesMap.insert(ClosedHandCursor, "208530c400c041818281048008011002");
-
- mCursorNamesMap.insert(DragCopyCursor, "dnd-copy");
- mCursorNamesMap.insert(DragCopyCursor, "copy");
-
- mCursorNamesMap.insert(DragMoveCursor, "dnd-move");
- mCursorNamesMap.insert(DragMoveCursor, "move");
-
- mCursorNamesMap.insert(DragLinkCursor, "dnd-link");
- mCursorNamesMap.insert(DragLinkCursor, "link");
-
- mCursorNamesMap.insert(ResizeNorthCursor, "n-resize");
- mCursorNamesMap.insert(ResizeNorthCursor, "top_side");
-
- mCursorNamesMap.insert(ResizeSouthCursor, "s-resize");
- mCursorNamesMap.insert(ResizeSouthCursor, "bottom_side");
-
- mCursorNamesMap.insert(ResizeEastCursor, "e-resize");
- mCursorNamesMap.insert(ResizeEastCursor, "right_side");
-
- mCursorNamesMap.insert(ResizeWestCursor, "w-resize");
- mCursorNamesMap.insert(ResizeWestCursor, "left_side");
-
- mCursorNamesMap.insert(ResizeNorthWestCursor, "nw-resize");
- mCursorNamesMap.insert(ResizeNorthWestCursor, "top_left_corner");
-
- mCursorNamesMap.insert(ResizeSouthEastCursor, "se-resize");
- mCursorNamesMap.insert(ResizeSouthEastCursor, "bottom_right_corner");
-
- mCursorNamesMap.insert(ResizeNorthEastCursor, "ne-resize");
- mCursorNamesMap.insert(ResizeNorthEastCursor, "top_right_corner");
-
- mCursorNamesMap.insert(ResizeSouthWestCursor, "sw-resize");
- mCursorNamesMap.insert(ResizeSouthWestCursor, "bottom_left_corner");
+ qCWarning(lcQpaWayland) << "Setting cursor position is not possible on wayland";
}
}
diff --git a/src/client/qwaylandcursor_p.h b/src/client/qwaylandcursor_p.h
index b3df93160..71f9cd1b8 100644
--- a/src/client/qwaylandcursor_p.h
+++ b/src/client/qwaylandcursor_p.h
@@ -68,20 +68,15 @@ namespace QtWaylandClient {
class QWaylandBuffer;
class QWaylandDisplay;
class QWaylandScreen;
+class QWaylandShm;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandCursor : public QPlatformCursor
+class Q_WAYLAND_CLIENT_EXPORT QWaylandCursorTheme
{
public:
- QWaylandCursor(QWaylandScreen *screen);
- ~QWaylandCursor() override;
-
- void changeCursor(QCursor *cursor, QWindow *window) override;
- void pointerEvent(const QMouseEvent &event) override;
- QPoint pos() const override;
- void setPos(const QPoint &pos) override;
-
+ static QWaylandCursorTheme *create(QWaylandShm *shm, int size);
+ static QWaylandCursorTheme *create(QWaylandShm *shm, int size, const QString &themeName);
+ ~QWaylandCursorTheme();
struct wl_cursor_image *cursorImage(Qt::CursorShape shape);
- QSharedPointer<QWaylandBuffer> cursorBitmapImage(const QCursor *cursor);
private:
enum WaylandCursor {
@@ -107,6 +102,7 @@ private:
DragCopyCursor,
DragMoveCursor,
DragLinkCursor,
+ // The following are used for cursors that don't have equivalents in Qt
ResizeNorthCursor = Qt::CustomCursor + 1,
ResizeSouthCursor,
ResizeEastCursor,
@@ -117,13 +113,29 @@ private:
ResizeSouthWestCursor
};
- struct wl_cursor* requestCursor(WaylandCursor shape);
- void initCursorMap();
+ explicit QWaylandCursorTheme(struct ::wl_cursor_theme *theme) : m_theme(theme) {}
+ struct ::wl_cursor *requestCursor(WaylandCursor shape);
+ struct ::wl_cursor_theme *m_theme = nullptr;
+ QMap<WaylandCursor, wl_cursor *> m_cursors;
+};
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandCursor : public QPlatformCursor
+{
+public:
+ QWaylandCursor(QWaylandScreen *screen);
+
+ void changeCursor(QCursor *cursor, QWindow *window) override;
+ void pointerEvent(const QMouseEvent &event) override;
+ QPoint pos() const override;
+ void setPos(const QPoint &pos) override;
+
+ QSharedPointer<QWaylandBuffer> cursorBitmapImage(const QCursor *cursor);
+ struct wl_cursor_image *cursorImage(Qt::CursorShape shape);
+
+private:
QWaylandDisplay *mDisplay = nullptr;
- struct wl_cursor_theme *mCursorTheme = nullptr;
+ QWaylandCursorTheme *mCursorTheme = nullptr;
QPoint mLastPos;
- QMap<WaylandCursor, wl_cursor *> mCursors;
- QMultiMap<WaylandCursor, QByteArray> mCursorNamesMap;
};
}
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
index a9fff410a..c57dc13ad 100644
--- a/src/client/qwaylanddisplay.cpp
+++ b/src/client/qwaylanddisplay.cpp
@@ -41,6 +41,7 @@
#include "qwaylandintegration_p.h"
#include "qwaylandwindow_p.h"
+#include "qwaylandabstractdecoration_p.h"
#include "qwaylandscreen_p.h"
#include "qwaylandcursor_p.h"
#include "qwaylandinputdevice_p.h"
@@ -50,10 +51,10 @@
#if QT_CONFIG(wayland_datadevice)
#include "qwaylanddatadevicemanager_p.h"
#endif
+#if QT_CONFIG(cursor)
+#include <wayland-cursor.h>
+#endif
#include "qwaylandhardwareintegration_p.h"
-#include "qwaylandxdgshell_p.h"
-#include "qwaylandxdgsurface_p.h"
-#include "qwaylandwlshellsurface_p.h"
#include "qwaylandinputcontext_p.h"
#include "qwaylandwindowmanagerintegration_p.h"
@@ -66,7 +67,6 @@
#include "qwaylandqtkey_p.h"
#include <QtWaylandClient/private/qwayland-text-input-unstable-v2.h>
-#include <QtWaylandClient/private/qwayland-xdg-shell.h>
#include <QtCore/QAbstractEventDispatcher>
#include <QtGui/private/qguiapplication_p.h>
@@ -155,9 +155,13 @@ QWaylandDisplay::~QWaylandDisplay(void)
mWaylandIntegration->destroyScreen(screen);
}
mScreens.clear();
+
#if QT_CONFIG(wayland_datadevice)
delete mDndSelectionHandler.take();
#endif
+#if QT_CONFIG(cursor)
+ qDeleteAll(mCursorThemesBySize);
+#endif
if (mDisplay)
wl_display_disconnect(mDisplay);
}
@@ -241,7 +245,6 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
mScreens.append(screen);
// We need to get the output events before creating surfaces
forceRoundTrip();
- screen->init();
mWaylandIntegration->screenAdded(screen);
} else if (interface == QStringLiteral("wl_compositor")) {
mCompositorVersion = qMin((int)version, 3);
@@ -261,7 +264,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
mSubCompositor.reset(new QtWayland::wl_subcompositor(registry, id, 1));
} else if (interface == QStringLiteral("qt_touch_extension")) {
mTouchExtension.reset(new QWaylandTouchExtension(this, id));
- } else if (interface == QStringLiteral("qt_key_extension")) {
+ } else if (interface == QStringLiteral("zqt_key_v1")) {
mQtKeyExtension.reset(new QWaylandQtKeyExtension(this, id));
} else if (interface == QStringLiteral("zwp_text_input_manager_v2")) {
mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
@@ -273,6 +276,11 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
// make a roundtrip here since we need to receive the events sent by
// qt_hardware_integration before creating windows
forceRoundTrip();
+ } else if (interface == QLatin1String("zxdg_output_manager_v1")) {
+ mXdgOutputManager.reset(new QtWayland::zxdg_output_manager_v1(registry, id, 1));
+ for (auto *screen : qAsConst(mScreens))
+ screen->initXdgOutput(xdgOutputManager());
+ forceRoundTrip();
}
mGlobals.append(RegistryGlobal(id, interface, version, registry));
@@ -318,6 +326,13 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
(*l.listener)(l.data, mGlobals[i].registry, mGlobals[i].id, mGlobals[i].interface, mGlobals[i].version);
}
+void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+{
+ std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+ return (l.listener == listener && l.data == data);
+ });
+}
+
uint32_t QWaylandDisplay::currentTimeMillisec()
{
//### we throw away the time information
@@ -398,6 +413,11 @@ void QWaylandDisplay::setLastInputDevice(QWaylandInputDevice *device, uint32_t s
mLastInputWindow = win;
}
+bool QWaylandDisplay::isWindowActivated(const QWaylandWindow *window)
+{
+ return mActiveWindows.contains(const_cast<QWaylandWindow *>(window));
+}
+
void QWaylandDisplay::handleWindowActivated(QWaylandWindow *window)
{
if (mActiveWindows.contains(window))
@@ -405,6 +425,9 @@ void QWaylandDisplay::handleWindowActivated(QWaylandWindow *window)
mActiveWindows.append(window);
requestWaylandSync();
+
+ if (auto *decoration = window->decoration())
+ decoration->update();
}
void QWaylandDisplay::handleWindowDeactivated(QWaylandWindow *window)
@@ -415,6 +438,9 @@ void QWaylandDisplay::handleWindowDeactivated(QWaylandWindow *window)
requestWaylandSync();
mActiveWindows.removeOne(window);
+
+ if (auto *decoration = window->decoration())
+ decoration->update();
}
void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice)
@@ -477,25 +503,46 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
}
#if QT_CONFIG(cursor)
-void QWaylandDisplay::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image)
+
+void QWaylandDisplay::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image, qreal dpr)
{
/* Qt doesn't tell us which input device we should set the cursor
* for, so set it for all devices. */
for (int i = 0; i < mInputDevices.count(); i++) {
QWaylandInputDevice *inputDevice = mInputDevices.at(i);
- inputDevice->setCursor(buffer, image);
+ inputDevice->setCursor(buffer, image, dpr);
}
}
-void QWaylandDisplay::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot)
+void QWaylandDisplay::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot, qreal dpr)
{
/* Qt doesn't tell us which input device we should set the cursor
* for, so set it for all devices. */
for (int i = 0; i < mInputDevices.count(); i++) {
QWaylandInputDevice *inputDevice = mInputDevices.at(i);
- inputDevice->setCursor(buffer, hotSpot);
+ inputDevice->setCursor(buffer, hotSpot, dpr);
+ }
+}
+
+QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(qreal devicePixelRatio)
+{
+ static int cursorSize = qEnvironmentVariableIntValue("XCURSOR_SIZE");
+ if (cursorSize <= 0)
+ cursorSize = 32;
+ if (compositorVersion() >= 3) // set_buffer_scale is not supported on earlier versions
+ cursorSize *= devicePixelRatio;
+
+ if (auto *theme = mCursorThemesBySize.value(cursorSize, nullptr))
+ return theme;
+
+ if (auto *theme = QWaylandCursorTheme::create(shm(), cursorSize)) {
+ mCursorThemesBySize[cursorSize] = theme;
+ return theme;
}
+
+ return nullptr;
}
+
#endif // QT_CONFIG(cursor)
}
diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h
index a65ed320d..71a39dd92 100644
--- a/src/client/qwaylanddisplay_p.h
+++ b/src/client/qwaylanddisplay_p.h
@@ -63,7 +63,6 @@
#include <QtWaylandClient/private/qwayland-wayland.h>
#include <QtWaylandClient/private/qtwaylandclientglobal_p.h>
-#include <QtWaylandClient/private/qwayland-xdg-shell.h>
#include <QtWaylandClient/private/qwaylandshm_p.h>
struct wl_cursor_image;
@@ -75,16 +74,14 @@ class QSocketNotifier;
class QPlatformScreen;
namespace QtWayland {
- class qt_shell;
- class qt_sub_surface_extension;
class qt_surface_extension;
class zwp_text_input_manager_v2;
- class xdg_shell;
+ class zxdg_output_manager_v1;
}
namespace QtWaylandClient {
-Q_DECLARE_LOGGING_CATEGORY(lcQpaWayland);
+Q_WAYLAND_CLIENT_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcQpaWayland);
class QWaylandInputDevice;
class QWaylandBuffer;
@@ -95,11 +92,10 @@ class QWaylandDataDeviceManager;
class QWaylandTouchExtension;
class QWaylandQtKeyExtension;
class QWaylandWindow;
-class QWaylandEventThread;
class QWaylandIntegration;
class QWaylandHardwareIntegration;
-class QWaylandXdgShell;
class QWaylandShellSurface;
+class QWaylandCursorTheme;
typedef void (*RegistryListener)(void *data,
struct wl_registry *registry,
@@ -127,8 +123,9 @@ public:
QWaylandWindowManagerIntegration *windowManagerIntegration() const;
#if QT_CONFIG(cursor)
- void setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image);
- void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot);
+ void setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image, qreal dpr);
+ void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot, qreal dpr);
+ QWaylandCursorTheme *loadCursorTheme(qreal devicePixelRatio);
#endif
struct wl_display *wl_display() const { return mDisplay; }
struct ::wl_registry *wl_registry() { return object(); }
@@ -147,6 +144,8 @@ public:
QWaylandTouchExtension *touchExtension() const { return mTouchExtension.data(); }
QtWayland::zwp_text_input_manager_v2 *textInputManager() const { return mTextInputManager.data(); }
QWaylandHardwareIntegration *hardwareIntegration() const { return mHardwareIntegration.data(); }
+ QtWayland::zxdg_output_manager_v1 *xdgOutputManager() const { return mXdgOutputManager.data(); }
+
struct RegistryGlobal {
uint32_t id;
@@ -162,6 +161,7 @@ public:
/* wl_registry_add_listener does not add but rather sets a listener, so this function is used
* to enable many listeners at once. */
void addRegistryListener(RegistryListener listener, void *data);
+ void removeListener(RegistryListener listener, void *data);
QWaylandShm *shm() const { return mShm.data(); }
@@ -176,6 +176,7 @@ public:
QWaylandWindow *lastInputWindow() const;
void setLastInputDevice(QWaylandInputDevice *device, uint32_t serial, QWaylandWindow *window);
+ bool isWindowActivated(const QWaylandWindow *window);
void handleWindowActivated(QWaylandWindow *window);
void handleWindowDeactivated(QWaylandWindow *window);
void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
@@ -205,6 +206,9 @@ private:
QList<QWaylandInputDevice *> mInputDevices;
QList<Listener> mRegistryListeners;
QWaylandIntegration *mWaylandIntegration = nullptr;
+#if QT_CONFIG(cursor)
+ QMap<int, QWaylandCursorTheme *> mCursorThemesBySize;
+#endif
#if QT_CONFIG(wayland_datadevice)
QScopedPointer<QWaylandDataDeviceManager> mDndSelectionHandler;
#endif
@@ -215,6 +219,7 @@ private:
QScopedPointer<QWaylandWindowManagerIntegration> mWindowManagerIntegration;
QScopedPointer<QtWayland::zwp_text_input_manager_v2> mTextInputManager;
QScopedPointer<QWaylandHardwareIntegration> mHardwareIntegration;
+ QScopedPointer<QtWayland::zxdg_output_manager_v1> mXdgOutputManager;
QSocketNotifier *mReadNotifier = nullptr;
int mFd;
int mWritableNotificationFd;
diff --git a/src/client/qwaylanddnd.cpp b/src/client/qwaylanddnd.cpp
index fe620506d..b01a9db36 100644
--- a/src/client/qwaylanddnd.cpp
+++ b/src/client/qwaylanddnd.cpp
@@ -77,15 +77,19 @@ void QWaylandDrag::cancel()
m_display->currentInputDevice()->dataDevice()->cancelDrag();
}
-void QWaylandDrag::move(const QPoint &globalPos)
+void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
{
Q_UNUSED(globalPos);
+ Q_UNUSED(b);
+ Q_UNUSED(mods);
// Do nothing
}
-void QWaylandDrag::drop(const QPoint &globalPos)
+void QWaylandDrag::drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
{
Q_UNUSED(globalPos);
+ Q_UNUSED(b);
+ Q_UNUSED(mods);
// Do nothing
}
diff --git a/src/client/qwaylanddnd_p.h b/src/client/qwaylanddnd_p.h
index 04b39826c..474fe2ab1 100644
--- a/src/client/qwaylanddnd_p.h
+++ b/src/client/qwaylanddnd_p.h
@@ -78,8 +78,8 @@ public:
protected:
void startDrag() override;
void cancel() override;
- void move(const QPoint &globalPos) override;
- void drop(const QPoint &globalPos) override;
+ void move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+ void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
void endDrag() override;
diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp
index 93344d13f..b4b7c4ef3 100644
--- a/src/client/qwaylandinputdevice.cpp
+++ b/src/client/qwaylandinputdevice.cpp
@@ -371,7 +371,7 @@ void QWaylandInputDevice::setCursor(Qt::CursorShape newShape, QWaylandScreen *sc
}
struct wl_buffer *buffer = wl_cursor_image_get_buffer(image);
- setCursor(buffer, image);
+ setCursor(buffer, image, screen->devicePixelRatio());
}
void QWaylandInputDevice::setCursor(const QCursor &cursor, QWaylandScreen *screen)
@@ -381,20 +381,26 @@ void QWaylandInputDevice::setCursor(const QCursor &cursor, QWaylandScreen *scree
mPointer->mCursorShape = cursor.shape();
if (cursor.shape() == Qt::BitmapCursor) {
- setCursor(screen->waylandCursor()->cursorBitmapImage(&cursor), cursor.hotSpot());
+ setCursor(screen->waylandCursor()->cursorBitmapImage(&cursor), cursor.hotSpot(), screen->devicePixelRatio());
return;
}
setCursor(cursor.shape(), screen);
}
-void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image)
+void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image, int bufferScale)
{
- setCursor(buffer,
- image ? QPoint(image->hotspot_x, image->hotspot_y) : QPoint(),
- image ? QSize(image->width, image->height) : QSize());
+ if (image) {
+ // Convert from pixel coordinates to surface coordinates
+ QPoint hotspot = QPoint(image->hotspot_x, image->hotspot_y) / bufferScale;
+ QSize size = QSize(image->width, image->height) / bufferScale;
+ setCursor(buffer, hotspot, size, bufferScale);
+ } else {
+ setCursor(buffer, QPoint(), QSize(), bufferScale);
+ }
}
-void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size)
+// size and hotspot are in surface coordinates
+void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size, int bufferScale)
{
if (mCaps & WL_SEAT_CAPABILITY_POINTER) {
bool force = mPointer->mEnterSerial > mPointer->mCursorSerial;
@@ -417,14 +423,16 @@ void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, const QPoint &hotS
mPointer->set_cursor(mPointer->mEnterSerial, pointerSurface,
hotSpot.x(), hotSpot.y());
wl_surface_attach(pointerSurface, buffer, 0, 0);
+ if (mQDisplay->compositorVersion() >= 3)
+ wl_surface_set_buffer_scale(pointerSurface, bufferScale);
wl_surface_damage(pointerSurface, 0, 0, size.width(), size.height());
wl_surface_commit(pointerSurface);
}
}
-void QWaylandInputDevice::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot)
+void QWaylandInputDevice::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot, int bufferScale)
{
- setCursor(buffer->buffer(), hotSpot, buffer->size());
+ setCursor(buffer->buffer(), hotSpot, buffer->size(), bufferScale);
mPixmapCursor = buffer;
}
#endif
diff --git a/src/client/qwaylandinputdevice_p.h b/src/client/qwaylandinputdevice_p.h
index 48c1cf57f..4b12cc089 100644
--- a/src/client/qwaylandinputdevice_p.h
+++ b/src/client/qwaylandinputdevice_p.h
@@ -110,9 +110,9 @@ public:
#if QT_CONFIG(cursor)
void setCursor(const QCursor &cursor, QWaylandScreen *screen);
- void setCursor(struct wl_buffer *buffer, struct ::wl_cursor_image *image);
- void setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size);
- void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot);
+ void setCursor(struct wl_buffer *buffer, struct ::wl_cursor_image *image, int bufferScale);
+ void setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size, int bufferScale);
+ void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot, int bufferScale);
#endif
void handleWindowDestroyed(QWaylandWindow *window);
void handleEndDrag();
diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp
index 6b2faf0c4..e935ef31f 100644
--- a/src/client/qwaylandintegration.cpp
+++ b/src/client/qwaylandintegration.cpp
@@ -82,9 +82,6 @@
#include "qwaylandshellintegration_p.h"
#include "qwaylandshellintegrationfactory_p.h"
-#include "qwaylandxdgshellintegration_p.h"
-#include "qwaylandwlshellintegration_p.h"
-#include "qwaylandxdgshellv6integration_p.h"
#include "qwaylandinputdeviceintegration_p.h"
#include "qwaylandinputdeviceintegrationfactory_p.h"
@@ -393,13 +390,14 @@ void QWaylandIntegration::initializeShellIntegration()
{
mShellIntegrationInitialized = true;
- QByteArray integrationName = qgetenv("QT_WAYLAND_SHELL_INTEGRATION");
- QString targetKey = QString::fromLocal8Bit(integrationName);
+ QByteArray integrationNames = qgetenv("QT_WAYLAND_SHELL_INTEGRATION");
+ QString targetKeys = QString::fromLocal8Bit(integrationNames);
QStringList preferredShells;
- if (!targetKey.isEmpty()) {
- preferredShells << targetKey;
+ if (!targetKeys.isEmpty()) {
+ preferredShells = targetKeys.split(QLatin1Char(';'));
} else {
+ preferredShells << QLatin1String("xdg-shell");
preferredShells << QLatin1String("xdg-shell-v6");
QString useXdgShell = QString::fromLocal8Bit(qgetenv("QT_WAYLAND_USE_XDG_SHELL"));
if (!useXdgShell.isEmpty() && useXdgShell != QLatin1String("0")) {
@@ -418,9 +416,9 @@ void QWaylandIntegration::initializeShellIntegration()
}
}
- if (!mShellIntegration || !mShellIntegration->initialize(mDisplay.data())) {
- mShellIntegration.reset();
- qWarning("Failed to load shell integration %s", qPrintable(targetKey));
+ if (!mShellIntegration) {
+ qCWarning(lcQpaWayland) << "Loading shell integration failed.";
+ qCWarning(lcQpaWayland) << "Attempted to load the following shells" << preferredShells;
}
}
@@ -452,15 +450,10 @@ void QWaylandIntegration::initializeInputDeviceIntegration()
QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
{
- if (integrationName == QLatin1Literal("wl-shell")) {
- return QWaylandWlShellIntegration::create(mDisplay.data());
- } else if (integrationName == QLatin1Literal("xdg-shell-v5")) {
- return QWaylandXdgShellIntegration::create(mDisplay.data());
- } else if (integrationName == QLatin1Literal("xdg-shell-v6")) {
- return QWaylandXdgShellV6Integration::create(mDisplay.data());
- } else if (QWaylandShellIntegrationFactory::keys().contains(integrationName)) {
- return QWaylandShellIntegrationFactory::create(integrationName, QStringList());
+ if (QWaylandShellIntegrationFactory::keys().contains(integrationName)) {
+ return QWaylandShellIntegrationFactory::create(integrationName, mDisplay.data());
} else {
+ qCWarning(lcQpaWayland) << "No shell integration named" << integrationName << "found";
return nullptr;
}
}
diff --git a/src/client/qwaylandintegration_p.h b/src/client/qwaylandintegration_p.h
index 8c34e7198..a5a3d7b69 100644
--- a/src/client/qwaylandintegration_p.h
+++ b/src/client/qwaylandintegration_p.h
@@ -117,7 +117,8 @@ public:
virtual QWaylandShellIntegration *shellIntegration() const;
private:
- // NOTE: mDisplay *must* be destructed after mDrag and mClientBufferIntegration.
+ // NOTE: mDisplay *must* be destructed after mDrag and mClientBufferIntegration
+ // and mShellIntegration.
// Do not move this definition into the private section at the bottom.
QScopedPointer<QWaylandDisplay> mDisplay;
diff --git a/src/client/qwaylandnativeinterface.cpp b/src/client/qwaylandnativeinterface.cpp
index 9946c3235..76acb526b 100644
--- a/src/client/qwaylandnativeinterface.cpp
+++ b/src/client/qwaylandnativeinterface.cpp
@@ -40,13 +40,13 @@
#include "qwaylandnativeinterface_p.h"
#include "qwaylanddisplay_p.h"
#include "qwaylandwindow_p.h"
+#include "qwaylandshellintegration_p.h"
#include "qwaylandsubsurface_p.h"
#include "qwaylandextendedsurface_p.h"
#include "qwaylandintegration_p.h"
#include "qwaylanddisplay_p.h"
#include "qwaylandwindowmanagerintegration_p.h"
#include "qwaylandscreen_p.h"
-#include "qwaylandwlshellsurface_p.h"
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/QScreen>
#include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h>
@@ -91,18 +91,13 @@ void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourc
QWaylandWindow *w = static_cast<QWaylandWindow*>(window->handle());
return w ? w->object() : nullptr;
}
- if (lowerCaseResource == "wl_shell_surface") {
- QWaylandWindow *w = static_cast<QWaylandWindow*>(window->handle());
- if (!w)
- return nullptr;
- QWaylandWlShellSurface *s = qobject_cast<QWaylandWlShellSurface *>(w->shellSurface());
- if (!s)
- return nullptr;
- return s->object();
- }
+
if (lowerCaseResource == "egldisplay" && m_integration->clientBufferIntegration())
return m_integration->clientBufferIntegration()->nativeResource(QWaylandClientBufferIntegration::EglDisplay);
+ if (auto shellIntegration = m_integration->shellIntegration())
+ return shellIntegration->nativeResourceForWindow(resourceString, window);
+
return nullptr;
}
diff --git a/src/client/qwaylandqtkey.cpp b/src/client/qwaylandqtkey.cpp
index ce0d2124e..a60185bd6 100644
--- a/src/client/qwaylandqtkey.cpp
+++ b/src/client/qwaylandqtkey.cpp
@@ -46,12 +46,12 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
QWaylandQtKeyExtension::QWaylandQtKeyExtension(QWaylandDisplay *display, uint32_t id)
- : QtWayland::qt_key_extension(display->wl_registry(), id, 2)
+ : QtWayland::zqt_key_v1(display->wl_registry(), id, 1)
, m_display(display)
{
}
-void QWaylandQtKeyExtension::key_extension_qtkey(struct wl_surface *surface,
+void QWaylandQtKeyExtension::zqt_key_v1_key(struct wl_surface *surface,
uint32_t time,
uint32_t type,
uint32_t key,
diff --git a/src/client/qwaylandqtkey_p.h b/src/client/qwaylandqtkey_p.h
index 9091cf819..117c44a6d 100644
--- a/src/client/qwaylandqtkey_p.h
+++ b/src/client/qwaylandqtkey_p.h
@@ -54,7 +54,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
-#include <QtWaylandClient/private/qwayland-qtkey-extension.h>
+#include <QtWaylandClient/private/qwayland-qt-key-unstable-v1.h>
QT_BEGIN_NAMESPACE
@@ -62,7 +62,7 @@ namespace QtWaylandClient {
class QWaylandDisplay;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandQtKeyExtension : public QtWayland::qt_key_extension
+class Q_WAYLAND_CLIENT_EXPORT QWaylandQtKeyExtension : public QtWayland::zqt_key_v1
{
public:
QWaylandQtKeyExtension(QWaylandDisplay *display, uint32_t id);
@@ -70,17 +70,17 @@ public:
private:
QWaylandDisplay *m_display = nullptr;
- void key_extension_qtkey(struct wl_surface *surface,
- uint32_t time,
- uint32_t type,
- uint32_t key,
- uint32_t modifiers,
- uint32_t nativeScanCode,
- uint32_t nativeVirtualKey,
- uint32_t nativeModifiers,
- const QString &text,
- uint32_t autorep,
- uint32_t count) override;
+ void zqt_key_v1_key(struct wl_surface *surface,
+ uint32_t time,
+ uint32_t type,
+ uint32_t key,
+ uint32_t modifiers,
+ uint32_t nativeScanCode,
+ uint32_t nativeVirtualKey,
+ uint32_t nativeModifiers,
+ const QString &text,
+ uint32_t autorep,
+ uint32_t count) override;
};
diff --git a/src/client/qwaylandscreen.cpp b/src/client/qwaylandscreen.cpp
index 38d97a91d..38d61f88c 100644
--- a/src/client/qwaylandscreen.cpp
+++ b/src/client/qwaylandscreen.cpp
@@ -58,20 +58,23 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
, mWaylandDisplay(waylandDisplay)
, mOutputName(QStringLiteral("Screen%1").arg(id))
{
+ if (auto *xdgOutputManager = waylandDisplay->xdgOutputManager())
+ initXdgOutput(xdgOutputManager);
}
QWaylandScreen::~QWaylandScreen()
{
-#if QT_CONFIG(cursor)
- delete mWaylandCursor;
-#endif
+ if (zxdg_output_v1::isInitialized())
+ zxdg_output_v1::destroy();
}
-void QWaylandScreen::init()
+void QWaylandScreen::initXdgOutput(QtWayland::zxdg_output_manager_v1 *xdgOutputManager)
{
-#if QT_CONFIG(cursor)
- mWaylandCursor = new QWaylandCursor(this);
-#endif
+ Q_ASSERT(xdgOutputManager);
+ if (zxdg_output_v1::isInitialized())
+ return;
+
+ zxdg_output_v1::init(xdgOutputManager->get_xdg_output(wl_output::object()));
}
QWaylandDisplay * QWaylandScreen::display() const
@@ -91,9 +94,13 @@ QString QWaylandScreen::model() const
QRect QWaylandScreen::geometry() const
{
- // Scale geometry for QScreen. This makes window and screen
- // geometry be in the same coordinate system.
- return QRect(mGeometry.topLeft(), mGeometry.size() / mScale);
+ if (zxdg_output_v1::isInitialized()) {
+ return mXdgGeometry;
+ } else {
+ // Scale geometry for QScreen. This makes window and screen
+ // geometry be in the same coordinate system.
+ return QRect(mGeometry.topLeft(), mGeometry.size() / mScale);
+ }
}
int QWaylandScreen::depth() const
@@ -116,11 +123,15 @@ QSizeF QWaylandScreen::physicalSize() const
QDpi QWaylandScreen::logicalDpi() const
{
- static int force_dpi = !qgetenv("QT_WAYLAND_FORCE_DPI").isEmpty() ? qgetenv("QT_WAYLAND_FORCE_DPI").toInt() : -1;
- if (force_dpi > 0)
- return QDpi(force_dpi, force_dpi);
+ static bool physicalDpi = qEnvironmentVariable("QT_WAYLAND_FORCE_DPI") == QStringLiteral("physical");
+ if (physicalDpi)
+ return QPlatformScreen::logicalDpi();
+
+ static int forceDpi = qgetenv("QT_WAYLAND_FORCE_DPI").toInt();
+ if (forceDpi)
+ return QDpi(forceDpi, forceDpi);
- return QPlatformScreen::logicalDpi();
+ return QDpi(96, 96);
}
QList<QPlatformScreen *> QWaylandScreen::virtualSiblings() const
@@ -165,11 +176,20 @@ qreal QWaylandScreen::refreshRate() const
}
#if QT_CONFIG(cursor)
+
QPlatformCursor *QWaylandScreen::cursor() const
{
- return mWaylandCursor;
+ return const_cast<QWaylandScreen *>(this)->waylandCursor();
+}
+
+QWaylandCursor *QWaylandScreen::waylandCursor()
+{
+ if (!mWaylandCursor)
+ mWaylandCursor.reset(new QWaylandCursor(this));
+ return mWaylandCursor.data();
}
-#endif
+
+#endif // QT_CONFIG(cursor)
QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window)
{
@@ -189,7 +209,6 @@ void QWaylandScreen::output_mode(uint32_t flags, int width, int height, int refr
return;
QSize size(width, height);
-
if (size != mGeometry.size())
mGeometry.setSize(size);
@@ -252,8 +271,25 @@ void QWaylandScreen::output_done()
QWindowSystemInterface::handleScreenOrientationChange(screen(), m_orientation);
mTransform = -1;
}
- QWindowSystemInterface::handleScreenGeometryChange(screen(), geometry(), geometry());
QWindowSystemInterface::handleScreenRefreshRateChange(screen(), refreshRate());
+ if (!zxdg_output_v1::isInitialized())
+ QWindowSystemInterface::handleScreenGeometryChange(screen(), geometry(), geometry());
+}
+
+
+void QWaylandScreen::zxdg_output_v1_logical_position(int32_t x, int32_t y)
+{
+ mXdgGeometry.moveTopLeft(QPoint(x, y));
+}
+
+void QWaylandScreen::zxdg_output_v1_logical_size(int32_t width, int32_t height)
+{
+ mXdgGeometry.setSize(QSize(width, height));
+}
+
+void QWaylandScreen::zxdg_output_v1_done()
+{
+ QWindowSystemInterface::handleScreenGeometryChange(screen(), geometry(), geometry());
}
}
diff --git a/src/client/qwaylandscreen_p.h b/src/client/qwaylandscreen_p.h
index 9df55d603..6e4ed94f7 100644
--- a/src/client/qwaylandscreen_p.h
+++ b/src/client/qwaylandscreen_p.h
@@ -55,6 +55,8 @@
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtWaylandClient/private/qwayland-wayland.h>
+#include <QtWaylandClient/private/qwayland-xdg-output-unstable-v1.h>
+
QT_BEGIN_NAMESPACE
@@ -63,13 +65,14 @@ namespace QtWaylandClient {
class QWaylandDisplay;
class QWaylandCursor;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandScreen : public QPlatformScreen, QtWayland::wl_output
+class Q_WAYLAND_CLIENT_EXPORT QWaylandScreen : public QPlatformScreen, QtWayland::wl_output, QtWayland::zxdg_output_v1
{
public:
QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id);
~QWaylandScreen() override;
- void init();
+ void initXdgOutput(QtWayland::zxdg_output_manager_v1 *xdgOutputManager);
+
QWaylandDisplay *display() const;
QString manufacturer() const override;
@@ -95,11 +98,11 @@ public:
#if QT_CONFIG(cursor)
QPlatformCursor *cursor() const override;
- QWaylandCursor *waylandCursor() const { return mWaylandCursor; }
+ QWaylandCursor *waylandCursor();
#endif
uint32_t outputId() const { return m_outputId; }
- ::wl_output *output() { return object(); }
+ ::wl_output *output() { return QtWayland::wl_output::object(); }
static QWaylandScreen *waylandScreenFromWindow(QWindow *window);
static QWaylandScreen *fromWlOutput(::wl_output *output);
@@ -115,11 +118,17 @@ private:
void output_scale(int32_t factor) override;
void output_done() override;
+ // XdgOutput
+ void zxdg_output_v1_logical_position(int32_t x, int32_t y) override;
+ void zxdg_output_v1_logical_size(int32_t width, int32_t height) override;
+ void zxdg_output_v1_done() override;
+
int m_outputId;
QWaylandDisplay *mWaylandDisplay = nullptr;
QString mManufacturer;
QString mModel;
QRect mGeometry;
+ QRect mXdgGeometry;
int mScale = 1;
int mDepth = 32;
int mRefreshRate = 60000;
@@ -130,7 +139,7 @@ private:
Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
#if QT_CONFIG(cursor)
- QWaylandCursor *mWaylandCursor = nullptr;
+ QScopedPointer<QWaylandCursor> mWaylandCursor;
#endif
};
diff --git a/src/client/qwaylandshellsurface_p.h b/src/client/qwaylandshellsurface_p.h
index fdc309a63..6bc3258c7 100644
--- a/src/client/qwaylandshellsurface_p.h
+++ b/src/client/qwaylandshellsurface_p.h
@@ -95,13 +95,9 @@ public:
inline QWaylandWindow *window() { return m_window; }
- virtual void setType(Qt::WindowType type, QWaylandWindow *transientParent) = 0;
-
-protected:
- virtual void setMaximized() {}
- virtual void setFullscreen() {}
- virtual void setNormal() {}
- virtual void setMinimized() {}
+ virtual void applyConfigure() {}
+ virtual void requestWindowStates(Qt::WindowStates states) {Q_UNUSED(states);}
+ virtual bool wantsDecorations() const { return false; }
private:
QWaylandWindow *m_window = nullptr;
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index 7149a2adb..e58e87221 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -44,8 +44,6 @@
#include "qwaylandinputdevice_p.h"
#include "qwaylandscreen_p.h"
#include "qwaylandshellsurface_p.h"
-#include "qwaylandwlshellsurface_p.h"
-#include "qwaylandxdgsurface_p.h"
#include "qwaylandsubsurface_p.h"
#include "qwaylandabstractdecoration_p.h"
#include "qwaylandwindowmanagerintegration_p.h"
@@ -143,8 +141,6 @@ void QWaylandWindow::initWindow()
mShellSurface = mDisplay->createShellSurface(this);
if (mShellSurface) {
- mShellSurface->setType(window()->type(), transientParent());
-
// Set initial surface title
setWindowTitle(window()->title());
@@ -202,11 +198,8 @@ void QWaylandWindow::initWindow()
else
setGeometry_helper(window()->geometry());
setMask(window()->mask());
- // setWindowStateInternal is a no-op if the argument is equal to mState,
- // but since we're creating the shellsurface only now we reset mState to
- // make sure the state gets sent out to the compositor
- mState = Qt::WindowNoState;
- setWindowStateInternal(window()->windowStates());
+ if (mShellSurface)
+ mShellSurface->requestWindowStates(window()->windowStates());
handleContentOrientationChange(window()->contentOrientation());
mFlags = window()->flags();
}
@@ -347,7 +340,16 @@ void QWaylandWindow::setGeometry(const QRect &rect)
sendExposeEvent(QRect(QPoint(), geometry().size()));
}
+void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+{
+ QMargins margins = frameMargins();
+ int widthWithoutMargins = qMax(sizeWithMargins.width() - (margins.left()+margins.right()), 1);
+ int heightWithoutMargins = qMax(sizeWithMargins.height() - (margins.top()+margins.bottom()), 1);
+ QRect geometry(QPoint(), QSize(widthWithoutMargins, heightWithoutMargins));
+ mOffset += offset;
+ setGeometry(geometry);
+}
void QWaylandWindow::sendExposeEvent(const QRect &rect)
{
@@ -435,46 +437,24 @@ void QWaylandWindow::setMask(const QRegion &mask)
wl_surface::commit();
}
-void QWaylandWindow::configure(uint32_t edges, int32_t width, int32_t height)
+void QWaylandWindow::applyConfigureWhenPossible()
{
QMutexLocker resizeLocker(&mResizeLock);
- mConfigure.edges |= edges;
- mConfigure.width = width;
- mConfigure.height = height;
-
- if (!mRequestResizeSent && !mConfigure.isEmpty()) {
- mRequestResizeSent= true;
- QMetaObject::invokeMethod(this, "requestResize", Qt::QueuedConnection);
+ if (!mWaitingToApplyConfigure) {
+ mWaitingToApplyConfigure = true;
+ QMetaObject::invokeMethod(this, "applyConfigure", Qt::QueuedConnection);
}
}
-void QWaylandWindow::doResize()
+void QWaylandWindow::doApplyConfigure()
{
- if (mConfigure.isEmpty()) {
+ if (!mWaitingToApplyConfigure)
return;
- }
-
- int widthWithoutMargins = qMax(mConfigure.width-(frameMargins().left() +frameMargins().right()),1);
- int heightWithoutMargins = qMax(mConfigure.height-(frameMargins().top()+frameMargins().bottom()),1);
- widthWithoutMargins = qMax(widthWithoutMargins, window()->minimumSize().width());
- heightWithoutMargins = qMax(heightWithoutMargins, window()->minimumSize().height());
- QRect geometry = QRect(0,0, widthWithoutMargins, heightWithoutMargins);
-
- int x = 0;
- int y = 0;
- QSize size = this->geometry().size();
- if (mConfigure.edges & WL_SHELL_SURFACE_RESIZE_LEFT) {
- x = size.width() - geometry.width();
- }
- if (mConfigure.edges & WL_SHELL_SURFACE_RESIZE_TOP) {
- y = size.height() - geometry.height();
- }
- mOffset += QPoint(x, y);
-
- setGeometry(geometry);
+ if (mShellSurface)
+ mShellSurface->applyConfigure();
- mConfigure.clear();
+ mWaitingToApplyConfigure = false;
}
void QWaylandWindow::setCanResize(bool canResize)
@@ -486,8 +466,8 @@ void QWaylandWindow::setCanResize(bool canResize)
if (mResizeDirty) {
QWindowSystemInterface::handleGeometryChange(window(), geometry());
}
- if (!mConfigure.isEmpty()) {
- doResize();
+ if (mWaitingToApplyConfigure) {
+ doApplyConfigure();
sendExposeEvent(QRect(QPoint(), geometry().size()));
} else if (mResizeDirty) {
mResizeDirty = false;
@@ -496,15 +476,13 @@ void QWaylandWindow::setCanResize(bool canResize)
}
}
-void QWaylandWindow::requestResize()
+void QWaylandWindow::applyConfigure()
{
QMutexLocker lock(&mResizeLock);
- if (mCanResize || !mSentInitialResize) {
- doResize();
- }
+ if (mCanResize || !mSentInitialResize)
+ doApplyConfigure();
- mRequestResizeSent = false;
lock.unlock();
sendExposeEvent(QRect(QPoint(), geometry().size()));
QWindowSystemInterface::flushWindowSystemEvents();
@@ -617,9 +595,8 @@ void QWaylandWindow::frameCallback(void *data, struct wl_callback *callback, uin
self->mWaitingForFrameSync = false;
if (self->mUpdateRequested) {
- QWindowPrivate *w = QWindowPrivate::get(self->window());
self->mUpdateRequested = false;
- w->deliverUpdateRequest();
+ self->deliverUpdateRequest();
}
}
@@ -694,10 +671,10 @@ void QWaylandWindow::setOrientationMask(Qt::ScreenOrientations mask)
mShellSurface->setContentOrientationMask(mask);
}
-void QWaylandWindow::setWindowState(Qt::WindowStates state)
+void QWaylandWindow::setWindowState(Qt::WindowStates states)
{
- if (setWindowStateInternal(state))
- QWindowSystemInterface::flushWindowSystemEvents(); // Required for oldState to work on WindowStateChanged
+ if (mShellSurface)
+ mShellSurface->requestWindowStates(states);
}
void QWaylandWindow::setWindowFlags(Qt::WindowFlags flags)
@@ -711,20 +688,6 @@ void QWaylandWindow::setWindowFlags(Qt::WindowFlags flags)
bool QWaylandWindow::createDecoration()
{
- // so far only xdg-shell support this "unminimize" trick, may be moved elsewhere
- if (mState & Qt::WindowMinimized) {
- QWaylandXdgSurface *xdgSurface = qobject_cast<QWaylandXdgSurface *>(mShellSurface);
- if ( xdgSurface ) {
- Qt::WindowStates states;
- if (xdgSurface->isFullscreen())
- states |= Qt::WindowFullScreen;
- if (xdgSurface->isMaximized())
- states |= Qt::WindowMaximized;
-
- setWindowStateInternal(states);
- }
- }
-
if (!mDisplay->supportsWindowDecoration())
return false;
@@ -741,12 +704,14 @@ bool QWaylandWindow::createDecoration()
default:
break;
}
- if (mFlags & Qt::FramelessWindowHint || isFullscreen())
+ if (mFlags & Qt::FramelessWindowHint)
decoration = false;
if (mFlags & Qt::BypassWindowManagerHint)
decoration = false;
if (mSubSurfaceWindow)
decoration = false;
+ if (mShellSurface && !mShellSurface->wantsDecorations())
+ decoration = false;
bool hadDecoration = mWindowDecoration;
if (decoration && !decorationPluginFailed) {
@@ -847,8 +812,13 @@ void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylan
}
#if QT_CONFIG(cursor)
- if (e.type == QWaylandPointerEvent::Enter)
- restoreMouseCursor(inputDevice);
+ if (e.type == QWaylandPointerEvent::Enter) {
+ QRect windowGeometry = window()->frameGeometry();
+ windowGeometry.moveTopLeft({0, 0}); // convert to wayland surface coordinates
+ QRect contentGeometry = windowGeometry.marginsRemoved(frameMargins());
+ if (contentGeometry.contains(e.local.toPoint()))
+ restoreMouseCursor(inputDevice);
+ }
#endif
}
@@ -877,8 +847,10 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe
{
if (mMousePressedInContentArea == Qt::NoButton &&
mWindowDecoration->handleMouse(inputDevice, e.local, e.global, e.buttons, e.modifiers)) {
- if (mMouseEventsInContentArea)
+ if (mMouseEventsInContentArea) {
QWindowSystemInterface::handleLeaveEvent(window());
+ mMouseEventsInContentArea = false;
+ }
return;
}
@@ -971,6 +943,11 @@ bool QWaylandWindow::isExposed() const
return QPlatformWindow::isExposed();
}
+bool QWaylandWindow::isActive() const
+{
+ return mDisplay->isWindowActivated(this);
+}
+
int QWaylandWindow::scale() const
{
return mScale;
@@ -992,31 +969,11 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
return true;
}
-bool QWaylandWindow::setWindowStateInternal(Qt::WindowStates state)
+void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
{
- if (mState == state) {
- return false;
- }
-
- // As of february 2013 QWindow::setWindowState sets the new state value after
- // QPlatformWindow::setWindowState returns, so we cannot rely on QWindow::windowState
- // here. We use then this mState variable.
- mState = state;
-
- if (mShellSurface) {
- createDecoration();
- if (state & Qt::WindowMaximized)
- mShellSurface->setMaximized();
- if (state & Qt::WindowFullScreen)
- mShellSurface->setFullscreen();
- if (state & Qt::WindowMinimized)
- mShellSurface->setMinimized();
- if (!state)
- mShellSurface->setNormal();
- }
-
- QWindowSystemInterface::handleWindowStateChanged(window(), mState);
- return true;
+ createDecoration();
+ QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
+ mLastReportedWindowStates = states;
}
void QWaylandWindow::sendProperty(const QString &name, const QVariant &value)
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
index 366548635..d11ed871b 100644
--- a/src/client/qwaylandwindow_p.h
+++ b/src/client/qwaylandwindow_p.h
@@ -80,23 +80,6 @@ class QWaylandScreen;
class QWaylandShmBackingStore;
class QWaylandPointerEvent;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandWindowConfigure
-{
-public:
- QWaylandWindowConfigure()
- { }
-
- void clear()
- { width = height = edges = 0; }
-
- bool isEmpty() const
- { return !height || !width; }
-
- int width = 0;
- int height = 0;
- uint32_t edges = 0;
-};
-
class Q_WAYLAND_CLIENT_EXPORT QWaylandWindow : public QObject, public QPlatformWindow, public QtWayland::wl_surface
{
Q_OBJECT
@@ -121,8 +104,9 @@ public:
void setWindowIcon(const QIcon &icon) override;
void setGeometry(const QRect &rect) override;
+ void resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset = {0, 0});
- void configure(uint32_t edges, int32_t width, int32_t height);
+ void applyConfigureWhenPossible(); //rename to possible?
using QtWayland::wl_surface::attach;
void attach(QWaylandBuffer *buffer, int x, int y);
@@ -148,8 +132,9 @@ public:
void handleContentOrientationChange(Qt::ScreenOrientation orientation) override;
void setOrientationMask(Qt::ScreenOrientations mask);
- void setWindowState(Qt::WindowStates state) override;
+ void setWindowState(Qt::WindowStates states) override;
void setWindowFlags(Qt::WindowFlags flags) override;
+ void handleWindowStatesChanged(Qt::WindowStates states);
void raise() override;
void lower() override;
@@ -161,6 +146,7 @@ public:
void requestActivateWindow() override;
bool isExposed() const override;
+ bool isActive() const override;
void unfocus();
QWaylandAbstractDecoration *decoration() const;
@@ -173,9 +159,6 @@ public:
bool createDecoration();
- inline bool isMaximized() const { return mState & Qt::WindowMaximized; }
- inline bool isFullscreen() const { return mState & Qt::WindowFullScreen; }
-
#if QT_CONFIG(cursor)
void setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor);
void restoreMouseCursor(QWaylandInputDevice *device);
@@ -184,7 +167,7 @@ public:
QWaylandWindow *transientParent() const;
QMutex *resizeMutex() { return &mResizeLock; }
- void doResize();
+ void doApplyConfigure();
void setCanResize(bool canResize);
bool setMouseGrabEnabled(bool grab) override;
@@ -209,7 +192,7 @@ public:
void requestUpdate() override;
public slots:
- void requestResize();
+ void applyConfigure();
protected:
void surface_enter(struct ::wl_output *output) override;
@@ -231,8 +214,7 @@ protected:
QWaitCondition mFrameSyncWait;
QMutex mResizeLock;
- QWaylandWindowConfigure mConfigure;
- bool mRequestResizeSent = false;
+ bool mWaitingToApplyConfigure = false;
bool mCanResize = true;
bool mResizeDirty = false;
bool mResizeAfterSwap;
@@ -244,9 +226,9 @@ protected:
QIcon mWindowIcon;
- Qt::WindowStates mState = Qt::WindowNoState;
Qt::WindowFlags mFlags;
QRegion mMask;
+ Qt::WindowStates mLastReportedWindowStates = Qt::WindowNoState;
QWaylandShmBackingStore *mBackingStore = nullptr;
@@ -254,7 +236,6 @@ private slots:
void handleScreenRemoved(QScreen *qScreen);
private:
- bool setWindowStateInternal(Qt::WindowStates flags);
void setGeometry_helper(const QRect &rect);
void initWindow();
void initializeWlSurface();
diff --git a/src/client/qwaylandxdgsurface.cpp b/src/client/qwaylandxdgsurface.cpp
deleted file mode 100644
index 42738528c..000000000
--- a/src/client/qwaylandxdgsurface.cpp
+++ /dev/null
@@ -1,257 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the config.tests of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwaylandxdgsurface_p.h"
-
-#include "qwaylanddisplay_p.h"
-#include "qwaylandwindow_p.h"
-#include "qwaylandinputdevice_p.h"
-#include "qwaylandabstractdecoration_p.h"
-#include "qwaylandscreen_p.h"
-#include "qwaylandextendedsurface_p.h"
-#include "qwaylandxdgshell_p.h"
-
-
-QT_BEGIN_NAMESPACE
-
-namespace QtWaylandClient {
-
-QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, QWaylandWindow *window)
- : QWaylandShellSurface(window)
- , QtWayland::xdg_surface(shell->get_xdg_surface(window->object()))
- , m_window(window)
- , m_shell(shell)
-{
- if (window->display()->windowExtension())
- m_extendedWindow = new QWaylandExtendedSurface(window);
-}
-
-QWaylandXdgSurface::~QWaylandXdgSurface()
-{
- if (m_active)
- window()->display()->handleWindowDeactivated(m_window);
-
- xdg_surface_destroy(object());
- delete m_extendedWindow;
-}
-
-void QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
-{
- // May need some conversion if types get incompatibles, ATM they're identical
- enum resize_edge const * const arg = reinterpret_cast<enum resize_edge const * const>(&edges);
- resize(inputDevice, *arg);
-}
-
-void QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, enum resize_edge edges)
-{
- resize(inputDevice->wl_seat(),
- inputDevice->serial(),
- edges);
-}
-
-bool QWaylandXdgSurface::move(QWaylandInputDevice *inputDevice)
-{
- move(inputDevice->wl_seat(),
- inputDevice->serial());
- return true;
-}
-
-void QWaylandXdgSurface::setMaximized()
-{
- if (!m_maximized)
- set_maximized();
-}
-
-void QWaylandXdgSurface::setFullscreen()
-{
- if (!m_fullscreen)
- set_fullscreen(nullptr);
-}
-
-void QWaylandXdgSurface::setNormal()
-{
- if (m_fullscreen || m_maximized || m_minimized) {
- if (m_maximized) {
- unset_maximized();
- }
- if (m_fullscreen) {
- unset_fullscreen();
- }
-
- m_fullscreen = m_maximized = m_minimized = false;
- }
-}
-
-void QWaylandXdgSurface::setMinimized()
-{
- m_minimized = true;
- set_minimized();
-}
-
-void QWaylandXdgSurface::updateTransientParent(QWaylandWindow *parent)
-{
- if (!parent)
- return;
- auto parentXdgSurface = qobject_cast<QWaylandXdgSurface *>(parent->shellSurface());
- Q_ASSERT(parentXdgSurface);
- set_parent(parentXdgSurface->object());
-}
-
-void QWaylandXdgSurface::setTitle(const QString & title)
-{
- return QtWayland::xdg_surface::set_title(title);
-}
-
-void QWaylandXdgSurface::setAppId(const QString & appId)
-{
- return QtWayland::xdg_surface::set_app_id(appId);
-}
-
-void QWaylandXdgSurface::raise()
-{
- if (m_extendedWindow)
- m_extendedWindow->raise();
-}
-
-void QWaylandXdgSurface::lower()
-{
- if (m_extendedWindow)
- m_extendedWindow->lower();
-}
-
-void QWaylandXdgSurface::setContentOrientationMask(Qt::ScreenOrientations orientation)
-{
- if (m_extendedWindow)
- m_extendedWindow->setContentOrientationMask(orientation);
-}
-
-void QWaylandXdgSurface::setWindowFlags(Qt::WindowFlags flags)
-{
- if (m_extendedWindow)
- m_extendedWindow->setWindowFlags(flags);
-}
-
-void QWaylandXdgSurface::sendProperty(const QString &name, const QVariant &value)
-{
- if (m_extendedWindow)
- m_extendedWindow->updateGenericProperty(name, value);
-}
-
-void QWaylandXdgSurface::setType(Qt::WindowType type, QWaylandWindow *transientParent)
-{
- Q_UNUSED(type)
- if (transientParent)
- updateTransientParent(transientParent);
-}
-
-void QWaylandXdgSurface::xdg_surface_configure(int32_t width, int32_t height, struct wl_array *states,uint32_t serial)
-{
- uint32_t *state = reinterpret_cast<uint32_t*>(states->data);
- size_t numStates = states->size / sizeof(uint32_t);
- bool aboutToMaximize = false;
- bool aboutToFullScreen = false;
- bool aboutToActivate = false;
-
- for (size_t i = 0; i < numStates; i++) {
- switch (state[i]) {
- case XDG_SURFACE_STATE_MAXIMIZED:
- aboutToMaximize = ((width > 0) && (height > 0));
- break;
- case XDG_SURFACE_STATE_FULLSCREEN:
- aboutToFullScreen = true;
- break;
- case XDG_SURFACE_STATE_RESIZING:
- m_normalSize = QSize(width, height);
- break;
- case XDG_SURFACE_STATE_ACTIVATED:
- aboutToActivate = true;
- break;
- default:
- break;
- }
- }
-
- if (!m_active && aboutToActivate) {
- m_active = true;
- window()->display()->handleWindowActivated(m_window);
- } else if (m_active && !aboutToActivate) {
- m_active = false;
- window()->display()->handleWindowDeactivated(m_window);
- }
-
- if (!m_fullscreen && aboutToFullScreen) {
- if (!m_maximized)
- m_normalSize = m_window->window()->frameGeometry().size();
- m_fullscreen = true;
- m_window->window()->showFullScreen();
- } else if (m_fullscreen && !aboutToFullScreen) {
- m_fullscreen = false;
- if ( m_maximized ) {
- m_window->window()->showMaximized();
- } else {
- m_window->window()->showNormal();
- }
- } else if (!m_maximized && aboutToMaximize) {
- if (!m_fullscreen)
- m_normalSize = m_window->window()->frameGeometry().size();
- m_maximized = true;
- m_window->window()->showMaximized();
- } else if (m_maximized && !aboutToMaximize) {
- m_maximized = false;
- m_window->window()->showNormal();
- }
-
- if (width <= 0 || height <= 0) {
- if (!m_normalSize.isEmpty())
- m_window->configure(0, m_normalSize.width(), m_normalSize.height());
- } else {
- m_window->configure(0, width, height);
- }
-
- ack_configure(serial);
-}
-
-void QWaylandXdgSurface::xdg_surface_close()
-{
- m_window->window()->close();
-}
-
-}
-
-QT_END_NAMESPACE
diff --git a/src/client/shellintegration/qwaylandshellintegration_p.h b/src/client/shellintegration/qwaylandshellintegration_p.h
index 7f3a2cefc..ccad00481 100644
--- a/src/client/shellintegration/qwaylandshellintegration_p.h
+++ b/src/client/shellintegration/qwaylandshellintegration_p.h
@@ -79,6 +79,11 @@ public:
if (oldFocus)
m_display->handleWindowDeactivated(oldFocus);
}
+ virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+ Q_UNUSED(resource);
+ Q_UNUSED(window);
+ return nullptr;
+ }
protected:
QWaylandDisplay *m_display = nullptr;
diff --git a/src/client/shellintegration/qwaylandshellintegrationfactory.cpp b/src/client/shellintegration/qwaylandshellintegrationfactory.cpp
index c5a505bbe..48fda14d4 100644
--- a/src/client/shellintegration/qwaylandshellintegrationfactory.cpp
+++ b/src/client/shellintegration/qwaylandshellintegrationfactory.cpp
@@ -78,19 +78,24 @@ QStringList QWaylandShellIntegrationFactory::keys(const QString &pluginPath)
#endif
}
-QWaylandShellIntegration *QWaylandShellIntegrationFactory::create(const QString &name, const QStringList &args, const QString &pluginPath)
+QWaylandShellIntegration *QWaylandShellIntegrationFactory::create(const QString &name, QWaylandDisplay *display, const QStringList &args, const QString &pluginPath)
{
#if QT_CONFIG(library)
+ QScopedPointer<QWaylandShellIntegration> integration;
+
// Try loading the plugin from platformPluginPath first:
if (!pluginPath.isEmpty()) {
QCoreApplication::addLibraryPath(pluginPath);
- if (QWaylandShellIntegration *ret = qLoadPlugin<QWaylandShellIntegration, QWaylandShellIntegrationPlugin>(directLoader(), name, args))
- return ret;
+ integration.reset(qLoadPlugin<QWaylandShellIntegration, QWaylandShellIntegrationPlugin>(directLoader(), name, args));
}
- if (QWaylandShellIntegration *ret = qLoadPlugin<QWaylandShellIntegration, QWaylandShellIntegrationPlugin>(loader(), name, args))
- return ret;
+ if (!integration)
+ integration.reset(qLoadPlugin<QWaylandShellIntegration, QWaylandShellIntegrationPlugin>(loader(), name, args));
#endif
- return nullptr;
+
+ if (integration && !integration->initialize(display))
+ return nullptr;
+
+ return integration.take();
}
}
diff --git a/src/client/shellintegration/qwaylandshellintegrationfactory_p.h b/src/client/shellintegration/qwaylandshellintegrationfactory_p.h
index 3edb0a89d..515a18e1f 100644
--- a/src/client/shellintegration/qwaylandshellintegrationfactory_p.h
+++ b/src/client/shellintegration/qwaylandshellintegrationfactory_p.h
@@ -51,7 +51,10 @@
// We mean it.
//
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+
#include <QtWaylandClient/qtwaylandclientglobal.h>
+
#include <QtCore/QStringList>
QT_BEGIN_NAMESPACE
@@ -64,7 +67,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandShellIntegrationFactory
{
public:
static QStringList keys(const QString &pluginPath = QString());
- static QWaylandShellIntegration *create(const QString &name, const QStringList &args, const QString &pluginPath = QString());
+ static QWaylandShellIntegration *create(const QString &name, QWaylandDisplay *display, const QStringList &args = QStringList(), const QString &pluginPath = QString());
};
}
diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri
index 4a0c0aa63..3df061459 100644
--- a/src/compositor/compositor_api/compositor_api.pri
+++ b/src/compositor/compositor_api/compositor_api.pri
@@ -27,6 +27,7 @@ HEADERS += \
compositor_api/qwaylandresource.h \
compositor_api/qwaylandsurfacegrabber.h \
compositor_api/qwaylandoutputmode_p.h \
+ compositor_api/qwaylandquickchildren.h
SOURCES += \
compositor_api/qwaylandcompositor.cpp \
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp
index 548298c41..c6c7c316a 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandcompositor.cpp
@@ -107,39 +107,48 @@ public:
bool sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e) override
{
if (e->type == QWindowSystemInterfacePrivate::Key) {
- QWindowSystemInterfacePrivate::KeyEvent *ke = static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e);
- QWaylandKeyboardPrivate *keyb = QWaylandKeyboardPrivate::get(compositor->defaultSeat()->keyboard());
+ QWindowSystemInterfacePrivate::KeyEvent *keyEvent = static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e);
+ handleKeyEvent(keyEvent);
+ } else {
+ QWindowSystemEventHandler::sendEvent(e);
+ }
+ return true;
+ }
- uint32_t code = ke->nativeScanCode;
- bool isDown = ke->keyType == QEvent::KeyPress;
+ void handleKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *ke)
+ {
+ auto *seat = compositor->defaultSeat();
+ if (!seat)
+ return;
+
+ QWaylandKeyboardPrivate *keyb = QWaylandKeyboardPrivate::get(seat->keyboard());
+
+ uint32_t code = ke->nativeScanCode;
+ bool isDown = ke->keyType == QEvent::KeyPress;
#if QT_CONFIG(xkbcommon_evdev)
- QString text;
- Qt::KeyboardModifiers modifiers = QWaylandXkb::modifiers(keyb->xkbState());
-
- const xkb_keysym_t sym = xkb_state_key_get_one_sym(keyb->xkbState(), code);
- int qtkey;
- std::tie(qtkey, text) = QWaylandXkb::keysymToQtKey(sym, modifiers);
-
- ke->key = qtkey;
- ke->modifiers = modifiers;
- ke->nativeVirtualKey = sym;
- ke->nativeModifiers = keyb->xkbModsMask();
- ke->unicode = text;
+ QString text;
+ Qt::KeyboardModifiers modifiers = QWaylandXkb::modifiers(keyb->xkbState());
+
+ const xkb_keysym_t sym = xkb_state_key_get_one_sym(keyb->xkbState(), code);
+ int qtkey;
+ std::tie(qtkey, text) = QWaylandXkb::keysymToQtKey(sym, modifiers);
+
+ ke->key = qtkey;
+ ke->modifiers = modifiers;
+ ke->nativeVirtualKey = sym;
+ ke->nativeModifiers = keyb->xkbModsMask();
+ ke->unicode = text;
#endif
- if (!ke->repeat)
- keyb->keyEvent(code, isDown ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED);
+ if (!ke->repeat)
+ keyb->keyEvent(code, isDown ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED);
- QWindowSystemEventHandler::sendEvent(e);
+ QWindowSystemEventHandler::sendEvent(ke);
- if (!ke->repeat) {
- keyb->maybeUpdateKeymap();
- keyb->updateModifierState(code, isDown ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED);
- }
- } else {
- QWindowSystemEventHandler::sendEvent(e);
+ if (!ke->repeat) {
+ keyb->maybeUpdateKeymap();
+ keyb->updateModifierState(code, isDown ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED);
}
- return true;
}
QWaylandCompositor *compositor = nullptr;
@@ -193,6 +202,10 @@ void QWaylandCompositorPrivate::init()
emit q->socketNameChanged(socket_name);
}
+#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10)
+ connectToExternalSockets();
+#endif
+
loop = wl_display_get_event_loop(display);
int fd = wl_event_loop_get_fd(loop);
@@ -274,6 +287,18 @@ void QWaylandCompositorPrivate::addPolishObject(QObject *object)
}
}
+#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10)
+void QWaylandCompositorPrivate::connectToExternalSockets()
+{
+ // Clear out any backlog of user-supplied external socket descriptors
+ for (int fd : qAsConst(externally_added_socket_fds)) {
+ if (wl_display_add_socket_fd(display, fd) != 0)
+ qWarning() << "Failed to integrate user-supplied socket fd into the Wayland event loop";
+ }
+ externally_added_socket_fds.clear();
+}
+#endif
+
void QWaylandCompositorPrivate::compositor_create_surface(wl_compositor::Resource *resource, uint32_t id)
{
Q_Q(QWaylandCompositor);
@@ -553,6 +578,46 @@ QByteArray QWaylandCompositor::socketName() const
}
/*!
+ * \qmlmethod QtWaylandCompositor::WaylandCompositor::addSocketFd(fd)
+ * \since 5.12
+ *
+ * Listen for client connections on a file descriptor referring to a
+ * server socket already bound and listening.
+ *
+ * Does not take ownership of the file descriptor; it must be closed
+ * explicitly if needed.
+ *
+ * \note This method is only available with libwayland 1.10.0 or
+ * newer. If built against an earlier libwayland runtime, this
+ * method is a noop.
+ */
+
+/*!
+ * Listen for client connections on a file descriptor referring to a
+ * server socket already bound and listening.
+ *
+ * Does not take ownership of the file descriptor; it must be closed
+ * explicitly if needed.
+ *
+ * \note This method is only available with libwayland 1.10.0 or
+ * newer. If built against an earlier libwayland runtime, this
+ * method is a noop.
+ *
+ * \since 5.12
+ */
+void QWaylandCompositor::addSocketFd(int fd)
+{
+#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10)
+ Q_D(QWaylandCompositor);
+ d->externally_added_socket_fds.append(fd);
+ if (isCreated())
+ d->connectToExternalSockets();
+#else
+ qWarning() << "QWaylandCompositor::addSocketFd() does nothing on libwayland versions prior to 1.10.0";
+#endif
+}
+
+/*!
* \internal
*/
struct wl_display *QWaylandCompositor::display() const
@@ -683,9 +748,11 @@ void QWaylandCompositor::setDefaultOutput(QWaylandOutput *output)
Q_D(QWaylandCompositor);
if (d->outputs.size() && d->outputs.first() == output)
return;
- d->outputs.removeOne(output);
+ bool alreadyAdded = d->outputs.removeOne(output);
d->outputs.prepend(output);
- defaultOutputChanged();
+ emit defaultOutputChanged();
+ if (!alreadyAdded)
+ emit outputAdded(output);
}
/*!
diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h
index 23844d72a..72b8f2d1b 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.h
+++ b/src/compositor/compositor_api/qwaylandcompositor.h
@@ -93,6 +93,8 @@ public:
void setSocketName(const QByteArray &name);
QByteArray socketName() const;
+ Q_INVOKABLE void addSocketFd(int fd);
+
::wl_display *display() const;
uint32_t nextSerial();
diff --git a/src/compositor/compositor_api/qwaylandcompositor_p.h b/src/compositor/compositor_api/qwaylandcompositor_p.h
index 0d259ee84..cdf4be6b4 100644
--- a/src/compositor/compositor_api/qwaylandcompositor_p.h
+++ b/src/compositor/compositor_api/qwaylandcompositor_p.h
@@ -112,6 +112,11 @@ public:
inline void addOutput(QWaylandOutput *output);
inline void removeOutput(QWaylandOutput *output);
+
+#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10)
+ void connectToExternalSockets();
+#endif
+
protected:
void compositor_create_surface(wl_compositor::Resource *resource, uint32_t id) override;
void compositor_create_region(wl_compositor::Resource *resource, uint32_t id) override;
@@ -128,6 +133,9 @@ protected:
void loadServerBufferIntegration();
QByteArray socket_name;
+#if WAYLAND_VERSION_MAJOR >= 1 && (WAYLAND_VERSION_MAJOR != 1 || WAYLAND_VERSION_MINOR >= 10)
+ QList<int> externally_added_socket_fds;
+#endif
struct wl_display *display = nullptr;
QList<QWaylandSeat *> seats;
diff --git a/src/compositor/compositor_api/qwaylandkeyboard.cpp b/src/compositor/compositor_api/qwaylandkeyboard.cpp
index 7ab8bff9e..c172bca85 100644
--- a/src/compositor/compositor_api/qwaylandkeyboard.cpp
+++ b/src/compositor/compositor_api/qwaylandkeyboard.cpp
@@ -54,6 +54,7 @@
#if QT_CONFIG(xkbcommon_evdev)
#include <sys/mman.h>
#include <sys/types.h>
+#include <qwaylandxkb_p.h>
#endif
QT_BEGIN_NAMESPACE
@@ -196,6 +197,32 @@ void QWaylandKeyboardPrivate::modifiers(uint32_t serial, uint32_t mods_depressed
}
}
+#if QT_CONFIG(xkbcommon_evdev)
+void QWaylandKeyboardPrivate::maybeUpdateXkbScanCodeTable()
+{
+ if (!scanCodesByQtKey.isEmpty() || !xkbState())
+ return;
+
+ if (xkb_keymap *keymap = xkb_state_get_keymap(xkb_state)) {
+ xkb_keymap_key_for_each(keymap, [](xkb_keymap *keymap, xkb_keycode_t keycode, void *d){
+ auto *scanCodesByQtKey = static_cast<QMap<ScanCodeKey, uint>*>(d);
+ uint numLayouts = xkb_keymap_num_layouts_for_key(keymap, keycode);
+ for (uint layout = 0; layout < numLayouts; ++layout) {
+ const xkb_keysym_t *syms = nullptr;
+ xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, 0, &syms);
+ if (!syms)
+ continue;
+
+ Qt::KeyboardModifiers mods = {};
+ int qtKey = QWaylandXkb::keysymToQtKey(syms[0], mods).first;
+ if (qtKey != 0)
+ scanCodesByQtKey->insert({layout, qtKey}, keycode);
+ }
+ }, &scanCodesByQtKey);
+ }
+}
+#endif
+
void QWaylandKeyboardPrivate::updateModifierState(uint code, uint32_t state)
{
#if QT_CONFIG(xkbcommon_evdev)
@@ -355,6 +382,7 @@ void QWaylandKeyboardPrivate::createXKBKeymap()
struct xkb_keymap *xkbKeymap = xkb_keymap_new_from_names(xkb_context, &rule_names, static_cast<xkb_keymap_compile_flags>(0));
if (xkbKeymap) {
+ scanCodesByQtKey.clear();
createXKBState(xkbKeymap);
xkb_keymap_unref(xkbKeymap);
} else {
@@ -561,4 +589,17 @@ void QWaylandKeyboard::addClient(QWaylandClient *client, uint32_t id, uint32_t v
d->add(client->client(), id, qMin<uint32_t>(QtWaylandServer::wl_keyboard::interfaceVersion(), version));
}
+uint QWaylandKeyboard::toScanCode(int qtKey) const
+{
+ uint scanCode = 0;
+#if QT_CONFIG(xkbcommon_evdev)
+ Q_D(const QWaylandKeyboard);
+ const_cast<QWaylandKeyboardPrivate *>(d)->maybeUpdateXkbScanCodeTable();
+ scanCode = d->scanCodesByQtKey.value({d->group, qtKey}, 0);
+#else
+ Q_UNUSED(qtKey);
+#endif
+ return scanCode;
+}
+
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandkeyboard.h b/src/compositor/compositor_api/qwaylandkeyboard.h
index 580f0c4ed..e5d5e086e 100644
--- a/src/compositor/compositor_api/qwaylandkeyboard.h
+++ b/src/compositor/compositor_api/qwaylandkeyboard.h
@@ -82,6 +82,8 @@ public:
virtual void addClient(QWaylandClient *client, uint32_t id, uint32_t version);
+ uint toScanCode(int qtKey) const;
+
Q_SIGNALS:
void focusChanged(QWaylandSurface *surface);
void repeatRateChanged(quint32 repeatRate);
diff --git a/src/compositor/compositor_api/qwaylandkeyboard_p.h b/src/compositor/compositor_api/qwaylandkeyboard_p.h
index 6db312cfb..cd1f27956 100644
--- a/src/compositor/compositor_api/qwaylandkeyboard_p.h
+++ b/src/compositor/compositor_api/qwaylandkeyboard_p.h
@@ -89,6 +89,7 @@ public:
#if QT_CONFIG(xkbcommon_evdev)
struct xkb_state *xkbState() const { return xkb_state; }
uint32_t xkbModsMask() const { return modsDepressed | modsLatched | modsLocked; }
+ void maybeUpdateXkbScanCodeTable();
#endif
void keyEvent(uint code, uint32_t state);
@@ -131,6 +132,8 @@ private:
size_t keymap_size;
int keymap_fd = -1;
char *keymap_area = nullptr;
+ using ScanCodeKey = std::pair<uint,int>; // group/layout and QtKey
+ QMap<ScanCodeKey, uint> scanCodesByQtKey;
struct xkb_context *xkb_context = nullptr;
struct xkb_state *xkb_state = nullptr;
#endif
diff --git a/src/compositor/compositor_api/qwaylandkeymap.h b/src/compositor/compositor_api/qwaylandkeymap.h
index d96c409be..8058e1440 100644
--- a/src/compositor/compositor_api/qwaylandkeymap.h
+++ b/src/compositor/compositor_api/qwaylandkeymap.h
@@ -42,6 +42,7 @@
#include <QtCore/QObject>
#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
+#include <QtWaylandCompositor/qwaylandquickchildren.h>
QT_BEGIN_NAMESPACE
@@ -51,6 +52,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandKeymap : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandKeymap)
+ Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandKeymap)
Q_PROPERTY(QString layout READ layout WRITE setLayout NOTIFY layoutChanged)
Q_PROPERTY(QString variant READ variant WRITE setVariant NOTIFY variantChanged)
Q_PROPERTY(QString options READ options WRITE setOptions NOTIFY optionsChanged)
diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp
index 415d08f16..17c56cfdc 100644
--- a/src/compositor/compositor_api/qwaylandoutput.cpp
+++ b/src/compositor/compositor_api/qwaylandoutput.cpp
@@ -165,6 +165,33 @@ void QWaylandOutputPrivate::sendModesInfo()
}
}
+void QWaylandOutputPrivate::handleWindowPixelSizeChanged()
+{
+ Q_Q(QWaylandOutput);
+ Q_ASSERT(window);
+ if (sizeFollowsWindow && currentMode <= modes.size() - 1) {
+ if (currentMode >= 0) {
+ QWaylandOutputMode mode = modes.at(currentMode);
+ mode.setSize(windowPixelSize);
+ modes.replace(currentMode, mode);
+ emit q->geometryChanged();
+ if (!availableGeometry.isValid())
+ emit q->availableGeometryChanged();
+ sendModesInfo();
+ } else {
+ // We didn't add a mode during the initialization because the window
+ // size was invalid, let's add it now
+ int mHzRefreshRate = qFloor(window->screen()->refreshRate() * 1000);
+ QWaylandOutputMode mode(windowPixelSize, mHzRefreshRate);
+ if (mode.isValid()) {
+ modes.clear();
+ q->addMode(mode, true);
+ q->setCurrentMode(mode);
+ }
+ }
+ }
+}
+
void QWaylandOutputPrivate::addView(QWaylandView *view, QWaylandSurface *surface)
{
for (int i = 0; i < surfaceViews.size(); i++) {
@@ -267,6 +294,10 @@ void QWaylandOutput::initialize()
Q_ASSERT(d->compositor);
Q_ASSERT(d->compositor->isCreated());
+ if (!d->window && d->sizeFollowsWindow) {
+ qWarning("Setting QWaylandOutput::sizeFollowsWindow without a window has no effect");
+ }
+
// Replace modes with one that follows the window size and refresh rate,
// but only if window size is valid
if (d->window && d->sizeFollowsWindow) {
@@ -282,8 +313,9 @@ void QWaylandOutput::initialize()
QWaylandCompositorPrivate::get(d->compositor)->addOutput(this);
if (d->window) {
- QObject::connect(d->window, &QWindow::widthChanged, this, &QWaylandOutput::handleSetWidth);
- QObject::connect(d->window, &QWindow::heightChanged, this, &QWaylandOutput::handleSetHeight);
+ QObject::connect(d->window, &QWindow::widthChanged, this, &QWaylandOutput::handleMaybeWindowPixelSizeChanged);
+ QObject::connect(d->window, &QWindow::heightChanged, this, &QWaylandOutput::handleMaybeWindowPixelSizeChanged);
+ QObject::connect(d->window, &QWindow::screenChanged, this, &QWaylandOutput::handleMaybeWindowPixelSizeChanged);
QObject::connect(d->window, &QObject::destroyed, this, &QWaylandOutput::handleWindowDestroyed);
}
@@ -297,7 +329,9 @@ void QWaylandOutput::initialize()
*/
QWaylandOutput *QWaylandOutput::fromResource(wl_resource *resource)
{
- return static_cast<QWaylandOutputPrivate *>(QWaylandOutputPrivate::Resource::fromResource(resource)->output_object)->q_func();
+ if (auto *r = QWaylandOutputPrivate::Resource::fromResource(resource))
+ return static_cast<QWaylandOutputPrivate *>(r->output_object)->q_func();
+ return nullptr;
}
/*!
@@ -817,11 +851,6 @@ void QWaylandOutput::setSizeFollowsWindow(bool follow)
{
Q_D(QWaylandOutput);
- if (!d->window) {
- qWarning("Setting QWaylandOutput::sizeFollowsWindow without a window has no effect");
- return;
- }
-
if (follow != d->sizeFollowsWindow) {
d->sizeFollowsWindow = follow;
Q_EMIT sizeFollowsWindowChanged();
@@ -924,66 +953,18 @@ void QWaylandOutput::surfaceLeave(QWaylandSurface *surface)
/*!
* \internal
*/
-void QWaylandOutput::handleSetWidth(int newWidth)
+void QWaylandOutput::handleMaybeWindowPixelSizeChanged()
{
Q_D(QWaylandOutput);
- if (!d->window || !d->sizeFollowsWindow)
+ if (!d->window)
return;
- if (d->currentMode <= d->modes.size() - 1) {
- if (d->currentMode >= 0) {
- QWaylandOutputMode mode = d->modes.at(d->currentMode);
- mode.setWidth(newWidth * d->window->devicePixelRatio());
- d->modes.replace(d->currentMode, mode);
- emit geometryChanged();
- if (!d->availableGeometry.isValid())
- emit availableGeometryChanged();
- d->sendModesInfo();
- } else {
- // We didn't add a mode during the initialization because the window
- // size was invalid, let's add it now
- QWaylandOutputMode mode(d->window->size() * d->window->devicePixelRatio(),
- qFloor(d->window->screen()->refreshRate() * 1000));
- if (mode.isValid()) {
- d->modes.clear();
- addMode(mode, true);
- setCurrentMode(mode);
- }
- }
- }
-}
-
-/*!
- * \internal
- */
-void QWaylandOutput::handleSetHeight(int newHeight)
-{
- Q_D(QWaylandOutput);
+ const QSize pixelSize = d->window->size() * d->window->devicePixelRatio();
- if (!d->window || !d->sizeFollowsWindow)
- return;
-
- if (d->currentMode <= d->modes.size() - 1) {
- if (d->currentMode >= 0) {
- QWaylandOutputMode mode = d->modes.at(d->currentMode);
- mode.setHeight(newHeight * d->window->devicePixelRatio());
- d->modes.replace(d->currentMode, mode);
- emit geometryChanged();
- if (!d->availableGeometry.isValid())
- emit availableGeometryChanged();
- d->sendModesInfo();
- } else {
- // We didn't add a mode during the initialization because the window
- // size was invalid, let's add it now
- QWaylandOutputMode mode(d->window->size() * d->window->devicePixelRatio(),
- qFloor(d->window->screen()->refreshRate() * 1000));
- if (mode.isValid()) {
- d->modes.clear();
- addMode(mode, true);
- setCurrentMode(mode);
- }
- }
+ if (pixelSize != d->windowPixelSize) {
+ d->windowPixelSize = pixelSize;
+ d->handleWindowPixelSizeChanged();
}
}
diff --git a/src/compositor/compositor_api/qwaylandoutput.h b/src/compositor/compositor_api/qwaylandoutput.h
index f0bea809e..c7f2973b6 100644
--- a/src/compositor/compositor_api/qwaylandoutput.h
+++ b/src/compositor/compositor_api/qwaylandoutput.h
@@ -181,8 +181,7 @@ Q_SIGNALS:
void windowDestroyed();
private Q_SLOTS:
- void handleSetWidth(int newWidth);
- void handleSetHeight(int newHeight);
+ void handleMaybeWindowPixelSizeChanged();
void handleWindowDestroyed();
protected:
diff --git a/src/compositor/compositor_api/qwaylandoutput_p.h b/src/compositor/compositor_api/qwaylandoutput_p.h
index 38bb1ec6e..d8b2c9dfa 100644
--- a/src/compositor/compositor_api/qwaylandoutput_p.h
+++ b/src/compositor/compositor_api/qwaylandoutput_p.h
@@ -108,6 +108,8 @@ public:
void sendMode(const Resource *resource, const QWaylandOutputMode &mode);
void sendModesInfo();
+ void handleWindowPixelSizeChanged();
+
protected:
void output_bind_resource(Resource *resource) override;
@@ -128,6 +130,7 @@ private:
int scaleFactor = 1;
bool sizeFollowsWindow = false;
bool initialized = false;
+ QSize windowPixelSize;
Q_DECLARE_PUBLIC(QWaylandOutput)
Q_DISABLE_COPY(QWaylandOutputPrivate)
diff --git a/src/compositor/compositor_api/qwaylandoutputmode.cpp b/src/compositor/compositor_api/qwaylandoutputmode.cpp
index 9ae285fd5..545871175 100644
--- a/src/compositor/compositor_api/qwaylandoutputmode.cpp
+++ b/src/compositor/compositor_api/qwaylandoutputmode.cpp
@@ -128,15 +128,7 @@ int QWaylandOutputMode::refreshRate() const
/*!
* \internal
*/
-void QWaylandOutputMode::setWidth(int width)
+void QWaylandOutputMode::setSize(const QSize &size)
{
- d->size.setWidth(width);
-}
-
-/*!
- * \internal
- */
-void QWaylandOutputMode::setHeight(int height)
-{
- d->size.setHeight(height);
+ d->size = size;
}
diff --git a/src/compositor/compositor_api/qwaylandoutputmode.h b/src/compositor/compositor_api/qwaylandoutputmode.h
index 7adb920e5..b03457929 100644
--- a/src/compositor/compositor_api/qwaylandoutputmode.h
+++ b/src/compositor/compositor_api/qwaylandoutputmode.h
@@ -64,10 +64,9 @@ public:
private:
class QWaylandOutputModePrivate *const d;
- friend class QWaylandOutput;
+ friend class QWaylandOutputPrivate;
- void setWidth(int width);
- void setHeight(int height);
+ void setSize(const QSize &size);
};
Q_DECLARE_TYPEINFO(QWaylandOutputMode, Q_MOVABLE_TYPE);
diff --git a/src/compositor/compositor_api/qwaylandquickchildren.h b/src/compositor/compositor_api/qwaylandquickchildren.h
new file mode 100644
index 000000000..7d821ab50
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandquickchildren.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDQUICKCHILDREN_H
+#define QWAYLANDQUICKCHILDREN_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#ifdef QT_WAYLAND_COMPOSITOR_QUICK
+#include <QtQml/QQmlListProperty>
+#include <QtCore/QVector>
+#endif
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifdef QT_WAYLAND_COMPOSITOR_QUICK
+#define Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(className) \
+ Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false) \
+ Q_CLASSINFO("DefaultProperty", "data") \
+ public: \
+ QQmlListProperty<QObject> data() \
+ { \
+ return QQmlListProperty<QObject>(this, this, \
+ &className::appendFunction, \
+ &className::countFunction, \
+ &className::atFunction, \
+ &className::clearFunction); \
+ } \
+ static void appendFunction(QQmlListProperty<QObject> *list, QObject *object) \
+ { \
+ static_cast<className *>(list->data)->m_children.append(object); \
+ } \
+ static int countFunction(QQmlListProperty<QObject> *list) \
+ { \
+ return static_cast<className *>(list->data)->m_children.size(); \
+ } \
+ static QObject *atFunction(QQmlListProperty<QObject> *list, int index) \
+ { \
+ return static_cast<className *>(list->data)->m_children.at(index); \
+ } \
+ static void clearFunction(QQmlListProperty<QObject> *list) \
+ { \
+ static_cast<className *>(list->data)->m_children.clear(); \
+ } \
+ private: \
+ QVector<QObject *> m_children;
+#else
+#define Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(className)
+#endif
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDQUICKCHILDREN_H
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp
index 1ee6848e3..fd9b1b800 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.cpp
+++ b/src/compositor/compositor_api/qwaylandquickitem.cpp
@@ -731,7 +731,39 @@ void QWaylandQuickItem::handleSubsurfaceAdded(QWaylandSurface *childSurface)
}
}
+void QWaylandQuickItem::handlePlaceAbove(QWaylandSurface *referenceSurface)
+{
+ Q_D(QWaylandQuickItem);
+ auto *parent = qobject_cast<QWaylandQuickItem*>(parentItem());
+ if (!parent)
+ return;
+ if (parent->surface() == referenceSurface) {
+ d->placeAboveParent();
+ } else if (auto *sibling = d->findSibling(referenceSurface)) {
+ d->placeAboveSibling(sibling);
+ } else {
+ qWarning() << "Couldn't find QWaylandQuickItem for surface" << referenceSurface
+ << "when handling wl_subsurface.place_above";
+ }
+}
+
+void QWaylandQuickItem::handlePlaceBelow(QWaylandSurface *referenceSurface)
+{
+ Q_D(QWaylandQuickItem);
+ QWaylandQuickItem *parent = qobject_cast<QWaylandQuickItem*>(parentItem());
+ if (!parent)
+ return;
+
+ if (parent->surface() == referenceSurface) {
+ d->placeBelowParent();
+ } else if (auto *sibling = d->findSibling(referenceSurface)) {
+ d->placeBelowSibling(sibling);
+ } else {
+ qWarning() << "Couldn't find QWaylandQuickItem for surface" << referenceSurface
+ << "when handling wl_subsurface.place_below";
+ }
+}
/*!
\qmlproperty object QtWaylandCompositor::WaylandQuickItem::subsurfaceHandler
@@ -859,6 +891,8 @@ void QWaylandQuickItem::handleSurfaceChanged()
disconnect(d->oldSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer);
disconnect(d->oldSurface, &QWaylandSurface::redraw, this, &QQuickItem::update);
disconnect(d->oldSurface, &QWaylandSurface::childAdded, this, &QWaylandQuickItem::handleSubsurfaceAdded);
+ disconnect(d->oldSurface, &QWaylandSurface::subsurfacePlaceAbove, this, &QWaylandQuickItem::handlePlaceAbove);
+ disconnect(d->oldSurface, &QWaylandSurface::subsurfacePlaceBelow, this, &QWaylandQuickItem::handlePlaceBelow);
#if QT_CONFIG(draganddrop)
disconnect(d->oldSurface, &QWaylandSurface::dragStarted, this, &QWaylandQuickItem::handleDragStarted);
#endif
@@ -874,6 +908,8 @@ void QWaylandQuickItem::handleSurfaceChanged()
connect(newSurface, &QWaylandSurface::configure, this, &QWaylandQuickItem::updateBuffer);
connect(newSurface, &QWaylandSurface::redraw, this, &QQuickItem::update);
connect(newSurface, &QWaylandSurface::childAdded, this, &QWaylandQuickItem::handleSubsurfaceAdded);
+ connect(newSurface, &QWaylandSurface::subsurfacePlaceAbove, this, &QWaylandQuickItem::handlePlaceAbove);
+ connect(newSurface, &QWaylandSurface::subsurfacePlaceBelow, this, &QWaylandQuickItem::handlePlaceBelow);
#if QT_CONFIG(draganddrop)
connect(newSurface, &QWaylandSurface::dragStarted, this, &QWaylandQuickItem::handleDragStarted);
#endif
@@ -1133,12 +1169,14 @@ void QWaylandQuickItem::updateWindow()
if (d->connectedWindow) {
disconnect(d->connectedWindow, &QQuickWindow::beforeSynchronizing, this, &QWaylandQuickItem::beforeSync);
+ disconnect(d->connectedWindow, &QQuickWindow::screenChanged, this, &QWaylandQuickItem::updateSize);
}
d->connectedWindow = newWindow;
if (d->connectedWindow) {
connect(d->connectedWindow, &QQuickWindow::beforeSynchronizing, this, &QWaylandQuickItem::beforeSync, Qt::DirectConnection);
+ connect(d->connectedWindow, &QQuickWindow::screenChanged, this, &QWaylandQuickItem::updateSize); // new screen may have new dpr
}
if (compositor() && d->connectedWindow) {
@@ -1146,6 +1184,25 @@ void QWaylandQuickItem::updateWindow()
Q_ASSERT(output);
d->view->setOutput(output);
}
+
+ updateSize(); // because scaleFactor depends on devicePixelRatio, which may be different for the new window
+}
+
+void QWaylandQuickItem::updateOutput()
+{
+ Q_D(QWaylandQuickItem);
+ if (d->view->output() == d->connectedOutput)
+ return;
+
+ if (d->connectedOutput)
+ disconnect(d->connectedOutput, &QWaylandOutput::scaleFactorChanged, this, &QWaylandQuickItem::updateSize);
+
+ d->connectedOutput = d->view->output();
+
+ if (d->connectedOutput)
+ connect(d->connectedOutput, &QWaylandOutput::scaleFactorChanged, this, &QWaylandQuickItem::updateSize);
+
+ updateSize();
}
void QWaylandQuickItem::beforeSync()
@@ -1320,6 +1377,19 @@ void QWaylandQuickItem::raise()
stackAfter(top);
}
+void QWaylandQuickItem::sendMouseMoveEvent(const QPointF &position, QWaylandSeat *seat)
+{
+ if (seat == nullptr)
+ seat = compositor()->defaultSeat();
+
+ if (!seat) {
+ qWarning() << "No seat, can't send mouse event";
+ return;
+ }
+
+ seat->sendMouseMoveEvent(view(), position);
+}
+
/*!
* \internal
*
@@ -1351,4 +1421,86 @@ qreal QWaylandQuickItemPrivate::scaleFactor() const
return f;
}
+QWaylandQuickItem *QWaylandQuickItemPrivate::findSibling(QWaylandSurface *surface) const
+{
+ Q_Q(const QWaylandQuickItem);
+ auto *parent = q->parentItem();
+ if (!parent)
+ return nullptr;
+
+ const auto siblings = q->parentItem()->childItems();
+ for (auto *sibling : siblings) {
+ auto *waylandItem = qobject_cast<QWaylandQuickItem *>(sibling);
+ if (waylandItem && waylandItem->surface() == surface)
+ return waylandItem;
+ }
+ return nullptr;
+}
+
+void QWaylandQuickItemPrivate::placeAboveSibling(QWaylandQuickItem *sibling)
+{
+ Q_Q(QWaylandQuickItem);
+ q->stackAfter(sibling);
+ q->setZ(sibling->z());
+ belowParent = sibling->d_func()->belowParent;
+}
+
+void QWaylandQuickItemPrivate::placeBelowSibling(QWaylandQuickItem *sibling)
+{
+ Q_Q(QWaylandQuickItem);
+ q->stackBefore(sibling);
+ q->setZ(sibling->z());
+ belowParent = sibling->d_func()->belowParent;
+}
+
+//### does not handle changes in z value if parent is a subsurface
+void QWaylandQuickItemPrivate::placeAboveParent()
+{
+ Q_Q(QWaylandQuickItem);
+ const auto siblings = q->parentItem()->childItems();
+
+ // Stack below first (bottom) sibling above parent
+ bool foundSibling = false;
+ for (auto it = siblings.cbegin(); it != siblings.cend(); ++it) {
+ QWaylandQuickItem *sibling = qobject_cast<QWaylandQuickItem*>(*it);
+ if (sibling && !sibling->d_func()->belowParent) {
+ q->stackBefore(sibling);
+ foundSibling = true;
+ break;
+ }
+ }
+
+ // No other subsurfaces above parent
+ if (!foundSibling && siblings.last() != q)
+ q->stackAfter(siblings.last());
+
+ q->setZ(q->parentItem()->z());
+ belowParent = false;
+}
+
+//### does not handle changes in z value if parent is a subsurface
+void QWaylandQuickItemPrivate::placeBelowParent()
+{
+ Q_Q(QWaylandQuickItem);
+ const auto siblings = q->parentItem()->childItems();
+
+ // Stack above last (top) sibling below parent
+ bool foundSibling = false;
+ for (auto it = siblings.crbegin(); it != siblings.crend(); ++it) {
+ QWaylandQuickItem *sibling = qobject_cast<QWaylandQuickItem*>(*it);
+ if (sibling && sibling->d_func()->belowParent) {
+ q->stackAfter(sibling);
+ foundSibling = true;
+ break;
+ }
+ }
+
+ // No other subsurfaces below parent
+ if (!foundSibling && siblings.first() != q)
+ q->stackBefore(siblings.first());
+
+ q->setZ(q->parentItem()->z() - 1.0);
+ belowParent = true;
+}
+
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandquickitem.h b/src/compositor/compositor_api/qwaylandquickitem.h
index 047fdeb65..653440aed 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.h
+++ b/src/compositor/compositor_api/qwaylandquickitem.h
@@ -151,6 +151,7 @@ public Q_SLOTS:
void setPaintEnabled(bool paintEnabled);
void raise();
void lower();
+ void sendMouseMoveEvent(const QPointF &position, QWaylandSeat *seat = nullptr);
private Q_SLOTS:
void surfaceMappedChanged();
@@ -159,9 +160,12 @@ private Q_SLOTS:
void updateSize();
void updateBuffer(bool hasBuffer);
void updateWindow();
+ void updateOutput();
void beforeSync();
void handleSubsurfaceAdded(QWaylandSurface *childSurface);
void handleSubsurfacePosition(const QPoint &pos);
+ void handlePlaceAbove(QWaylandSurface *referenceSurface);
+ void handlePlaceBelow(QWaylandSurface *referenceSurface);
#if QT_CONFIG(draganddrop)
void handleDragStarted(QWaylandDrag *drag);
#endif
diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h
index f926d55e8..51b41c9f6 100644
--- a/src/compositor/compositor_api/qwaylandquickitem_p.h
+++ b/src/compositor/compositor_api/qwaylandquickitem_p.h
@@ -128,6 +128,7 @@ public:
QObject::connect(view.data(), &QWaylandView::surfaceChanged, q, &QWaylandQuickItem::handleSurfaceChanged);
QObject::connect(view.data(), &QWaylandView::surfaceDestroyed, q, &QWaylandQuickItem::surfaceDestroyed);
QObject::connect(view.data(), &QWaylandView::outputChanged, q, &QWaylandQuickItem::outputChanged);
+ QObject::connect(view.data(), &QWaylandView::outputChanged, q, &QWaylandQuickItem::updateOutput);
QObject::connect(view.data(), &QWaylandView::bufferLockedChanged, q, &QWaylandQuickItem::bufferLockedChanged);
QObject::connect(view.data(), &QWaylandView::allowDiscardFrontBufferChanged, q, &QWaylandQuickItem::allowDiscardFrontBuffer);
@@ -151,6 +152,12 @@ public:
bool shouldSendInputEvents() const { return view->surface() && inputEventsEnabled; }
qreal scaleFactor() const;
+ QWaylandQuickItem *findSibling(QWaylandSurface *surface) const;
+ void placeAboveSibling(QWaylandQuickItem *sibling);
+ void placeBelowSibling(QWaylandQuickItem *sibling);
+ void placeAboveParent();
+ void placeBelowParent();
+
static QMutex *mutex;
QScopedPointer<QWaylandView> view;
@@ -163,10 +170,12 @@ public:
bool newTexture = false;
bool focusOnClick = true;
bool sizeFollowsSurface = true;
+ bool belowParent = false;
QPoint hoverPos;
QMatrix4x4 lastMatrix;
QQuickWindow *connectedWindow = nullptr;
+ QWaylandOutput *connectedOutput = nullptr;
QWaylandSurface::Origin origin = QWaylandSurface::OriginTopLeft;
QPointer<QObject> subsurfaceHandler;
QVector<QWaylandSeat *> touchingSeats;
diff --git a/src/compositor/compositor_api/qwaylandquickoutput.h b/src/compositor/compositor_api/qwaylandquickoutput.h
index cd79f14f5..5f3749b01 100644
--- a/src/compositor/compositor_api/qwaylandquickoutput.h
+++ b/src/compositor/compositor_api/qwaylandquickoutput.h
@@ -43,6 +43,7 @@
#include <QtQuick/QQuickWindow>
#include <QtWaylandCompositor/qwaylandoutput.h>
+#include <QtWaylandCompositor/qwaylandquickchildren.h>
QT_BEGIN_NAMESPACE
@@ -53,6 +54,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickOutput : public QWaylandOutput, p
{
Q_INTERFACES(QQmlParserStatus)
Q_OBJECT
+ Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandQuickOutput)
Q_PROPERTY(bool automaticFrameCallback READ automaticFrameCallback WRITE setAutomaticFrameCallback NOTIFY automaticFrameCallbackChanged)
public:
QWaylandQuickOutput();
diff --git a/src/compositor/compositor_api/qwaylandquicksurface.h b/src/compositor/compositor_api/qwaylandquicksurface.h
index a234b776e..258f1a22f 100644
--- a/src/compositor/compositor_api/qwaylandquicksurface.h
+++ b/src/compositor/compositor_api/qwaylandquicksurface.h
@@ -41,6 +41,7 @@
#define QQUICKWAYLANDSURFACE_H
#include <QtWaylandCompositor/qwaylandsurface.h>
+#include <QtWaylandCompositor/qwaylandquickchildren.h>
struct wl_client;
@@ -53,6 +54,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickSurface : public QWaylandSurface
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandQuickSurface)
+ Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandQuickSurface)
Q_PROPERTY(bool useTextureAlpha READ useTextureAlpha WRITE setUseTextureAlpha NOTIFY useTextureAlphaChanged)
Q_PROPERTY(bool clientRenderingEnabled READ clientRenderingEnabled WRITE setClientRenderingEnabled NOTIFY clientRenderingEnabledChanged)
public:
diff --git a/src/compositor/compositor_api/qwaylandseat.cpp b/src/compositor/compositor_api/qwaylandseat.cpp
index c67e6020d..60d4d6fd9 100644
--- a/src/compositor/compositor_api/qwaylandseat.cpp
+++ b/src/compositor/compositor_api/qwaylandseat.cpp
@@ -440,10 +440,50 @@ void QWaylandSeat::sendFullKeyEvent(QKeyEvent *event)
return;
if (!d->keyboard.isNull() && !event->isAutoRepeat()) {
+
+ uint scanCode = event->nativeScanCode();
+ if (scanCode == 0)
+ scanCode = d->keyboard->toScanCode(event->key());
+
+ if (scanCode == 0) {
+ qWarning() << "Can't send Wayland key event: Unable to get a valid scan code";
+ return;
+ }
+
if (event->type() == QEvent::KeyPress)
- d->keyboard->sendKeyPressEvent(event->nativeScanCode());
+ d->keyboard->sendKeyPressEvent(scanCode);
else if (event->type() == QEvent::KeyRelease)
- d->keyboard->sendKeyReleaseEvent(event->nativeScanCode());
+ d->keyboard->sendKeyReleaseEvent(scanCode);
+ }
+}
+
+/*!
+ * \qmlmethod void QtWaylandCompositor::WaylandSeat::sendKeyEvent(int qtKey, bool pressed)
+ * \since 5.12
+ *
+ * Sends a key press or release to the keyboard device.
+ */
+
+/*!
+ * Sends a key press or release to the keyboard device.
+ *
+ * \since 5.12
+ */
+void QWaylandSeat::sendKeyEvent(int qtKey, bool pressed)
+{
+ Q_D(QWaylandSeat);
+ if (!keyboardFocus()) {
+ qWarning("Cannot send Wayland key event, no keyboard focus, fix the compositor");
+ return;
+ }
+
+ if (auto scanCode = d->keyboard->toScanCode(qtKey)) {
+ if (pressed)
+ d->keyboard->sendKeyPressEvent(scanCode);
+ else
+ d->keyboard->sendKeyReleaseEvent(scanCode);
+ } else {
+ qWarning() << "Can't send Wayland key event: Unable to get scan code for" << Qt::Key(qtKey);
}
}
@@ -591,7 +631,9 @@ bool QWaylandSeat::isOwner(QInputEvent *inputEvent) const
*/
QWaylandSeat *QWaylandSeat::fromSeatResource(struct ::wl_resource *resource)
{
- return static_cast<QWaylandSeatPrivate *>(QWaylandSeatPrivate::Resource::fromResource(resource)->seat_object)->q_func();
+ if (auto *r = QWaylandSeatPrivate::Resource::fromResource(resource))
+ return static_cast<QWaylandSeatPrivate *>(r->seat_object)->q_func();
+ return nullptr;
}
/*!
diff --git a/src/compositor/compositor_api/qwaylandseat.h b/src/compositor/compositor_api/qwaylandseat.h
index f438b6639..6a4d6e176 100644
--- a/src/compositor/compositor_api/qwaylandseat.h
+++ b/src/compositor/compositor_api/qwaylandseat.h
@@ -97,6 +97,7 @@ public:
void sendKeyReleaseEvent(uint code);
void sendFullKeyEvent(QKeyEvent *event);
+ Q_INVOKABLE void sendKeyEvent(int qtKey, bool pressed);
uint sendTouchPointEvent(QWaylandSurface *surface, int id, const QPointF &point, Qt::TouchPointState state);
Q_INVOKABLE uint sendTouchPointPressed(QWaylandSurface *surface, int id, const QPointF &position);
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp
index 9783b5848..632b1757f 100644
--- a/src/compositor/compositor_api/qwaylandsurface.cpp
+++ b/src/compositor/compositor_api/qwaylandsurface.cpp
@@ -748,7 +748,9 @@ QList<QWaylandView *> QWaylandSurface::views() const
*/
QWaylandSurface *QWaylandSurface::fromResource(::wl_resource *res)
{
- return static_cast<QWaylandSurfacePrivate *>(QWaylandSurfacePrivate::Resource::fromResource(res)->surface_object)->q_func();
+ if (auto *r = QWaylandSurfacePrivate::Resource::fromResource(res))
+ return static_cast<QWaylandSurfacePrivate *>(r->surface_object)->q_func();
+ return nullptr;
}
/*!
diff --git a/src/compositor/doc/qtwaylandcompositor.qdocconf b/src/compositor/doc/qtwaylandcompositor.qdocconf
index f520c98ba..4fa9f394d 100644
--- a/src/compositor/doc/qtwaylandcompositor.qdocconf
+++ b/src/compositor/doc/qtwaylandcompositor.qdocconf
@@ -7,7 +7,7 @@ version = $QT_VERSION
qhp.projects = QtWaylandCompositor
qhp.QtWaylandCompositor.file = qtwaylandcompositor.qhp
-qhp.QtWaylandCompositor.namespace = org.qtproject.qtwaylandcompositor.$QT_VERSION_TAG
+qhp.QtWaylandCompositor.namespace = org.qt-project.qtwaylandcompositor.$QT_VERSION_TAG
qhp.QtWaylandCompositor.virtualFolder = qtwaylandcompositor
qhp.QtWaylandCompositor.indexTitle = Qt Wayland Compositor
qhp.QtWaylandCompositor.indexRoot =
diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri
index 8b36649e4..5c708f891 100644
--- a/src/compositor/extensions/extensions.pri
+++ b/src/compositor/extensions/extensions.pri
@@ -6,11 +6,12 @@ private_headers.CONFIG += no_check_exist
WAYLANDSERVERSOURCES += \
../extensions/touch-extension.xml \
- ../extensions/qtkey-extension.xml \
+ ../extensions/qt-key-unstable-v1.xml \
../extensions/qt-windowmanager.xml \
../3rdparty/protocol/text-input-unstable-v2.xml \
- ../3rdparty/protocol/xdg-shell.xml \
../3rdparty/protocol/xdg-shell-unstable-v6.xml \
+ ../3rdparty/protocol/xdg-shell.xml \
+ ../3rdparty/protocol/xdg-decoration-unstable-v1.xml \
../3rdparty/protocol/ivi-application.xml \
HEADERS += \
@@ -30,6 +31,10 @@ HEADERS += \
extensions/qwaylandxdgshellv5_p.h \
extensions/qwaylandxdgshellv6.h \
extensions/qwaylandxdgshellv6_p.h \
+ extensions/qwaylandxdgshell.h \
+ extensions/qwaylandxdgshell_p.h \
+ extensions/qwaylandxdgdecorationv1.h \
+ extensions/qwaylandxdgdecorationv1_p.h \
extensions/qwaylandshellsurface.h \
extensions/qwaylandiviapplication.h \
extensions/qwaylandiviapplication_p.h \
@@ -46,6 +51,8 @@ SOURCES += \
extensions/qwaylandqtwindowmanager.cpp \
extensions/qwaylandxdgshellv5.cpp \
extensions/qwaylandxdgshellv6.cpp \
+ extensions/qwaylandxdgshell.cpp \
+ extensions/qwaylandxdgdecorationv1.cpp \
extensions/qwaylandshellsurface.cpp \
extensions/qwaylandiviapplication.cpp \
extensions/qwaylandivisurface.cpp \
@@ -58,6 +65,7 @@ qtHaveModule(quick):contains(QT_CONFIG, opengl) {
extensions/qwaylandwlshellintegration_p.h \
extensions/qwaylandxdgshellv5integration_p.h \
extensions/qwaylandxdgshellv6integration_p.h \
+ extensions/qwaylandxdgshellintegration_p.h
SOURCES += \
extensions/qwaylandquickshellsurfaceitem.cpp \
@@ -65,7 +73,10 @@ qtHaveModule(quick):contains(QT_CONFIG, opengl) {
extensions/qwaylandwlshellintegration.cpp \
extensions/qwaylandxdgshellv5integration.cpp \
extensions/qwaylandxdgshellv6integration.cpp \
+ extensions/qwaylandxdgshellintegration.cpp
}
+include ($$PWD/pregenerated/xdg-shell-v5.pri)
+
INCLUDEPATH += extensions
diff --git a/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5.cpp b/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5.cpp
new file mode 100644
index 000000000..77044d8e1
--- /dev/null
+++ b/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5.cpp
@@ -0,0 +1,899 @@
+/*
+ * Copyright © 2008-2013 Kristian Høgsberg
+ * Copyright © 2013 Rafael Antognolli
+ * Copyright © 2013 Jasper St. Pierre
+ * Copyright © 2010-2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <QtWaylandCompositor/private/qwayland-server-xdg-shell-unstable-v5_p.h>
+
+QT_BEGIN_NAMESPACE
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers")
+
+namespace QtWaylandServer {
+ xdg_shell_v5::xdg_shell_v5(struct ::wl_client *client, int id, int version)
+ : m_resource_map()
+ , m_resource(nullptr)
+ , m_global(nullptr)
+ {
+ init(client, id, version);
+ }
+
+ xdg_shell_v5::xdg_shell_v5(struct ::wl_display *display, int version)
+ : m_resource_map()
+ , m_resource(nullptr)
+ , m_global(nullptr)
+ {
+ init(display, version);
+ }
+
+ xdg_shell_v5::xdg_shell_v5(struct ::wl_resource *resource)
+ : m_resource_map()
+ , m_resource(nullptr)
+ , m_global(nullptr)
+ {
+ init(resource);
+ }
+
+ xdg_shell_v5::xdg_shell_v5()
+ : m_resource_map()
+ , m_resource(nullptr)
+ , m_global(nullptr)
+ {
+ }
+
+ xdg_shell_v5::~xdg_shell_v5()
+ {
+ for (auto resource : qAsConst(m_resource_map))
+ wl_resource_set_implementation(resource->handle, nullptr, nullptr, nullptr);
+
+ if (m_global) {
+ wl_global_destroy(m_global);
+ wl_list_remove(&m_displayDestroyedListener.link);
+ }
+ }
+
+ void xdg_shell_v5::init(struct ::wl_client *client, int id, int version)
+ {
+ m_resource = bind(client, id, version);
+ }
+
+ void xdg_shell_v5::init(struct ::wl_resource *resource)
+ {
+ m_resource = bind(resource);
+ }
+
+ xdg_shell_v5::Resource *xdg_shell_v5::add(struct ::wl_client *client, int version)
+ {
+ Resource *resource = bind(client, 0, version);
+ m_resource_map.insert(client, resource);
+ return resource;
+ }
+
+ xdg_shell_v5::Resource *xdg_shell_v5::add(struct ::wl_client *client, int id, int version)
+ {
+ Resource *resource = bind(client, id, version);
+ m_resource_map.insert(client, resource);
+ return resource;
+ }
+
+ void xdg_shell_v5::init(struct ::wl_display *display, int version)
+ {
+ m_global = wl_global_create(display, &::xdg_shell_v5_interface, version, this, bind_func);
+ m_globalVersion = version;
+ m_displayDestroyedListener.notify = xdg_shell_v5::display_destroy_func;
+ m_displayDestroyedListener.parent = this;
+ wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
+ }
+
+ const struct wl_interface *xdg_shell_v5::interface()
+ {
+ return &::xdg_shell_v5_interface;
+ }
+
+ xdg_shell_v5::Resource *xdg_shell_v5::xdg_shell_allocate()
+ {
+ return new Resource;
+ }
+
+ void xdg_shell_v5::xdg_shell_bind_resource(Resource *)
+ {
+ }
+
+ void xdg_shell_v5::xdg_shell_destroy_resource(Resource *)
+ {
+ }
+
+ void xdg_shell_v5::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
+ {
+ xdg_shell_v5 *that = static_cast<xdg_shell_v5 *>(data);
+ that->add(client, id, qMin(that->m_globalVersion, version));
+ }
+
+ void xdg_shell_v5::display_destroy_func(struct ::wl_listener *listener, void *data)
+ {
+ Q_UNUSED(data);
+ xdg_shell_v5 *that = static_cast<xdg_shell_v5::DisplayDestroyedListener *>(listener)->parent;
+ that->m_global = nullptr;
+ }
+
+ void xdg_shell_v5::destroy_func(struct ::wl_resource *client_resource)
+ {
+ Resource *resource = Resource::fromResource(client_resource);
+ xdg_shell_v5 *that = resource->xdg_shell_object;
+ that->m_resource_map.remove(resource->client(), resource);
+ that->xdg_shell_destroy_resource(resource);
+ delete resource;
+#if !WAYLAND_VERSION_CHECK(1, 2, 0)
+ free(client_resource);
+#endif
+ }
+
+ xdg_shell_v5::Resource *xdg_shell_v5::bind(struct ::wl_client *client, uint32_t id, int version)
+ {
+ Q_ASSERT_X(!wl_client_get_object(client, id), "QWaylandObject bind", QStringLiteral("binding to object %1 more than once").arg(id).toLocal8Bit().constData());
+ struct ::wl_resource *handle = wl_resource_create(client, &::xdg_shell_v5_interface, version, id);
+ return bind(handle);
+ }
+
+ xdg_shell_v5::Resource *xdg_shell_v5::bind(struct ::wl_resource *handle)
+ {
+ Resource *resource = xdg_shell_allocate();
+ resource->xdg_shell_object = this;
+
+ wl_resource_set_implementation(handle, &m_xdg_shell_interface, resource, destroy_func);
+ resource->handle = handle;
+ xdg_shell_bind_resource(resource);
+ return resource;
+ }
+ xdg_shell_v5::Resource *xdg_shell_v5::Resource::fromResource(struct ::wl_resource *resource)
+ {
+ if (wl_resource_instance_of(resource, &::xdg_shell_v5_interface, &m_xdg_shell_interface))
+ return static_cast<Resource *>(resource->data);
+ return nullptr;
+ }
+
+ const struct ::xdg_shell_v5_interface xdg_shell_v5::m_xdg_shell_interface = {
+ xdg_shell_v5::handle_destroy,
+ xdg_shell_v5::handle_use_unstable_version,
+ xdg_shell_v5::handle_get_xdg_surface,
+ xdg_shell_v5::handle_get_xdg_popup,
+ xdg_shell_v5::handle_pong
+ };
+
+ void xdg_shell_v5::xdg_shell_destroy(Resource *)
+ {
+ }
+
+ void xdg_shell_v5::xdg_shell_use_unstable_version(Resource *, int32_t )
+ {
+ }
+
+ void xdg_shell_v5::xdg_shell_get_xdg_surface(Resource *, uint32_t, struct ::wl_resource *)
+ {
+ }
+
+ void xdg_shell_v5::xdg_shell_get_xdg_popup(Resource *, uint32_t, struct ::wl_resource *, struct ::wl_resource *, struct ::wl_resource *, uint32_t , int32_t , int32_t )
+ {
+ }
+
+ void xdg_shell_v5::xdg_shell_pong(Resource *, uint32_t )
+ {
+ }
+
+
+ void xdg_shell_v5::handle_destroy(
+ ::wl_client *client,
+ struct wl_resource *resource)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_shell_v5 *>(r->xdg_shell_object)->xdg_shell_destroy(
+ r);
+ }
+
+ void xdg_shell_v5::handle_use_unstable_version(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ int32_t version)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_shell_v5 *>(r->xdg_shell_object)->xdg_shell_use_unstable_version(
+ r,
+ version);
+ }
+
+ void xdg_shell_v5::handle_get_xdg_surface(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ uint32_t id,
+ struct ::wl_resource *surface)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_shell_v5 *>(r->xdg_shell_object)->xdg_shell_get_xdg_surface(
+ r,
+ id,
+ surface);
+ }
+
+ void xdg_shell_v5::handle_get_xdg_popup(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ uint32_t id,
+ struct ::wl_resource *surface,
+ struct ::wl_resource *parent,
+ struct ::wl_resource *seat,
+ uint32_t serial,
+ int32_t x,
+ int32_t y)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_shell_v5 *>(r->xdg_shell_object)->xdg_shell_get_xdg_popup(
+ r,
+ id,
+ surface,
+ parent,
+ seat,
+ serial,
+ x,
+ y);
+ }
+
+ void xdg_shell_v5::handle_pong(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ uint32_t serial)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_shell_v5 *>(r->xdg_shell_object)->xdg_shell_pong(
+ r,
+ serial);
+ }
+
+ void xdg_shell_v5::send_ping(uint32_t serial)
+ {
+ send_ping(
+ m_resource->handle,
+ serial);
+ }
+
+ void xdg_shell_v5::send_ping(struct ::wl_resource *resource, uint32_t serial)
+ {
+ xdg_shell_send_ping(
+ resource,
+ serial);
+ }
+
+
+ xdg_surface_v5::xdg_surface_v5(struct ::wl_client *client, int id, int version)
+ : m_resource_map()
+ , m_resource(nullptr)
+ , m_global(nullptr)
+ {
+ init(client, id, version);
+ }
+
+ xdg_surface_v5::xdg_surface_v5(struct ::wl_display *display, int version)
+ : m_resource_map()
+ , m_resource(nullptr)
+ , m_global(nullptr)
+ {
+ init(display, version);
+ }
+
+ xdg_surface_v5::xdg_surface_v5(struct ::wl_resource *resource)
+ : m_resource_map()
+ , m_resource(nullptr)
+ , m_global(nullptr)
+ {
+ init(resource);
+ }
+
+ xdg_surface_v5::xdg_surface_v5()
+ : m_resource_map()
+ , m_resource(nullptr)
+ , m_global(nullptr)
+ {
+ }
+
+ xdg_surface_v5::~xdg_surface_v5()
+ {
+ for (auto resource : qAsConst(m_resource_map))
+ wl_resource_set_implementation(resource->handle, nullptr, nullptr, nullptr);
+
+ if (m_global) {
+ wl_global_destroy(m_global);
+ wl_list_remove(&m_displayDestroyedListener.link);
+ }
+ }
+
+ void xdg_surface_v5::init(struct ::wl_client *client, int id, int version)
+ {
+ m_resource = bind(client, id, version);
+ }
+
+ void xdg_surface_v5::init(struct ::wl_resource *resource)
+ {
+ m_resource = bind(resource);
+ }
+
+ xdg_surface_v5::Resource *xdg_surface_v5::add(struct ::wl_client *client, int version)
+ {
+ Resource *resource = bind(client, 0, version);
+ m_resource_map.insert(client, resource);
+ return resource;
+ }
+
+ xdg_surface_v5::Resource *xdg_surface_v5::add(struct ::wl_client *client, int id, int version)
+ {
+ Resource *resource = bind(client, id, version);
+ m_resource_map.insert(client, resource);
+ return resource;
+ }
+
+ void xdg_surface_v5::init(struct ::wl_display *display, int version)
+ {
+ m_global = wl_global_create(display, &::xdg_surface_v5_interface, version, this, bind_func);
+ m_globalVersion = version;
+ m_displayDestroyedListener.notify = xdg_surface_v5::display_destroy_func;
+ m_displayDestroyedListener.parent = this;
+ wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
+ }
+
+ const struct wl_interface *xdg_surface_v5::interface()
+ {
+ return &::xdg_surface_v5_interface;
+ }
+
+ xdg_surface_v5::Resource *xdg_surface_v5::xdg_surface_allocate()
+ {
+ return new Resource;
+ }
+
+ void xdg_surface_v5::xdg_surface_bind_resource(Resource *)
+ {
+ }
+
+ void xdg_surface_v5::xdg_surface_destroy_resource(Resource *)
+ {
+ }
+
+ void xdg_surface_v5::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
+ {
+ xdg_surface_v5 *that = static_cast<xdg_surface_v5 *>(data);
+ that->add(client, id, qMin(that->m_globalVersion, version));
+ }
+
+ void xdg_surface_v5::display_destroy_func(struct ::wl_listener *listener, void *data)
+ {
+ Q_UNUSED(data);
+ xdg_surface_v5 *that = static_cast<xdg_surface_v5::DisplayDestroyedListener *>(listener)->parent;
+ that->m_global = nullptr;
+ }
+
+ void xdg_surface_v5::destroy_func(struct ::wl_resource *client_resource)
+ {
+ Resource *resource = Resource::fromResource(client_resource);
+ xdg_surface_v5 *that = resource->xdg_surface_object;
+ that->m_resource_map.remove(resource->client(), resource);
+ that->xdg_surface_destroy_resource(resource);
+ delete resource;
+#if !WAYLAND_VERSION_CHECK(1, 2, 0)
+ free(client_resource);
+#endif
+ }
+
+ xdg_surface_v5::Resource *xdg_surface_v5::bind(struct ::wl_client *client, uint32_t id, int version)
+ {
+ Q_ASSERT_X(!wl_client_get_object(client, id), "QWaylandObject bind", QStringLiteral("binding to object %1 more than once").arg(id).toLocal8Bit().constData());
+ struct ::wl_resource *handle = wl_resource_create(client, &::xdg_surface_v5_interface, version, id);
+ return bind(handle);
+ }
+
+ xdg_surface_v5::Resource *xdg_surface_v5::bind(struct ::wl_resource *handle)
+ {
+ Resource *resource = xdg_surface_allocate();
+ resource->xdg_surface_object = this;
+
+ wl_resource_set_implementation(handle, &m_xdg_surface_interface, resource, destroy_func);
+ resource->handle = handle;
+ xdg_surface_bind_resource(resource);
+ return resource;
+ }
+ xdg_surface_v5::Resource *xdg_surface_v5::Resource::fromResource(struct ::wl_resource *resource)
+ {
+ if (wl_resource_instance_of(resource, &::xdg_surface_v5_interface, &m_xdg_surface_interface))
+ return static_cast<Resource *>(resource->data);
+ return nullptr;
+ }
+
+ const struct ::xdg_surface_v5_interface xdg_surface_v5::m_xdg_surface_interface = {
+ xdg_surface_v5::handle_destroy,
+ xdg_surface_v5::handle_set_parent,
+ xdg_surface_v5::handle_set_title,
+ xdg_surface_v5::handle_set_app_id,
+ xdg_surface_v5::handle_show_window_menu,
+ xdg_surface_v5::handle_move,
+ xdg_surface_v5::handle_resize,
+ xdg_surface_v5::handle_ack_configure,
+ xdg_surface_v5::handle_set_window_geometry,
+ xdg_surface_v5::handle_set_maximized,
+ xdg_surface_v5::handle_unset_maximized,
+ xdg_surface_v5::handle_set_fullscreen,
+ xdg_surface_v5::handle_unset_fullscreen,
+ xdg_surface_v5::handle_set_minimized
+ };
+
+ void xdg_surface_v5::xdg_surface_destroy(Resource *)
+ {
+ }
+
+ void xdg_surface_v5::xdg_surface_set_parent(Resource *, struct ::wl_resource *)
+ {
+ }
+
+ void xdg_surface_v5::xdg_surface_set_title(Resource *, const QString &)
+ {
+ }
+
+ void xdg_surface_v5::xdg_surface_set_app_id(Resource *, const QString &)
+ {
+ }
+
+ void xdg_surface_v5::xdg_surface_show_window_menu(Resource *, struct ::wl_resource *, uint32_t , int32_t , int32_t )
+ {
+ }
+
+ void xdg_surface_v5::xdg_surface_move(Resource *, struct ::wl_resource *, uint32_t )
+ {
+ }
+
+ void xdg_surface_v5::xdg_surface_resize(Resource *, struct ::wl_resource *, uint32_t , uint32_t )
+ {
+ }
+
+ void xdg_surface_v5::xdg_surface_ack_configure(Resource *, uint32_t )
+ {
+ }
+
+ void xdg_surface_v5::xdg_surface_set_window_geometry(Resource *, int32_t , int32_t , int32_t , int32_t )
+ {
+ }
+
+ void xdg_surface_v5::xdg_surface_set_maximized(Resource *)
+ {
+ }
+
+ void xdg_surface_v5::xdg_surface_unset_maximized(Resource *)
+ {
+ }
+
+ void xdg_surface_v5::xdg_surface_set_fullscreen(Resource *, struct ::wl_resource *)
+ {
+ }
+
+ void xdg_surface_v5::xdg_surface_unset_fullscreen(Resource *)
+ {
+ }
+
+ void xdg_surface_v5::xdg_surface_set_minimized(Resource *)
+ {
+ }
+
+
+ void xdg_surface_v5::handle_destroy(
+ ::wl_client *client,
+ struct wl_resource *resource)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_destroy(
+ r);
+ }
+
+ void xdg_surface_v5::handle_set_parent(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ struct ::wl_resource *parent)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_parent(
+ r,
+ parent);
+ }
+
+ void xdg_surface_v5::handle_set_title(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ const char *title)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_title(
+ r,
+ QString::fromUtf8(title));
+ }
+
+ void xdg_surface_v5::handle_set_app_id(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ const char *app_id)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_app_id(
+ r,
+ QString::fromUtf8(app_id));
+ }
+
+ void xdg_surface_v5::handle_show_window_menu(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ struct ::wl_resource *seat,
+ uint32_t serial,
+ int32_t x,
+ int32_t y)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_show_window_menu(
+ r,
+ seat,
+ serial,
+ x,
+ y);
+ }
+
+ void xdg_surface_v5::handle_move(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ struct ::wl_resource *seat,
+ uint32_t serial)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_move(
+ r,
+ seat,
+ serial);
+ }
+
+ void xdg_surface_v5::handle_resize(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ struct ::wl_resource *seat,
+ uint32_t serial,
+ uint32_t edges)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_resize(
+ r,
+ seat,
+ serial,
+ edges);
+ }
+
+ void xdg_surface_v5::handle_ack_configure(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ uint32_t serial)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_ack_configure(
+ r,
+ serial);
+ }
+
+ void xdg_surface_v5::handle_set_window_geometry(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ int32_t x,
+ int32_t y,
+ int32_t width,
+ int32_t height)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_window_geometry(
+ r,
+ x,
+ y,
+ width,
+ height);
+ }
+
+ void xdg_surface_v5::handle_set_maximized(
+ ::wl_client *client,
+ struct wl_resource *resource)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_maximized(
+ r);
+ }
+
+ void xdg_surface_v5::handle_unset_maximized(
+ ::wl_client *client,
+ struct wl_resource *resource)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_unset_maximized(
+ r);
+ }
+
+ void xdg_surface_v5::handle_set_fullscreen(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ struct ::wl_resource *output)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_fullscreen(
+ r,
+ output);
+ }
+
+ void xdg_surface_v5::handle_unset_fullscreen(
+ ::wl_client *client,
+ struct wl_resource *resource)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_unset_fullscreen(
+ r);
+ }
+
+ void xdg_surface_v5::handle_set_minimized(
+ ::wl_client *client,
+ struct wl_resource *resource)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_surface_v5 *>(r->xdg_surface_object)->xdg_surface_set_minimized(
+ r);
+ }
+
+ void xdg_surface_v5::send_configure(int32_t width, int32_t height, const QByteArray &states, uint32_t serial)
+ {
+ send_configure(
+ m_resource->handle,
+ width,
+ height,
+ states,
+ serial);
+ }
+
+ void xdg_surface_v5::send_configure(struct ::wl_resource *resource, int32_t width, int32_t height, const QByteArray &states, uint32_t serial)
+ {
+ struct wl_array states_data;
+ states_data.size = states.size();
+ states_data.data = static_cast<void *>(const_cast<char *>(states.constData()));
+ states_data.alloc = 0;
+
+ xdg_surface_send_configure(
+ resource,
+ width,
+ height,
+ &states_data,
+ serial);
+ }
+
+
+ void xdg_surface_v5::send_close()
+ {
+ send_close(
+ m_resource->handle);
+ }
+
+ void xdg_surface_v5::send_close(struct ::wl_resource *resource)
+ {
+ xdg_surface_send_close(
+ resource);
+ }
+
+
+ xdg_popup_v5::xdg_popup_v5(struct ::wl_client *client, int id, int version)
+ : m_resource_map()
+ , m_resource(nullptr)
+ , m_global(nullptr)
+ {
+ init(client, id, version);
+ }
+
+ xdg_popup_v5::xdg_popup_v5(struct ::wl_display *display, int version)
+ : m_resource_map()
+ , m_resource(nullptr)
+ , m_global(nullptr)
+ {
+ init(display, version);
+ }
+
+ xdg_popup_v5::xdg_popup_v5(struct ::wl_resource *resource)
+ : m_resource_map()
+ , m_resource(nullptr)
+ , m_global(nullptr)
+ {
+ init(resource);
+ }
+
+ xdg_popup_v5::xdg_popup_v5()
+ : m_resource_map()
+ , m_resource(nullptr)
+ , m_global(nullptr)
+ {
+ }
+
+ xdg_popup_v5::~xdg_popup_v5()
+ {
+ for (auto resource : qAsConst(m_resource_map))
+ wl_resource_set_implementation(resource->handle, nullptr, nullptr, nullptr);
+
+ if (m_global) {
+ wl_global_destroy(m_global);
+ wl_list_remove(&m_displayDestroyedListener.link);
+ }
+ }
+
+ void xdg_popup_v5::init(struct ::wl_client *client, int id, int version)
+ {
+ m_resource = bind(client, id, version);
+ }
+
+ void xdg_popup_v5::init(struct ::wl_resource *resource)
+ {
+ m_resource = bind(resource);
+ }
+
+ xdg_popup_v5::Resource *xdg_popup_v5::add(struct ::wl_client *client, int version)
+ {
+ Resource *resource = bind(client, 0, version);
+ m_resource_map.insert(client, resource);
+ return resource;
+ }
+
+ xdg_popup_v5::Resource *xdg_popup_v5::add(struct ::wl_client *client, int id, int version)
+ {
+ Resource *resource = bind(client, id, version);
+ m_resource_map.insert(client, resource);
+ return resource;
+ }
+
+ void xdg_popup_v5::init(struct ::wl_display *display, int version)
+ {
+ m_global = wl_global_create(display, &::xdg_popup_v5_interface, version, this, bind_func);
+ m_globalVersion = version;
+ m_displayDestroyedListener.notify = xdg_popup_v5::display_destroy_func;
+ m_displayDestroyedListener.parent = this;
+ wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
+ }
+
+ const struct wl_interface *xdg_popup_v5::interface()
+ {
+ return &::xdg_popup_v5_interface;
+ }
+
+ xdg_popup_v5::Resource *xdg_popup_v5::xdg_popup_allocate()
+ {
+ return new Resource;
+ }
+
+ void xdg_popup_v5::xdg_popup_bind_resource(Resource *)
+ {
+ }
+
+ void xdg_popup_v5::xdg_popup_destroy_resource(Resource *)
+ {
+ }
+
+ void xdg_popup_v5::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
+ {
+ xdg_popup_v5 *that = static_cast<xdg_popup_v5 *>(data);
+ that->add(client, id, qMin(that->m_globalVersion, version));
+ }
+
+ void xdg_popup_v5::display_destroy_func(struct ::wl_listener *listener, void *data)
+ {
+ Q_UNUSED(data);
+ xdg_popup_v5 *that = static_cast<xdg_popup_v5::DisplayDestroyedListener *>(listener)->parent;
+ that->m_global = nullptr;
+ }
+
+ void xdg_popup_v5::destroy_func(struct ::wl_resource *client_resource)
+ {
+ Resource *resource = Resource::fromResource(client_resource);
+ xdg_popup_v5 *that = resource->xdg_popup_object;
+ that->m_resource_map.remove(resource->client(), resource);
+ that->xdg_popup_destroy_resource(resource);
+ delete resource;
+#if !WAYLAND_VERSION_CHECK(1, 2, 0)
+ free(client_resource);
+#endif
+ }
+
+ xdg_popup_v5::Resource *xdg_popup_v5::bind(struct ::wl_client *client, uint32_t id, int version)
+ {
+ Q_ASSERT_X(!wl_client_get_object(client, id), "QWaylandObject bind", QStringLiteral("binding to object %1 more than once").arg(id).toLocal8Bit().constData());
+ struct ::wl_resource *handle = wl_resource_create(client, &::xdg_popup_v5_interface, version, id);
+ return bind(handle);
+ }
+
+ xdg_popup_v5::Resource *xdg_popup_v5::bind(struct ::wl_resource *handle)
+ {
+ Resource *resource = xdg_popup_allocate();
+ resource->xdg_popup_object = this;
+
+ wl_resource_set_implementation(handle, &m_xdg_popup_interface, resource, destroy_func);
+ resource->handle = handle;
+ xdg_popup_bind_resource(resource);
+ return resource;
+ }
+ xdg_popup_v5::Resource *xdg_popup_v5::Resource::fromResource(struct ::wl_resource *resource)
+ {
+ if (wl_resource_instance_of(resource, &::xdg_popup_v5_interface, &m_xdg_popup_interface))
+ return static_cast<Resource *>(resource->data);
+ return nullptr;
+ }
+
+ const struct ::xdg_popup_v5_interface xdg_popup_v5::m_xdg_popup_interface = {
+ xdg_popup_v5::handle_destroy
+ };
+
+ void xdg_popup_v5::xdg_popup_destroy(Resource *)
+ {
+ }
+
+
+ void xdg_popup_v5::handle_destroy(
+ ::wl_client *client,
+ struct wl_resource *resource)
+ {
+ Q_UNUSED(client);
+ Resource *r = Resource::fromResource(resource);
+ static_cast<xdg_popup_v5 *>(r->xdg_popup_object)->xdg_popup_destroy(
+ r);
+ }
+
+ void xdg_popup_v5::send_popup_done()
+ {
+ send_popup_done(
+ m_resource->handle);
+ }
+
+ void xdg_popup_v5::send_popup_done(struct ::wl_resource *resource)
+ {
+ xdg_popup_send_popup_done(
+ resource);
+ }
+
+}
+
+QT_WARNING_POP
+QT_END_NAMESPACE
diff --git a/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5_p.h b/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5_p.h
new file mode 100644
index 000000000..dfd42535e
--- /dev/null
+++ b/src/compositor/extensions/pregenerated/3rdparty/qwayland-server-xdg-shell-unstable-v5_p.h
@@ -0,0 +1,436 @@
+/*
+ * Copyright © 2008-2013 Kristian Høgsberg
+ * Copyright © 2013 Rafael Antognolli
+ * Copyright © 2013 Jasper St. Pierre
+ * Copyright © 2010-2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef QT_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5
+#define QT_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5
+
+#include "wayland-server.h"
+#include <QtWaylandCompositor/private/wayland-xdg-shell-unstable-v5-server-protocol_p.h>
+#include <QByteArray>
+#include <QMultiMap>
+#include <QString>
+
+#ifndef WAYLAND_VERSION_CHECK
+#define WAYLAND_VERSION_CHECK(major, minor, micro) \
+ ((WAYLAND_VERSION_MAJOR > (major)) || \
+ (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \
+ (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro)))
+#endif
+
+QT_BEGIN_NAMESPACE
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers")
+QT_WARNING_DISABLE_CLANG("-Wmissing-field-initializers")
+
+#if !defined(Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT)
+# if defined(QT_SHARED)
+# define Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT Q_DECL_EXPORT
+# else
+# define Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT
+# endif
+#endif
+
+namespace QtWaylandServer {
+ class Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT xdg_shell_v5
+ {
+ public:
+ xdg_shell_v5(struct ::wl_client *client, int id, int version);
+ xdg_shell_v5(struct ::wl_display *display, int version);
+ xdg_shell_v5(struct ::wl_resource *resource);
+ xdg_shell_v5();
+
+ virtual ~xdg_shell_v5();
+
+ class Resource
+ {
+ public:
+ Resource() : xdg_shell_object(nullptr), handle(nullptr) {}
+ virtual ~Resource() {}
+
+ xdg_shell_v5 *xdg_shell_object;
+ struct ::wl_resource *handle;
+
+ struct ::wl_client *client() const { return handle->client; }
+ int version() const { return wl_resource_get_version(handle); }
+
+ static Resource *fromResource(struct ::wl_resource *resource);
+ };
+
+ void init(struct ::wl_client *client, int id, int version);
+ void init(struct ::wl_display *display, int version);
+ void init(struct ::wl_resource *resource);
+
+ Resource *add(struct ::wl_client *client, int version);
+ Resource *add(struct ::wl_client *client, int id, int version);
+ Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version);
+
+ Resource *resource() { return m_resource; }
+ const Resource *resource() const { return m_resource; }
+
+ QMultiMap<struct ::wl_client*, Resource*> resourceMap() { return m_resource_map; }
+ const QMultiMap<struct ::wl_client*, Resource*> resourceMap() const { return m_resource_map; }
+
+ bool isGlobal() const { return m_global != nullptr; }
+ bool isResource() const { return m_resource != nullptr; }
+
+ static const struct ::wl_interface *interface();
+ static QByteArray interfaceName() { return interface()->name; }
+ static int interfaceVersion() { return interface()->version; }
+
+
+ enum version {
+ version_current = 5 // Always the latest version
+ };
+
+ enum error {
+ error_role = 0, // given wl_surface has another role
+ error_defunct_surfaces = 1, // xdg_shell was destroyed before children
+ error_not_the_topmost_popup = 2, // the client tried to map or destroy a non-topmost popup
+ error_invalid_popup_parent = 3 // the client specified an invalid popup parent surface
+ };
+
+ void send_ping(uint32_t serial);
+ void send_ping(struct ::wl_resource *resource, uint32_t serial);
+
+ protected:
+ virtual Resource *xdg_shell_allocate();
+
+ virtual void xdg_shell_bind_resource(Resource *resource);
+ virtual void xdg_shell_destroy_resource(Resource *resource);
+
+ virtual void xdg_shell_destroy(Resource *resource);
+ virtual void xdg_shell_use_unstable_version(Resource *resource, int32_t version);
+ virtual void xdg_shell_get_xdg_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface);
+ virtual void xdg_shell_get_xdg_popup(Resource *resource, uint32_t id, struct ::wl_resource *surface, struct ::wl_resource *parent, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y);
+ virtual void xdg_shell_pong(Resource *resource, uint32_t serial);
+
+ private:
+ static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id);
+ static void destroy_func(struct ::wl_resource *client_resource);
+ static void display_destroy_func(struct ::wl_listener *listener, void *data);
+
+ Resource *bind(struct ::wl_client *client, uint32_t id, int version);
+ Resource *bind(struct ::wl_resource *handle);
+
+ static const struct ::xdg_shell_v5_interface m_xdg_shell_interface;
+
+ static void handle_destroy(
+ ::wl_client *client,
+ struct wl_resource *resource);
+ static void handle_use_unstable_version(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ int32_t version);
+ static void handle_get_xdg_surface(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ uint32_t id,
+ struct ::wl_resource *surface);
+ static void handle_get_xdg_popup(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ uint32_t id,
+ struct ::wl_resource *surface,
+ struct ::wl_resource *parent,
+ struct ::wl_resource *seat,
+ uint32_t serial,
+ int32_t x,
+ int32_t y);
+ static void handle_pong(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ uint32_t serial);
+
+ QMultiMap<struct ::wl_client*, Resource*> m_resource_map;
+ Resource *m_resource;
+ struct ::wl_global *m_global;
+ uint32_t m_globalVersion;
+ struct DisplayDestroyedListener : ::wl_listener {
+ xdg_shell_v5 *parent;
+ };
+ DisplayDestroyedListener m_displayDestroyedListener;
+ };
+
+ class Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT xdg_surface_v5
+ {
+ public:
+ xdg_surface_v5(struct ::wl_client *client, int id, int version);
+ xdg_surface_v5(struct ::wl_display *display, int version);
+ xdg_surface_v5(struct ::wl_resource *resource);
+ xdg_surface_v5();
+
+ virtual ~xdg_surface_v5();
+
+ class Resource
+ {
+ public:
+ Resource() : xdg_surface_object(nullptr), handle(nullptr) {}
+ virtual ~Resource() {}
+
+ xdg_surface_v5 *xdg_surface_object;
+ struct ::wl_resource *handle;
+
+ struct ::wl_client *client() const { return handle->client; }
+ int version() const { return wl_resource_get_version(handle); }
+
+ static Resource *fromResource(struct ::wl_resource *resource);
+ };
+
+ void init(struct ::wl_client *client, int id, int version);
+ void init(struct ::wl_display *display, int version);
+ void init(struct ::wl_resource *resource);
+
+ Resource *add(struct ::wl_client *client, int version);
+ Resource *add(struct ::wl_client *client, int id, int version);
+ Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version);
+
+ Resource *resource() { return m_resource; }
+ const Resource *resource() const { return m_resource; }
+
+ QMultiMap<struct ::wl_client*, Resource*> resourceMap() { return m_resource_map; }
+ const QMultiMap<struct ::wl_client*, Resource*> resourceMap() const { return m_resource_map; }
+
+ bool isGlobal() const { return m_global != nullptr; }
+ bool isResource() const { return m_resource != nullptr; }
+
+ static const struct ::wl_interface *interface();
+ static QByteArray interfaceName() { return interface()->name; }
+ static int interfaceVersion() { return interface()->version; }
+
+
+ enum resize_edge {
+ resize_edge_none = 0,
+ resize_edge_top = 1,
+ resize_edge_bottom = 2,
+ resize_edge_left = 4,
+ resize_edge_top_left = 5,
+ resize_edge_bottom_left = 6,
+ resize_edge_right = 8,
+ resize_edge_top_right = 9,
+ resize_edge_bottom_right = 10
+ };
+
+ enum state {
+ state_maximized = 1, // the surface is maximized
+ state_fullscreen = 2, // the surface is fullscreen
+ state_resizing = 3,
+ state_activated = 4
+ };
+
+ void send_configure(int32_t width, int32_t height, const QByteArray &states, uint32_t serial);
+ void send_configure(struct ::wl_resource *resource, int32_t width, int32_t height, const QByteArray &states, uint32_t serial);
+ void send_close();
+ void send_close(struct ::wl_resource *resource);
+
+ protected:
+ virtual Resource *xdg_surface_allocate();
+
+ virtual void xdg_surface_bind_resource(Resource *resource);
+ virtual void xdg_surface_destroy_resource(Resource *resource);
+
+ virtual void xdg_surface_destroy(Resource *resource);
+ virtual void xdg_surface_set_parent(Resource *resource, struct ::wl_resource *parent);
+ virtual void xdg_surface_set_title(Resource *resource, const QString &title);
+ virtual void xdg_surface_set_app_id(Resource *resource, const QString &app_id);
+ virtual void xdg_surface_show_window_menu(Resource *resource, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y);
+ virtual void xdg_surface_move(Resource *resource, struct ::wl_resource *seat, uint32_t serial);
+ virtual void xdg_surface_resize(Resource *resource, struct ::wl_resource *seat, uint32_t serial, uint32_t edges);
+ virtual void xdg_surface_ack_configure(Resource *resource, uint32_t serial);
+ virtual void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height);
+ virtual void xdg_surface_set_maximized(Resource *resource);
+ virtual void xdg_surface_unset_maximized(Resource *resource);
+ virtual void xdg_surface_set_fullscreen(Resource *resource, struct ::wl_resource *output);
+ virtual void xdg_surface_unset_fullscreen(Resource *resource);
+ virtual void xdg_surface_set_minimized(Resource *resource);
+
+ private:
+ static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id);
+ static void destroy_func(struct ::wl_resource *client_resource);
+ static void display_destroy_func(struct ::wl_listener *listener, void *data);
+
+ Resource *bind(struct ::wl_client *client, uint32_t id, int version);
+ Resource *bind(struct ::wl_resource *handle);
+
+ static const struct ::xdg_surface_v5_interface m_xdg_surface_interface;
+
+ static void handle_destroy(
+ ::wl_client *client,
+ struct wl_resource *resource);
+ static void handle_set_parent(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ struct ::wl_resource *parent);
+ static void handle_set_title(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ const char *title);
+ static void handle_set_app_id(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ const char *app_id);
+ static void handle_show_window_menu(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ struct ::wl_resource *seat,
+ uint32_t serial,
+ int32_t x,
+ int32_t y);
+ static void handle_move(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ struct ::wl_resource *seat,
+ uint32_t serial);
+ static void handle_resize(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ struct ::wl_resource *seat,
+ uint32_t serial,
+ uint32_t edges);
+ static void handle_ack_configure(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ uint32_t serial);
+ static void handle_set_window_geometry(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ int32_t x,
+ int32_t y,
+ int32_t width,
+ int32_t height);
+ static void handle_set_maximized(
+ ::wl_client *client,
+ struct wl_resource *resource);
+ static void handle_unset_maximized(
+ ::wl_client *client,
+ struct wl_resource *resource);
+ static void handle_set_fullscreen(
+ ::wl_client *client,
+ struct wl_resource *resource,
+ struct ::wl_resource *output);
+ static void handle_unset_fullscreen(
+ ::wl_client *client,
+ struct wl_resource *resource);
+ static void handle_set_minimized(
+ ::wl_client *client,
+ struct wl_resource *resource);
+
+ QMultiMap<struct ::wl_client*, Resource*> m_resource_map;
+ Resource *m_resource;
+ struct ::wl_global *m_global;
+ uint32_t m_globalVersion;
+ struct DisplayDestroyedListener : ::wl_listener {
+ xdg_surface_v5 *parent;
+ };
+ DisplayDestroyedListener m_displayDestroyedListener;
+ };
+
+ class Q_WAYLAND_SERVER_XDG_SHELL_UNSTABLE_V5_EXPORT xdg_popup_v5
+ {
+ public:
+ xdg_popup_v5(struct ::wl_client *client, int id, int version);
+ xdg_popup_v5(struct ::wl_display *display, int version);
+ xdg_popup_v5(struct ::wl_resource *resource);
+ xdg_popup_v5();
+
+ virtual ~xdg_popup_v5();
+
+ class Resource
+ {
+ public:
+ Resource() : xdg_popup_object(nullptr), handle(nullptr) {}
+ virtual ~Resource() {}
+
+ xdg_popup_v5 *xdg_popup_object;
+ struct ::wl_resource *handle;
+
+ struct ::wl_client *client() const { return handle->client; }
+ int version() const { return wl_resource_get_version(handle); }
+
+ static Resource *fromResource(struct ::wl_resource *resource);
+ };
+
+ void init(struct ::wl_client *client, int id, int version);
+ void init(struct ::wl_display *display, int version);
+ void init(struct ::wl_resource *resource);
+
+ Resource *add(struct ::wl_client *client, int version);
+ Resource *add(struct ::wl_client *client, int id, int version);
+ Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version);
+
+ Resource *resource() { return m_resource; }
+ const Resource *resource() const { return m_resource; }
+
+ QMultiMap<struct ::wl_client*, Resource*> resourceMap() { return m_resource_map; }
+ const QMultiMap<struct ::wl_client*, Resource*> resourceMap() const { return m_resource_map; }
+
+ bool isGlobal() const { return m_global != nullptr; }
+ bool isResource() const { return m_resource != nullptr; }
+
+ static const struct ::wl_interface *interface();
+ static QByteArray interfaceName() { return interface()->name; }
+ static int interfaceVersion() { return interface()->version; }
+
+
+ void send_popup_done();
+ void send_popup_done(struct ::wl_resource *resource);
+
+ protected:
+ virtual Resource *xdg_popup_allocate();
+
+ virtual void xdg_popup_bind_resource(Resource *resource);
+ virtual void xdg_popup_destroy_resource(Resource *resource);
+
+ virtual void xdg_popup_destroy(Resource *resource);
+
+ private:
+ static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id);
+ static void destroy_func(struct ::wl_resource *client_resource);
+ static void display_destroy_func(struct ::wl_listener *listener, void *data);
+
+ Resource *bind(struct ::wl_client *client, uint32_t id, int version);
+ Resource *bind(struct ::wl_resource *handle);
+
+ static const struct ::xdg_popup_v5_interface m_xdg_popup_interface;
+
+ static void handle_destroy(
+ ::wl_client *client,
+ struct wl_resource *resource);
+
+ QMultiMap<struct ::wl_client*, Resource*> m_resource_map;
+ Resource *m_resource;
+ struct ::wl_global *m_global;
+ uint32_t m_globalVersion;
+ struct DisplayDestroyedListener : ::wl_listener {
+ xdg_popup_v5 *parent;
+ };
+ DisplayDestroyedListener m_displayDestroyedListener;
+ };
+}
+
+QT_WARNING_POP
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c b/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c
new file mode 100644
index 000000000..e2781c994
--- /dev/null
+++ b/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c
@@ -0,0 +1,126 @@
+/* Generated by wayland-scanner 1.15.92 */
+// Hand edited to resolve conflicts with xdg-shell stable
+
+/*
+ * Copyright © 2008-2013 Kristian Høgsberg
+ * Copyright © 2013 Rafael Antognolli
+ * Copyright © 2013 Jasper St. Pierre
+ * Copyright © 2010-2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+#include "wayland-util.h"
+
+extern const struct wl_interface wl_output_interface;
+extern const struct wl_interface wl_seat_interface;
+extern const struct wl_interface wl_surface_interface;
+extern const struct wl_interface xdg_popup_v5_interface;
+extern const struct wl_interface xdg_surface_v5_interface;
+
+static const struct wl_interface *types[] = {
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &xdg_surface_v5_interface,
+ &wl_surface_interface,
+ &xdg_popup_v5_interface,
+ &wl_surface_interface,
+ &wl_surface_interface,
+ &wl_seat_interface,
+ NULL,
+ NULL,
+ NULL,
+ &xdg_surface_v5_interface,
+ &wl_seat_interface,
+ NULL,
+ NULL,
+ NULL,
+ &wl_seat_interface,
+ NULL,
+ &wl_seat_interface,
+ NULL,
+ NULL,
+ &wl_output_interface,
+};
+
+static const struct wl_message xdg_shell_requests[] = {
+ { "destroy", "", types + 0 },
+ { "use_unstable_version", "i", types + 0 },
+ { "get_xdg_surface", "no", types + 4 },
+ { "get_xdg_popup", "nooouii", types + 6 },
+ { "pong", "u", types + 0 },
+};
+
+static const struct wl_message xdg_shell_events[] = {
+ { "ping", "u", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface xdg_shell_v5_interface = {
+ "xdg_shell", 1,
+ 5, xdg_shell_requests,
+ 1, xdg_shell_events,
+};
+
+static const struct wl_message xdg_surface_requests[] = {
+ { "destroy", "", types + 0 },
+ { "set_parent", "?o", types + 13 },
+ { "set_title", "s", types + 0 },
+ { "set_app_id", "s", types + 0 },
+ { "show_window_menu", "ouii", types + 14 },
+ { "move", "ou", types + 18 },
+ { "resize", "ouu", types + 20 },
+ { "ack_configure", "u", types + 0 },
+ { "set_window_geometry", "iiii", types + 0 },
+ { "set_maximized", "", types + 0 },
+ { "unset_maximized", "", types + 0 },
+ { "set_fullscreen", "?o", types + 23 },
+ { "unset_fullscreen", "", types + 0 },
+ { "set_minimized", "", types + 0 },
+};
+
+static const struct wl_message xdg_surface_events[] = {
+ { "configure", "iiau", types + 0 },
+ { "close", "", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface xdg_surface_v5_interface = {
+ "xdg_surface", 1,
+ 14, xdg_surface_requests,
+ 2, xdg_surface_events,
+};
+
+static const struct wl_message xdg_popup_requests[] = {
+ { "destroy", "", types + 0 },
+};
+
+static const struct wl_message xdg_popup_events[] = {
+ { "popup_done", "", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface xdg_popup_v5_interface = {
+ "xdg_popup", 1,
+ 1, xdg_popup_requests,
+ 1, xdg_popup_events,
+};
+
diff --git a/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-server-protocol_p.h b/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-server-protocol_p.h
new file mode 100644
index 000000000..b979f048c
--- /dev/null
+++ b/src/compositor/extensions/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-server-protocol_p.h
@@ -0,0 +1,905 @@
+/* Generated by wayland-scanner 1.15.92 */
+// Hand edited to resolve conflicts with xdg-shell stable
+
+#ifndef XDG_SHELL_UNSTABLE_V5_SERVER_PROTOCOL_H
+#define XDG_SHELL_UNSTABLE_V5_SERVER_PROTOCOL_H
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-server.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct wl_client;
+struct wl_resource;
+
+/**
+ * @page page_xdg_shell_unstable_v5 The xdg_shell_unstable_v5 protocol
+ * @section page_ifaces_xdg_shell_unstable_v5 Interfaces
+ * - @subpage page_iface_xdg_shell - create desktop-style surfaces
+ * - @subpage page_iface_xdg_surface - A desktop window
+ * - @subpage page_iface_xdg_popup - short-lived, popup surfaces for menus
+ * @section page_copyright_xdg_shell_unstable_v5 Copyright
+ * <pre>
+ *
+ * Copyright © 2008-2013 Kristian Høgsberg
+ * Copyright © 2013 Rafael Antognolli
+ * Copyright © 2013 Jasper St. Pierre
+ * Copyright © 2010-2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ * </pre>
+ */
+struct wl_output;
+struct wl_seat;
+struct wl_surface;
+struct xdg_popup;
+struct xdg_shell;
+struct xdg_surface;
+
+/**
+ * @page page_iface_xdg_shell xdg_shell
+ * @section page_iface_xdg_shell_desc Description
+ *
+ * xdg_shell allows clients to turn a wl_surface into a "real window"
+ * which can be dragged, resized, stacked, and moved around by the
+ * user. Everything about this interface is suited towards traditional
+ * desktop environments.
+ * @section page_iface_xdg_shell_api API
+ * See @ref iface_xdg_shell.
+ */
+/**
+ * @defgroup iface_xdg_shell The xdg_shell interface
+ *
+ * xdg_shell allows clients to turn a wl_surface into a "real window"
+ * which can be dragged, resized, stacked, and moved around by the
+ * user. Everything about this interface is suited towards traditional
+ * desktop environments.
+ */
+extern const struct wl_interface xdg_shell_v5_interface;
+/**
+ * @page page_iface_xdg_surface xdg_surface
+ * @section page_iface_xdg_surface_desc Description
+ *
+ * An interface that may be implemented by a wl_surface, for
+ * implementations that provide a desktop-style user interface.
+ *
+ * It provides requests to treat surfaces like windows, allowing to set
+ * properties like maximized, fullscreen, minimized, and to move and resize
+ * them, and associate metadata like title and app id.
+ *
+ * The client must call wl_surface.commit on the corresponding wl_surface
+ * for the xdg_surface state to take effect. Prior to committing the new
+ * state, it can set up initial configuration, such as maximizing or setting
+ * a window geometry.
+ *
+ * Even without attaching a buffer the compositor must respond to initial
+ * committed configuration, for instance sending a configure event with
+ * expected window geometry if the client maximized its surface during
+ * initialization.
+ *
+ * For a surface to be mapped by the compositor the client must have
+ * committed both an xdg_surface state and a buffer.
+ * @section page_iface_xdg_surface_api API
+ * See @ref iface_xdg_surface.
+ */
+/**
+ * @defgroup iface_xdg_surface The xdg_surface interface
+ *
+ * An interface that may be implemented by a wl_surface, for
+ * implementations that provide a desktop-style user interface.
+ *
+ * It provides requests to treat surfaces like windows, allowing to set
+ * properties like maximized, fullscreen, minimized, and to move and resize
+ * them, and associate metadata like title and app id.
+ *
+ * The client must call wl_surface.commit on the corresponding wl_surface
+ * for the xdg_surface state to take effect. Prior to committing the new
+ * state, it can set up initial configuration, such as maximizing or setting
+ * a window geometry.
+ *
+ * Even without attaching a buffer the compositor must respond to initial
+ * committed configuration, for instance sending a configure event with
+ * expected window geometry if the client maximized its surface during
+ * initialization.
+ *
+ * For a surface to be mapped by the compositor the client must have
+ * committed both an xdg_surface state and a buffer.
+ */
+extern const struct wl_interface xdg_surface_v5_interface;
+/**
+ * @page page_iface_xdg_popup xdg_popup
+ * @section page_iface_xdg_popup_desc Description
+ *
+ * A popup surface is a short-lived, temporary surface that can be
+ * used to implement menus. It takes an explicit grab on the surface
+ * that will be dismissed when the user dismisses the popup. This can
+ * be done by the user clicking outside the surface, using the keyboard,
+ * or even locking the screen through closing the lid or a timeout.
+ *
+ * When the popup is dismissed, a popup_done event will be sent out,
+ * and at the same time the surface will be unmapped. The xdg_popup
+ * object is now inert and cannot be reactivated, so clients should
+ * destroy it. Explicitly destroying the xdg_popup object will also
+ * dismiss the popup and unmap the surface.
+ *
+ * Clients will receive events for all their surfaces during this
+ * grab (which is an "owner-events" grab in X11 parlance). This is
+ * done so that users can navigate through submenus and other
+ * "nested" popup windows without having to dismiss the topmost
+ * popup.
+ *
+ * Clients that want to dismiss the popup when another surface of
+ * their own is clicked should dismiss the popup using the destroy
+ * request.
+ *
+ * The parent surface must have either an xdg_surface or xdg_popup
+ * role.
+ *
+ * Specifying an xdg_popup for the parent means that the popups are
+ * nested, with this popup now being the topmost popup. Nested
+ * popups must be destroyed in the reverse order they were created
+ * in, e.g. the only popup you are allowed to destroy at all times
+ * is the topmost one.
+ *
+ * If there is an existing popup when creating a new popup, the
+ * parent must be the current topmost popup.
+ *
+ * A parent surface must be mapped before the new popup is mapped.
+ *
+ * When compositors choose to dismiss a popup, they will likely
+ * dismiss every nested popup as well. When a compositor dismisses
+ * popups, it will follow the same dismissing order as required
+ * from the client.
+ *
+ * The x and y arguments passed when creating the popup object specify
+ * where the top left of the popup should be placed, relative to the
+ * local surface coordinates of the parent surface. See
+ * xdg_shell.get_xdg_popup.
+ *
+ * The client must call wl_surface.commit on the corresponding wl_surface
+ * for the xdg_popup state to take effect.
+ *
+ * For a surface to be mapped by the compositor the client must have
+ * committed both the xdg_popup state and a buffer.
+ * @section page_iface_xdg_popup_api API
+ * See @ref iface_xdg_popup.
+ */
+/**
+ * @defgroup iface_xdg_popup The xdg_popup interface
+ *
+ * A popup surface is a short-lived, temporary surface that can be
+ * used to implement menus. It takes an explicit grab on the surface
+ * that will be dismissed when the user dismisses the popup. This can
+ * be done by the user clicking outside the surface, using the keyboard,
+ * or even locking the screen through closing the lid or a timeout.
+ *
+ * When the popup is dismissed, a popup_done event will be sent out,
+ * and at the same time the surface will be unmapped. The xdg_popup
+ * object is now inert and cannot be reactivated, so clients should
+ * destroy it. Explicitly destroying the xdg_popup object will also
+ * dismiss the popup and unmap the surface.
+ *
+ * Clients will receive events for all their surfaces during this
+ * grab (which is an "owner-events" grab in X11 parlance). This is
+ * done so that users can navigate through submenus and other
+ * "nested" popup windows without having to dismiss the topmost
+ * popup.
+ *
+ * Clients that want to dismiss the popup when another surface of
+ * their own is clicked should dismiss the popup using the destroy
+ * request.
+ *
+ * The parent surface must have either an xdg_surface or xdg_popup
+ * role.
+ *
+ * Specifying an xdg_popup for the parent means that the popups are
+ * nested, with this popup now being the topmost popup. Nested
+ * popups must be destroyed in the reverse order they were created
+ * in, e.g. the only popup you are allowed to destroy at all times
+ * is the topmost one.
+ *
+ * If there is an existing popup when creating a new popup, the
+ * parent must be the current topmost popup.
+ *
+ * A parent surface must be mapped before the new popup is mapped.
+ *
+ * When compositors choose to dismiss a popup, they will likely
+ * dismiss every nested popup as well. When a compositor dismisses
+ * popups, it will follow the same dismissing order as required
+ * from the client.
+ *
+ * The x and y arguments passed when creating the popup object specify
+ * where the top left of the popup should be placed, relative to the
+ * local surface coordinates of the parent surface. See
+ * xdg_shell.get_xdg_popup.
+ *
+ * The client must call wl_surface.commit on the corresponding wl_surface
+ * for the xdg_popup state to take effect.
+ *
+ * For a surface to be mapped by the compositor the client must have
+ * committed both the xdg_popup state and a buffer.
+ */
+extern const struct wl_interface xdg_popup_v5_interface;
+
+#ifndef XDG_SHELL_VERSION_ENUM
+#define XDG_SHELL_VERSION_ENUM
+/**
+ * @ingroup iface_xdg_shell
+ * latest protocol version
+ *
+ * The 'current' member of this enum gives the version of the
+ * protocol. Implementations can compare this to the version
+ * they implement using static_assert to ensure the protocol and
+ * implementation versions match.
+ */
+enum xdg_shell_version {
+ /**
+ * Always the latest version
+ */
+ XDG_SHELL_VERSION_CURRENT = 5,
+};
+#endif /* XDG_SHELL_VERSION_ENUM */
+
+#ifndef XDG_SHELL_ERROR_ENUM
+#define XDG_SHELL_ERROR_ENUM
+enum xdg_shell_error {
+ /**
+ * given wl_surface has another role
+ */
+ XDG_SHELL_ERROR_ROLE = 0,
+ /**
+ * xdg_shell was destroyed before children
+ */
+ XDG_SHELL_ERROR_DEFUNCT_SURFACES = 1,
+ /**
+ * the client tried to map or destroy a non-topmost popup
+ */
+ XDG_SHELL_ERROR_NOT_THE_TOPMOST_POPUP = 2,
+ /**
+ * the client specified an invalid popup parent surface
+ */
+ XDG_SHELL_ERROR_INVALID_POPUP_PARENT = 3,
+};
+#endif /* XDG_SHELL_ERROR_ENUM */
+
+/**
+ * @ingroup iface_xdg_shell
+ * @struct xdg_shell_v5_interface
+ */
+struct xdg_shell_v5_interface {
+ /**
+ * destroy xdg_shell
+ *
+ * Destroy this xdg_shell object.
+ *
+ * Destroying a bound xdg_shell object while there are surfaces
+ * still alive created by this xdg_shell object instance is illegal
+ * and will result in a protocol error.
+ */
+ void (*destroy)(struct wl_client *client,
+ struct wl_resource *resource);
+ /**
+ * enable use of this unstable version
+ *
+ * Negotiate the unstable version of the interface. This
+ * mechanism is in place to ensure client and server agree on the
+ * unstable versions of the protocol that they speak or exit
+ * cleanly if they don't agree. This request will go away once the
+ * xdg-shell protocol is stable.
+ */
+ void (*use_unstable_version)(struct wl_client *client,
+ struct wl_resource *resource,
+ int32_t version);
+ /**
+ * create a shell surface from a surface
+ *
+ * This creates an xdg_surface for the given surface and gives it
+ * the xdg_surface role. A wl_surface can only be given an
+ * xdg_surface role once. If get_xdg_surface is called with a
+ * wl_surface that already has an active xdg_surface associated
+ * with it, or if it had any other role, an error is raised.
+ *
+ * See the documentation of xdg_surface for more details about what
+ * an xdg_surface is and how it is used.
+ */
+ void (*get_xdg_surface)(struct wl_client *client,
+ struct wl_resource *resource,
+ uint32_t id,
+ struct wl_resource *surface);
+ /**
+ * create a popup for a surface
+ *
+ * This creates an xdg_popup for the given surface and gives it
+ * the xdg_popup role. A wl_surface can only be given an xdg_popup
+ * role once. If get_xdg_popup is called with a wl_surface that
+ * already has an active xdg_popup associated with it, or if it had
+ * any other role, an error is raised.
+ *
+ * This request must be used in response to some sort of user
+ * action like a button press, key press, or touch down event.
+ *
+ * See the documentation of xdg_popup for more details about what
+ * an xdg_popup is and how it is used.
+ * @param seat the wl_seat of the user event
+ * @param serial the serial of the user event
+ */
+ void (*get_xdg_popup)(struct wl_client *client,
+ struct wl_resource *resource,
+ uint32_t id,
+ struct wl_resource *surface,
+ struct wl_resource *parent,
+ struct wl_resource *seat,
+ uint32_t serial,
+ int32_t x,
+ int32_t y);
+ /**
+ * respond to a ping event
+ *
+ * A client must respond to a ping event with a pong request or
+ * the client may be deemed unresponsive.
+ * @param serial serial of the ping event
+ */
+ void (*pong)(struct wl_client *client,
+ struct wl_resource *resource,
+ uint32_t serial);
+};
+
+#define XDG_SHELL_PING 0
+
+/**
+ * @ingroup iface_xdg_shell
+ */
+#define XDG_SHELL_PING_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_xdg_shell
+ */
+#define XDG_SHELL_DESTROY_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_shell
+ */
+#define XDG_SHELL_USE_UNSTABLE_VERSION_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_shell
+ */
+#define XDG_SHELL_GET_XDG_SURFACE_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_shell
+ */
+#define XDG_SHELL_GET_XDG_POPUP_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_shell
+ */
+#define XDG_SHELL_PONG_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_xdg_shell
+ * Sends an ping event to the client owning the resource.
+ * @param resource_ The client's resource
+ * @param serial pass this to the pong request
+ */
+static inline void
+xdg_shell_send_ping(struct wl_resource *resource_, uint32_t serial)
+{
+ wl_resource_post_event(resource_, XDG_SHELL_PING, serial);
+}
+
+#ifndef XDG_SURFACE_RESIZE_EDGE_ENUM
+#define XDG_SURFACE_RESIZE_EDGE_ENUM
+/**
+ * @ingroup iface_xdg_surface
+ * edge values for resizing
+ *
+ * These values are used to indicate which edge of a surface
+ * is being dragged in a resize operation.
+ */
+enum xdg_surface_resize_edge {
+ XDG_SURFACE_RESIZE_EDGE_NONE = 0,
+ XDG_SURFACE_RESIZE_EDGE_TOP = 1,
+ XDG_SURFACE_RESIZE_EDGE_BOTTOM = 2,
+ XDG_SURFACE_RESIZE_EDGE_LEFT = 4,
+ XDG_SURFACE_RESIZE_EDGE_TOP_LEFT = 5,
+ XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT = 6,
+ XDG_SURFACE_RESIZE_EDGE_RIGHT = 8,
+ XDG_SURFACE_RESIZE_EDGE_TOP_RIGHT = 9,
+ XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT = 10,
+};
+#endif /* XDG_SURFACE_RESIZE_EDGE_ENUM */
+
+#ifndef XDG_SURFACE_STATE_ENUM
+#define XDG_SURFACE_STATE_ENUM
+/**
+ * @ingroup iface_xdg_surface
+ * types of state on the surface
+ *
+ * The different state values used on the surface. This is designed for
+ * state values like maximized, fullscreen. It is paired with the
+ * configure event to ensure that both the client and the compositor
+ * setting the state can be synchronized.
+ *
+ * States set in this way are double-buffered. They will get applied on
+ * the next commit.
+ *
+ * Desktop environments may extend this enum by taking up a range of
+ * values and documenting the range they chose in this description.
+ * They are not required to document the values for the range that they
+ * chose. Ideally, any good extensions from a desktop environment should
+ * make its way into standardization into this enum.
+ *
+ * The current reserved ranges are:
+ *
+ * 0x0000 - 0x0FFF: xdg-shell core values, documented below.
+ * 0x1000 - 0x1FFF: GNOME
+ */
+enum xdg_surface_state {
+ /**
+ * the surface is maximized
+ */
+ XDG_SURFACE_STATE_MAXIMIZED = 1,
+ /**
+ * the surface is fullscreen
+ */
+ XDG_SURFACE_STATE_FULLSCREEN = 2,
+ XDG_SURFACE_STATE_RESIZING = 3,
+ XDG_SURFACE_STATE_ACTIVATED = 4,
+};
+#endif /* XDG_SURFACE_STATE_ENUM */
+
+/**
+ * @ingroup iface_xdg_surface
+ * @struct xdg_surface_v5_interface
+ */
+struct xdg_surface_v5_interface {
+ /**
+ * Destroy the xdg_surface
+ *
+ * Unmap and destroy the window. The window will be effectively
+ * hidden from the user's point of view, and all state like
+ * maximization, fullscreen, and so on, will be lost.
+ */
+ void (*destroy)(struct wl_client *client,
+ struct wl_resource *resource);
+ /**
+ * set the parent of this surface
+ *
+ * Set the "parent" of this surface. This window should be
+ * stacked above a parent. The parent surface must be mapped as
+ * long as this surface is mapped.
+ *
+ * Parent windows should be set on dialogs, toolboxes, or other
+ * "auxiliary" surfaces, so that the parent is raised when the
+ * dialog is raised.
+ */
+ void (*set_parent)(struct wl_client *client,
+ struct wl_resource *resource,
+ struct wl_resource *parent);
+ /**
+ * set surface title
+ *
+ * Set a short title for the surface.
+ *
+ * This string may be used to identify the surface in a task bar,
+ * window list, or other user interface elements provided by the
+ * compositor.
+ *
+ * The string must be encoded in UTF-8.
+ */
+ void (*set_title)(struct wl_client *client,
+ struct wl_resource *resource,
+ const char *title);
+ /**
+ * set application ID
+ *
+ * Set an application identifier for the surface.
+ *
+ * The app ID identifies the general class of applications to which
+ * the surface belongs. The compositor can use this to group
+ * multiple surfaces together, or to determine how to launch a new
+ * application.
+ *
+ * For D-Bus activatable applications, the app ID is used as the
+ * D-Bus service name.
+ *
+ * The compositor shell will try to group application surfaces
+ * together by their app ID. As a best practice, it is suggested to
+ * select app ID's that match the basename of the application's
+ * .desktop file. For example, "org.freedesktop.FooViewer" where
+ * the .desktop file is "org.freedesktop.FooViewer.desktop".
+ *
+ * See the desktop-entry specification [0] for more details on
+ * application identifiers and how they relate to well-known D-Bus
+ * names and .desktop files.
+ *
+ * [0] http://standards.freedesktop.org/desktop-entry-spec/
+ */
+ void (*set_app_id)(struct wl_client *client,
+ struct wl_resource *resource,
+ const char *app_id);
+ /**
+ * show the window menu
+ *
+ * Clients implementing client-side decorations might want to
+ * show a context menu when right-clicking on the decorations,
+ * giving the user a menu that they can use to maximize or minimize
+ * the window.
+ *
+ * This request asks the compositor to pop up such a window menu at
+ * the given position, relative to the local surface coordinates of
+ * the parent surface. There are no guarantees as to what menu
+ * items the window menu contains.
+ *
+ * This request must be used in response to some sort of user
+ * action like a button press, key press, or touch down event.
+ * @param seat the wl_seat of the user event
+ * @param serial the serial of the user event
+ * @param x the x position to pop up the window menu at
+ * @param y the y position to pop up the window menu at
+ */
+ void (*show_window_menu)(struct wl_client *client,
+ struct wl_resource *resource,
+ struct wl_resource *seat,
+ uint32_t serial,
+ int32_t x,
+ int32_t y);
+ /**
+ * start an interactive move
+ *
+ * Start an interactive, user-driven move of the surface.
+ *
+ * This request must be used in response to some sort of user
+ * action like a button press, key press, or touch down event. The
+ * passed serial is used to determine the type of interactive move
+ * (touch, pointer, etc).
+ *
+ * The server may ignore move requests depending on the state of
+ * the surface (e.g. fullscreen or maximized), or if the passed
+ * serial is no longer valid.
+ *
+ * If triggered, the surface will lose the focus of the device
+ * (wl_pointer, wl_touch, etc) used for the move. It is up to the
+ * compositor to visually indicate that the move is taking place,
+ * such as updating a pointer cursor, during the move. There is no
+ * guarantee that the device focus will return when the move is
+ * completed.
+ * @param seat the wl_seat of the user event
+ * @param serial the serial of the user event
+ */
+ void (*move)(struct wl_client *client,
+ struct wl_resource *resource,
+ struct wl_resource *seat,
+ uint32_t serial);
+ /**
+ * start an interactive resize
+ *
+ * Start a user-driven, interactive resize of the surface.
+ *
+ * This request must be used in response to some sort of user
+ * action like a button press, key press, or touch down event. The
+ * passed serial is used to determine the type of interactive
+ * resize (touch, pointer, etc).
+ *
+ * The server may ignore resize requests depending on the state of
+ * the surface (e.g. fullscreen or maximized).
+ *
+ * If triggered, the client will receive configure events with the
+ * "resize" state enum value and the expected sizes. See the
+ * "resize" enum value for more details about what is required. The
+ * client must also acknowledge configure events using
+ * "ack_configure". After the resize is completed, the client will
+ * receive another "configure" event without the resize state.
+ *
+ * If triggered, the surface also will lose the focus of the device
+ * (wl_pointer, wl_touch, etc) used for the resize. It is up to the
+ * compositor to visually indicate that the resize is taking place,
+ * such as updating a pointer cursor, during the resize. There is
+ * no guarantee that the device focus will return when the resize
+ * is completed.
+ *
+ * The edges parameter specifies how the surface should be resized,
+ * and is one of the values of the resize_edge enum. The compositor
+ * may use this information to update the surface position for
+ * example when dragging the top left corner. The compositor may
+ * also use this information to adapt its behavior, e.g. choose an
+ * appropriate cursor image.
+ * @param seat the wl_seat of the user event
+ * @param serial the serial of the user event
+ * @param edges which edge or corner is being dragged
+ */
+ void (*resize)(struct wl_client *client,
+ struct wl_resource *resource,
+ struct wl_resource *seat,
+ uint32_t serial,
+ uint32_t edges);
+ /**
+ * ack a configure event
+ *
+ * When a configure event is received, if a client commits the
+ * surface in response to the configure event, then the client must
+ * make a ack_configure request before the commit request, passing
+ * along the serial of the configure event.
+ *
+ * For instance, the compositor might use this information to move
+ * a surface to the top left only when the client has drawn itself
+ * for the maximized or fullscreen state.
+ *
+ * If the client receives multiple configure events before it can
+ * respond to one, it only has to ack the last configure event.
+ * @param serial the serial from the configure event
+ */
+ void (*ack_configure)(struct wl_client *client,
+ struct wl_resource *resource,
+ uint32_t serial);
+ /**
+ * set the new window geometry
+ *
+ * The window geometry of a window is its "visible bounds" from
+ * the user's perspective. Client-side decorations often have
+ * invisible portions like drop-shadows which should be ignored for
+ * the purposes of aligning, placing and constraining windows.
+ *
+ * The window geometry is double buffered, and will be applied at
+ * the time wl_surface.commit of the corresponding wl_surface is
+ * called.
+ *
+ * Once the window geometry of the surface is set once, it is not
+ * possible to unset it, and it will remain the same until
+ * set_window_geometry is called again, even if a new subsurface or
+ * buffer is attached.
+ *
+ * If never set, the value is the full bounds of the surface,
+ * including any subsurfaces. This updates dynamically on every
+ * commit. This unset mode is meant for extremely simple clients.
+ *
+ * If responding to a configure event, the window geometry in here
+ * must respect the sizing negotiations specified by the states in
+ * the configure event.
+ *
+ * The arguments are given in the surface local coordinate space of
+ * the wl_surface associated with this xdg_surface.
+ *
+ * The width and height must be greater than zero.
+ */
+ void (*set_window_geometry)(struct wl_client *client,
+ struct wl_resource *resource,
+ int32_t x,
+ int32_t y,
+ int32_t width,
+ int32_t height);
+ /**
+ * maximize the window
+ *
+ * Maximize the surface.
+ *
+ * After requesting that the surface should be maximized, the
+ * compositor will respond by emitting a configure event with the
+ * "maximized" state and the required window geometry. The client
+ * should then update its content, drawing it in a maximized state,
+ * i.e. without shadow or other decoration outside of the window
+ * geometry. The client must also acknowledge the configure when
+ * committing the new content (see ack_configure).
+ *
+ * It is up to the compositor to decide how and where to maximize
+ * the surface, for example which output and what region of the
+ * screen should be used.
+ *
+ * If the surface was already maximized, the compositor will still
+ * emit a configure event with the "maximized" state.
+ */
+ void (*set_maximized)(struct wl_client *client,
+ struct wl_resource *resource);
+ /**
+ * unmaximize the window
+ *
+ * Unmaximize the surface.
+ *
+ * After requesting that the surface should be unmaximized, the
+ * compositor will respond by emitting a configure event without
+ * the "maximized" state. If available, the compositor will include
+ * the window geometry dimensions the window had prior to being
+ * maximized in the configure request. The client must then update
+ * its content, drawing it in a regular state, i.e. potentially
+ * with shadow, etc. The client must also acknowledge the configure
+ * when committing the new content (see ack_configure).
+ *
+ * It is up to the compositor to position the surface after it was
+ * unmaximized; usually the position the surface had before
+ * maximizing, if applicable.
+ *
+ * If the surface was already not maximized, the compositor will
+ * still emit a configure event without the "maximized" state.
+ */
+ void (*unset_maximized)(struct wl_client *client,
+ struct wl_resource *resource);
+ /**
+ * set the window as fullscreen on a monitor
+ *
+ * Make the surface fullscreen.
+ *
+ * You can specify an output that you would prefer to be
+ * fullscreen. If this value is NULL, it's up to the compositor to
+ * choose which display will be used to map this surface.
+ *
+ * If the surface doesn't cover the whole output, the compositor
+ * will position the surface in the center of the output and
+ * compensate with black borders filling the rest of the output.
+ */
+ void (*set_fullscreen)(struct wl_client *client,
+ struct wl_resource *resource,
+ struct wl_resource *output);
+ /**
+ */
+ void (*unset_fullscreen)(struct wl_client *client,
+ struct wl_resource *resource);
+ /**
+ * set the window as minimized
+ *
+ * Request that the compositor minimize your surface. There is no
+ * way to know if the surface is currently minimized, nor is there
+ * any way to unset minimization on this surface.
+ *
+ * If you are looking to throttle redrawing when minimized, please
+ * instead use the wl_surface.frame event for this, as this will
+ * also work with live previews on windows in Alt-Tab, Expose or
+ * similar compositor features.
+ */
+ void (*set_minimized)(struct wl_client *client,
+ struct wl_resource *resource);
+};
+
+#define XDG_SURFACE_CONFIGURE 0
+#define XDG_SURFACE_CLOSE 1
+
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_CONFIGURE_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_CLOSE_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_DESTROY_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SET_PARENT_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SET_TITLE_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SET_APP_ID_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SHOW_WINDOW_MENU_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_MOVE_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_RESIZE_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_ACK_CONFIGURE_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SET_WINDOW_GEOMETRY_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SET_MAXIMIZED_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_UNSET_MAXIMIZED_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SET_FULLSCREEN_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_UNSET_FULLSCREEN_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SET_MINIMIZED_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_xdg_surface
+ * Sends an configure event to the client owning the resource.
+ * @param resource_ The client's resource
+ */
+static inline void
+xdg_surface_send_configure(struct wl_resource *resource_, int32_t width, int32_t height, struct wl_array *states, uint32_t serial)
+{
+ wl_resource_post_event(resource_, XDG_SURFACE_CONFIGURE, width, height, states, serial);
+}
+
+/**
+ * @ingroup iface_xdg_surface
+ * Sends an close event to the client owning the resource.
+ * @param resource_ The client's resource
+ */
+static inline void
+xdg_surface_send_close(struct wl_resource *resource_)
+{
+ wl_resource_post_event(resource_, XDG_SURFACE_CLOSE);
+}
+
+/**
+ * @ingroup iface_xdg_popup
+ * @struct xdg_popup_v5_interface
+ */
+struct xdg_popup_v5_interface {
+ /**
+ * remove xdg_popup interface
+ *
+ * This destroys the popup. Explicitly destroying the xdg_popup
+ * object will also dismiss the popup, and unmap the surface.
+ *
+ * If this xdg_popup is not the "topmost" popup, a protocol error
+ * will be sent.
+ */
+ void (*destroy)(struct wl_client *client,
+ struct wl_resource *resource);
+};
+
+#define XDG_POPUP_POPUP_DONE 0
+
+/**
+ * @ingroup iface_xdg_popup
+ */
+#define XDG_POPUP_POPUP_DONE_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_xdg_popup
+ */
+#define XDG_POPUP_DESTROY_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_xdg_popup
+ * Sends an popup_done event to the client owning the resource.
+ * @param resource_ The client's resource
+ */
+static inline void
+xdg_popup_send_popup_done(struct wl_resource *resource_)
+{
+ wl_resource_post_event(resource_, XDG_POPUP_POPUP_DONE);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/compositor/extensions/pregenerated/xdg-shell-v5.pri b/src/compositor/extensions/pregenerated/xdg-shell-v5.pri
new file mode 100644
index 000000000..48d163f17
--- /dev/null
+++ b/src/compositor/extensions/pregenerated/xdg-shell-v5.pri
@@ -0,0 +1,10 @@
+# Putting pregenerated files in a 3rdparty directory to avoid
+# qtqa's license checking failing.
+
+HEADERS += \
+ $$PWD/3rdparty/qwayland-server-xdg-shell-unstable-v5_p.h \
+ $$PWD/3rdparty/wayland-xdg-shell-unstable-v5-server-protocol_p.h
+
+SOURCES += \
+ $$PWD/3rdparty/qwayland-server-xdg-shell-unstable-v5.cpp \
+ $$PWD/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c
diff --git a/src/compositor/extensions/qwaylandivisurface.h b/src/compositor/extensions/qwaylandivisurface.h
index ce5001d1a..65d5bbc86 100644
--- a/src/compositor/extensions/qwaylandivisurface.h
+++ b/src/compositor/extensions/qwaylandivisurface.h
@@ -41,6 +41,7 @@
#define QWAYLANDIVISURFACE_H
#include <QtWaylandCompositor/QWaylandShellSurface>
+#include <QtWaylandCompositor/qwaylandquickchildren.h>
struct wl_resource;
@@ -56,6 +57,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandIviSurface : public QWaylandShellSurfa
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandIviSurface)
+ Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandIviSurface)
Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged)
Q_PROPERTY(uint iviId READ iviId NOTIFY iviIdChanged)
diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp
index 6b8845797..84e9c356d 100644
--- a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp
+++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp
@@ -45,6 +45,21 @@
QT_BEGIN_NAMESPACE
+QWaylandQuickShellSurfaceItem *QWaylandQuickShellSurfaceItemPrivate::maybeCreateAutoPopup(QWaylandShellSurface* shellSurface)
+{
+ if (!m_autoCreatePopupItems)
+ return nullptr;
+
+ Q_Q(QWaylandQuickShellSurfaceItem);
+ auto *popupItem = new QWaylandQuickShellSurfaceItem(q);
+ popupItem->setShellSurface(shellSurface);
+ popupItem->setAutoCreatePopupItems(true);
+ QObject::connect(popupItem, &QWaylandQuickShellSurfaceItem::surfaceDestroyed, [popupItem](){
+ popupItem->deleteLater();
+ });
+ return popupItem;
+}
+
/*!
* \qmltype ShellSurfaceItem
* \inherits WaylandQuickItem
@@ -163,6 +178,36 @@ void QWaylandQuickShellSurfaceItem::setMoveItem(QQuickItem *moveItem)
moveItemChanged();
}
+/*!
+ * \qmlproperty bool QtWaylandCompositor::ShellSurfaceItem::autoCreatePopupItems
+ *
+ * This property holds whether ShellSurfaceItems for popups parented to the shell
+ * surface managed by this item should automatically be created.
+ */
+
+/*!
+ * \property QWaylandQuickShellSurfaceItem::autoCreatePopupItems
+ *
+ * This property holds whether QWaylandQuickShellSurfaceItems for popups
+ * parented to the shell surface managed by this item should automatically be created.
+ */
+bool QWaylandQuickShellSurfaceItem::autoCreatePopupItems()
+{
+ Q_D(const QWaylandQuickShellSurfaceItem);
+ return d->m_autoCreatePopupItems;
+}
+
+void QWaylandQuickShellSurfaceItem::setAutoCreatePopupItems(bool enabled)
+{
+ Q_D(QWaylandQuickShellSurfaceItem);
+
+ if (enabled == d->m_autoCreatePopupItems)
+ return;
+
+ d->m_autoCreatePopupItems = enabled;
+ emit autoCreatePopupItemsChanged();
+}
+
void QWaylandQuickShellSurfaceItem::mouseMoveEvent(QMouseEvent *event)
{
Q_D(QWaylandQuickShellSurfaceItem);
diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.h b/src/compositor/extensions/qwaylandquickshellsurfaceitem.h
index e2c823651..d14fa3fce 100644
--- a/src/compositor/extensions/qwaylandquickshellsurfaceitem.h
+++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.h
@@ -54,6 +54,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellSurfaceItem : public QWaylan
Q_DECLARE_PRIVATE(QWaylandQuickShellSurfaceItem)
Q_PROPERTY(QWaylandShellSurface *shellSurface READ shellSurface WRITE setShellSurface NOTIFY shellSurfaceChanged)
Q_PROPERTY(QQuickItem *moveItem READ moveItem WRITE setMoveItem NOTIFY moveItemChanged)
+ Q_PROPERTY(bool autoCreatePopupItems READ autoCreatePopupItems WRITE setAutoCreatePopupItems NOTIFY autoCreatePopupItemsChanged)
public:
QWaylandQuickShellSurfaceItem(QQuickItem *parent = nullptr);
~QWaylandQuickShellSurfaceItem() override;
@@ -64,9 +65,13 @@ public:
QQuickItem *moveItem() const;
void setMoveItem(QQuickItem *moveItem);
+ bool autoCreatePopupItems();
+ void setAutoCreatePopupItems(bool enabled);
+
Q_SIGNALS:
void shellSurfaceChanged();
void moveItemChanged();
+ void autoCreatePopupItemsChanged();
protected:
QWaylandQuickShellSurfaceItem(QWaylandQuickShellSurfaceItemPrivate &dd, QQuickItem *parent);
diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h b/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h
index abb56221e..7a458381e 100644
--- a/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h
+++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h
@@ -40,6 +40,7 @@
#ifndef QWAYLANDQUICKSHELLSURFACEITEM_P_H
#define QWAYLANDQUICKSHELLSURFACEITEM_P_H
+#include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem>
#include <QtWaylandCompositor/private/qwaylandquickitem_p.h>
#include <QtCore/QBasicTimer>
@@ -60,15 +61,20 @@ QT_BEGIN_NAMESPACE
class QWaylandQuickShellIntegration;
class QWaylandShellSurface;
+class QWaylandQuickShellSurfaceItem;
class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellSurfaceItemPrivate : public QWaylandQuickItemPrivate
{
+ Q_DECLARE_PUBLIC(QWaylandQuickShellSurfaceItem)
public:
- QWaylandQuickShellSurfaceItemPrivate()
- {}
+ QWaylandQuickShellSurfaceItemPrivate() {}
+ QWaylandQuickShellSurfaceItem *maybeCreateAutoPopup(QWaylandShellSurface* shellSurface);
+ static QWaylandQuickShellSurfaceItemPrivate *get(QWaylandQuickShellSurfaceItem *item) { return item->d_func(); }
+
QWaylandQuickShellIntegration *m_shellIntegration = nullptr;
QWaylandShellSurface *m_shellSurface = nullptr;
QQuickItem *m_moveItem = nullptr;
+ bool m_autoCreatePopupItems = false;
};
class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellIntegration : public QObject
diff --git a/src/compositor/extensions/qwaylandwlshell.h b/src/compositor/extensions/qwaylandwlshell.h
index 4923b4fb0..421888000 100644
--- a/src/compositor/extensions/qwaylandwlshell.h
+++ b/src/compositor/extensions/qwaylandwlshell.h
@@ -44,6 +44,7 @@
#include <QtWaylandCompositor/QWaylandResource>
#include <QtWaylandCompositor/QWaylandShell>
#include <QtWaylandCompositor/QWaylandShellSurface>
+#include <QtWaylandCompositor/qwaylandquickchildren.h>
#include <QtCore/QSize>
@@ -87,6 +88,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShellSurface : public QWaylandShellS
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandWlShellSurface)
+ Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandWlShellSurface)
Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged)
Q_PROPERTY(QWaylandWlShell *shell READ shell NOTIFY shellChanged)
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
diff --git a/src/compositor/extensions/qwaylandwlshellintegration.cpp b/src/compositor/extensions/qwaylandwlshellintegration.cpp
index 9e1e9dd6d..896b1587d 100644
--- a/src/compositor/extensions/qwaylandwlshellintegration.cpp
+++ b/src/compositor/extensions/qwaylandwlshellintegration.cpp
@@ -99,6 +99,12 @@ void WlShellIntegration::handleSetDefaultTopLevel()
// so we need to unset the flags here but we save the previous state and move
// to the initial position when redrawing
nextState = State::Windowed;
+
+ // Any handlers for making maximized or fullscreen state track the size of
+ // the designated output, are unneeded now that we're going to windowed
+ // state.
+ nonwindowedState.output = nullptr;
+ disconnect(nonwindowedState.sizeChangedConnection);
}
void WlShellIntegration::handleSetTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, bool inactive)
@@ -129,8 +135,23 @@ void WlShellIntegration::handleSetMaximized(QWaylandOutput *output)
nextState = State::Maximized;
finalPosition = designatedOutput->position() + designatedOutput->availableGeometry().topLeft();
- auto scaleFactor = m_item->view()->output()->scaleFactor();
- m_shellSurface->sendConfigure(designatedOutput->availableGeometry().size() / scaleFactor, QWaylandWlShellSurface::NoneEdge);
+ // Any prior output-resize handlers are irrelevant at this point
+ disconnect(nonwindowedState.sizeChangedConnection);
+ nonwindowedState.output = designatedOutput;
+ nonwindowedState.sizeChangedConnection = connect(designatedOutput, &QWaylandOutput::availableGeometryChanged, this, &WlShellIntegration::handleMaximizedSizeChanged);
+ handleMaximizedSizeChanged();
+}
+
+void WlShellIntegration::handleMaximizedSizeChanged()
+{
+ if (!m_shellSurface)
+ return;
+
+ if (nextState == State::Maximized) {
+ QWaylandOutput *designatedOutput = nonwindowedState.output;
+ auto scaleFactor = designatedOutput->scaleFactor();
+ m_shellSurface->sendConfigure(designatedOutput->availableGeometry().size() / scaleFactor, QWaylandWlShellSurface::NoneEdge);
+ }
}
void WlShellIntegration::handleSetFullScreen(QWaylandWlShellSurface::FullScreenMethod method, uint framerate, QWaylandOutput *output)
@@ -154,7 +175,22 @@ void WlShellIntegration::handleSetFullScreen(QWaylandWlShellSurface::FullScreenM
nextState = State::FullScreen;
finalPosition = designatedOutput->position();
- m_shellSurface->sendConfigure(designatedOutput->geometry().size(), QWaylandWlShellSurface::NoneEdge);
+ // Any prior output-resize handlers are irrelevant at this point
+ disconnect(nonwindowedState.sizeChangedConnection);
+ nonwindowedState.output = designatedOutput;
+ nonwindowedState.sizeChangedConnection = connect(designatedOutput, &QWaylandOutput::geometryChanged, this, &WlShellIntegration::handleFullScreenSizeChanged);
+ handleFullScreenSizeChanged();
+}
+
+void WlShellIntegration::handleFullScreenSizeChanged()
+{
+ if (!m_shellSurface)
+ return;
+
+ if (nextState == State::FullScreen) {
+ QWaylandOutput *designatedOutput = nonwindowedState.output;
+ m_shellSurface->sendConfigure(designatedOutput->geometry().size(), QWaylandWlShellSurface::NoneEdge);
+ }
}
void WlShellIntegration::handleSetPopup(QWaylandSeat *seat, QWaylandSurface *parent, const QPoint &relativeToParent)
@@ -221,6 +257,11 @@ void WlShellIntegration::handleShellSurfaceDestroyed()
{
if (isPopup)
handlePopupRemoved();
+
+ // Disarm any handlers that might fire and attempt to use the now-stale pointer
+ nonwindowedState.output = nullptr;
+ disconnect(nonwindowedState.sizeChangedConnection);
+
m_shellSurface = nullptr;
}
diff --git a/src/compositor/extensions/qwaylandwlshellintegration_p.h b/src/compositor/extensions/qwaylandwlshellintegration_p.h
index 68c936b1e..ff236e636 100644
--- a/src/compositor/extensions/qwaylandwlshellintegration_p.h
+++ b/src/compositor/extensions/qwaylandwlshellintegration_p.h
@@ -80,6 +80,8 @@ private Q_SLOTS:
void handleSurfaceHasContentChanged();
void handleRedraw();
void adjustOffsetForNextFrame(const QPointF &offset);
+ void handleFullScreenSizeChanged();
+ void handleMaximizedSizeChanged();
private:
enum class GrabberState {
@@ -118,6 +120,14 @@ private:
State currentState = State::Windowed;
State nextState = State::Windowed;
+
+ struct {
+ QWaylandOutput *output = nullptr;
+ QMetaObject::Connection sizeChangedConnection; // Depending on whether maximized or fullscreen,
+ // will be hooked to geometry-changed or available-
+ // geometry-changed.
+ } nonwindowedState;
+
QPointF normalPosition;
QPointF finalPosition;
};
diff --git a/src/compositor/extensions/qwaylandxdgdecorationv1.cpp b/src/compositor/extensions/qwaylandxdgdecorationv1.cpp
new file mode 100644
index 000000000..1abd5e3fc
--- /dev/null
+++ b/src/compositor/extensions/qwaylandxdgdecorationv1.cpp
@@ -0,0 +1,260 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgdecorationv1_p.h"
+
+#include <QtWaylandCompositor/QWaylandXdgToplevel>
+#include <QtWaylandCompositor/private/qwaylandxdgshell_p.h>
+
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include <QtCore/QObject>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype XdgDecorationManagerV1
+ \inqmlmodule QtWayland.Compositor
+ \since 5.12
+ \brief Provides an extension for negotiation of server-side and client-side window decorations
+
+ The XdgDecorationManagerV1 extension provides a way for a compositor to announce support for
+ server-side window decorations, and for xdg-shell clients to communicate whether they prefer
+ client-side or server-side decorations.
+
+ XdgDecorationManagerV1 corresponds to the Wayland interface, \c zxdg_decoration_manager_v1.
+
+ To provide the functionality of the extension in a compositor, create an instance of the
+ XdgDecorationManagerV1 component and add it to the list of extensions supported by the compositor:
+
+ \code
+ import QtWayland.Compositor 1.3
+
+ WaylandCompositor {
+ // Xdg decoration manager assumes xdg-shell is being used
+ XdgShell {
+ onToplevelCreated: // ...
+ }
+ XdgDecorationManagerV1 {
+ // Provide a hint to clients that support the extension they should use server-side
+ // decorations.
+ preferredMode: XdgToplevel.ServerSideDecoration
+ }
+ }
+ \endcode
+
+ \sa XdgToplevel::decorationMode
+*/
+
+/*!
+ \class QWaylandXdgDecorationManagerV1
+ \inmodule QtWaylandCompositor
+ \since 5.12
+ \brief Provides an extension for negotiation of server-side and client-side window decorations
+
+ The QWaylandXdgDecorationManagerV1 extension provides a way for a compositor to announce support
+ for server-side window decorations, and for xdg-shell clients to communicate whether they prefer
+ client-side or server-side decorations.
+
+ QWaylandXdgDecorationManagerV1 corresponds to the Wayland interface, \c zxdg_decoration_manager_v1.
+
+ \sa QWaylandXdgToplevel::decorationMode
+*/
+
+/*!
+ Constructs a QWaylandXdgDecorationManagerV1 object.
+*/
+QWaylandXdgDecorationManagerV1::QWaylandXdgDecorationManagerV1()
+ : QWaylandCompositorExtensionTemplate<QWaylandXdgDecorationManagerV1>(*new QWaylandXdgDecorationManagerV1Private)
+{
+}
+
+/*!
+ Initializes the extension.
+*/
+void QWaylandXdgDecorationManagerV1::initialize()
+{
+ Q_D(QWaylandXdgDecorationManagerV1);
+
+ QWaylandCompositorExtensionTemplate::initialize();
+ QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
+ if (!compositor) {
+ qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandXdgDecorationV1";
+ return;
+ }
+ d->init(compositor->display(), 1);
+}
+
+/*!
+ \qmlproperty string QtWaylandCompositor::XdgDecorationManagerV1::preferredMode
+
+ This property holds the decoration mode the compositor prefers.
+
+ This is the mode used for clients that don't indicate a preference for server-side or
+ client-side decorations.
+*/
+/*!
+ \property QWaylandXdgDecorationManagerV1::preferredMode
+
+ This property holds the decoration mode the compositor prefers.
+
+ This is the mode used for clients that don't indicate a preference for server-side or
+ client-side decorations.
+*/
+QWaylandXdgToplevel::DecorationMode QWaylandXdgDecorationManagerV1::preferredMode() const
+{
+ Q_D(const QWaylandXdgDecorationManagerV1);
+ return d->m_preferredMode;
+}
+
+void QWaylandXdgDecorationManagerV1::setPreferredMode(QWaylandXdgToplevel::DecorationMode preferredMode)
+{
+ Q_D(QWaylandXdgDecorationManagerV1);
+ if (d->m_preferredMode == preferredMode)
+ return;
+
+ d->m_preferredMode = preferredMode;
+ emit preferredModeChanged();
+}
+
+/*!
+ Returns the Wayland interface for the QWaylandXdgDecorationManagerV1.
+*/
+const wl_interface *QWaylandXdgDecorationManagerV1::interface()
+{
+ return QWaylandXdgDecorationManagerV1Private::interface();
+}
+
+void QWaylandXdgDecorationManagerV1Private::zxdg_decoration_manager_v1_get_toplevel_decoration(
+ Resource *resource, uint id, wl_resource *toplevelResource)
+{
+ Q_Q(QWaylandXdgDecorationManagerV1);
+
+ auto *toplevel = QWaylandXdgToplevel::fromResource(toplevelResource);
+ if (!toplevel) {
+ qWarning() << "Couldn't find toplevel for decoration";
+ return;
+ }
+
+ //TODO: verify that the xdg surface is unconfigured, and post protocol error/warning
+
+ auto *toplevelPrivate = QWaylandXdgToplevelPrivate::get(toplevel);
+
+ if (toplevelPrivate->m_decoration) {
+ qWarning() << "zxdg_decoration_manager_v1.get_toplevel_decoration:"
+ << toplevel << "already has a decoration object, ignoring";
+ //TODO: protocol error as well?
+ return;
+ }
+
+ new QWaylandXdgToplevelDecorationV1(toplevel, q, resource->client(), id);
+}
+
+QWaylandXdgToplevelDecorationV1::QWaylandXdgToplevelDecorationV1(QWaylandXdgToplevel *toplevel,
+ QWaylandXdgDecorationManagerV1 *manager,
+ wl_client *client, int id)
+ : QtWaylandServer::zxdg_toplevel_decoration_v1(client, id, /*version*/ 1)
+ , m_toplevel(toplevel)
+ , m_manager(manager)
+{
+ Q_ASSERT(toplevel);
+ auto *toplevelPrivate = QWaylandXdgToplevelPrivate::get(toplevel);
+ Q_ASSERT(!toplevelPrivate->m_decoration);
+ toplevelPrivate->m_decoration = this;
+ sendConfigure(manager->preferredMode());
+}
+
+QWaylandXdgToplevelDecorationV1::~QWaylandXdgToplevelDecorationV1()
+{
+ QWaylandXdgToplevelPrivate::get(m_toplevel)->m_decoration = nullptr;
+}
+
+void QWaylandXdgToplevelDecorationV1::sendConfigure(QWaylandXdgToplevelDecorationV1::DecorationMode mode)
+{
+ if (configuredMode() == mode)
+ return;
+
+ switch (mode) {
+ case DecorationMode::ClientSideDecoration:
+ send_configure(mode_client_side);
+ break;
+ case DecorationMode::ServerSideDecoration:
+ send_configure(mode_server_side);
+ break;
+ default:
+ qWarning() << "Illegal mode in QWaylandXdgToplevelDecorationV1::sendConfigure" << mode;
+ break;
+ }
+
+ m_configuredMode = mode;
+ emit m_toplevel->decorationModeChanged();
+}
+
+void QWaylandXdgToplevelDecorationV1::zxdg_toplevel_decoration_v1_destroy_resource(Resource *resource)
+{
+ Q_UNUSED(resource);
+ delete this;
+}
+
+void QWaylandXdgToplevelDecorationV1::zxdg_toplevel_decoration_v1_destroy(Resource *resource)
+{
+ wl_resource_destroy(resource->handle);
+}
+
+void QWaylandXdgToplevelDecorationV1::zxdg_toplevel_decoration_v1_set_mode(Resource *resource, uint32_t mode)
+{
+ Q_UNUSED(resource);
+ m_clientPreferredMode = mode;
+ handleClientPreferredModeChanged();
+}
+
+void QWaylandXdgToplevelDecorationV1::zxdg_toplevel_decoration_v1_unset_mode(Resource *resource)
+{
+ Q_UNUSED(resource);
+ m_clientPreferredMode = 0;
+ handleClientPreferredModeChanged();
+}
+
+void QWaylandXdgToplevelDecorationV1::handleClientPreferredModeChanged()
+{
+ if (m_clientPreferredMode != m_configuredMode) {
+ if (m_clientPreferredMode == 0)
+ sendConfigure(m_manager->preferredMode());
+ else
+ sendConfigure(DecorationMode(m_clientPreferredMode));
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwaylandxdgdecorationv1.h b/src/compositor/extensions/qwaylandxdgdecorationv1.h
new file mode 100644
index 000000000..4390716e8
--- /dev/null
+++ b/src/compositor/extensions/qwaylandxdgdecorationv1.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXDGDECORATIONV1_H
+#define QWAYLANDXDGDECORATIONV1_H
+
+#include <QtWaylandCompositor/QWaylandCompositorExtension>
+#include <QtWaylandCompositor/QWaylandXdgToplevel>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandXdgDecorationManagerV1Private;
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgDecorationManagerV1 : public QWaylandCompositorExtensionTemplate<QWaylandXdgDecorationManagerV1>
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandXdgDecorationManagerV1)
+ Q_PROPERTY(QWaylandXdgToplevel::DecorationMode preferredMode READ preferredMode WRITE setPreferredMode NOTIFY preferredModeChanged)
+
+public:
+ explicit QWaylandXdgDecorationManagerV1();
+
+ void initialize() override;
+
+ QWaylandXdgToplevel::DecorationMode preferredMode() const;
+ void setPreferredMode(QWaylandXdgToplevel::DecorationMode preferredMode);
+
+ static const struct wl_interface *interface();
+
+Q_SIGNALS:
+ void preferredModeChanged();
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXDGDECORATIONV1_H
diff --git a/src/compositor/extensions/qwaylandxdgdecorationv1_p.h b/src/compositor/extensions/qwaylandxdgdecorationv1_p.h
new file mode 100644
index 000000000..fdd555abb
--- /dev/null
+++ b/src/compositor/extensions/qwaylandxdgdecorationv1_p.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXDGDECORATIONV1_P_H
+#define QWAYLANDXDGDECORATIONV1_P_H
+
+#include "qwaylandxdgdecorationv1.h"
+
+#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h>
+#include <QtWaylandCompositor/private/qwayland-server-xdg-decoration-unstable-v1.h>
+
+#include <QtWaylandCompositor/QWaylandXdgToplevel>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandXdgToplevel;
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgDecorationManagerV1Private
+ : public QWaylandCompositorExtensionPrivate
+ , public QtWaylandServer::zxdg_decoration_manager_v1
+{
+ Q_DECLARE_PUBLIC(QWaylandXdgDecorationManagerV1)
+public:
+ using DecorationMode = QWaylandXdgToplevel::DecorationMode;
+ explicit QWaylandXdgDecorationManagerV1Private() {}
+
+protected:
+ void zxdg_decoration_manager_v1_get_toplevel_decoration(Resource *resource, uint id, ::wl_resource *toplevelResource) override;
+
+private:
+ DecorationMode m_preferredMode = DecorationMode::ClientSideDecoration;
+};
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevelDecorationV1
+ : public QtWaylandServer::zxdg_toplevel_decoration_v1
+{
+public:
+ using DecorationMode = QWaylandXdgToplevel::DecorationMode;
+ explicit QWaylandXdgToplevelDecorationV1(QWaylandXdgToplevel *toplevel,
+ QWaylandXdgDecorationManagerV1 *manager,
+ wl_client *client, int id);
+ ~QWaylandXdgToplevelDecorationV1() override;
+
+ DecorationMode configuredMode() const { return DecorationMode(m_configuredMode); }
+ void sendConfigure(DecorationMode mode);
+
+protected:
+ void zxdg_toplevel_decoration_v1_destroy_resource(Resource *resource) override;
+ void zxdg_toplevel_decoration_v1_destroy(Resource *resource) override;
+ void zxdg_toplevel_decoration_v1_set_mode(Resource *resource, uint32_t mode) override;
+ void zxdg_toplevel_decoration_v1_unset_mode(Resource *resource) override;
+
+private:
+ void handleClientPreferredModeChanged();
+
+ QWaylandXdgToplevel *m_toplevel = nullptr;
+ QWaylandXdgDecorationManagerV1 *m_manager = nullptr;
+ uint m_configuredMode = 0;
+ uint m_clientPreferredMode = 0;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXDGDECORATIONV1_P_H
diff --git a/src/compositor/extensions/qwaylandxdgshell.cpp b/src/compositor/extensions/qwaylandxdgshell.cpp
new file mode 100644
index 000000000..ce6add3de
--- /dev/null
+++ b/src/compositor/extensions/qwaylandxdgshell.cpp
@@ -0,0 +1,2090 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshell.h"
+#include "qwaylandxdgshell_p.h"
+
+#ifdef QT_WAYLAND_COMPOSITOR_QUICK
+#include "qwaylandxdgshellintegration_p.h"
+#endif
+
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include <QtWaylandCompositor/QWaylandSeat>
+#include <QtWaylandCompositor/QWaylandSurface>
+#include <QtWaylandCompositor/QWaylandSurfaceRole>
+#include <QtWaylandCompositor/QWaylandResource>
+
+#include <QtCore/QObject>
+
+#include <algorithm>
+
+QT_BEGIN_NAMESPACE
+
+QWaylandXdgShellPrivate::QWaylandXdgShellPrivate()
+{
+}
+
+void QWaylandXdgShellPrivate::ping(QtWaylandServer::xdg_wm_base::Resource *resource, uint32_t serial)
+{
+ m_pings.insert(serial);
+ send_ping(resource->handle, serial);
+}
+
+void QWaylandXdgShellPrivate::registerXdgSurface(QWaylandXdgSurface *xdgSurface)
+{
+ m_xdgSurfaces.insert(xdgSurface->surface()->client()->client(), xdgSurface);
+}
+
+void QWaylandXdgShellPrivate::unregisterXdgSurface(QWaylandXdgSurface *xdgSurface)
+{
+ auto xdgSurfacePrivate = QWaylandXdgSurfacePrivate::get(xdgSurface);
+ if (!m_xdgSurfaces.remove(xdgSurfacePrivate->resource()->client(), xdgSurface))
+ qWarning("%s Unexpected state. Can't find registered xdg surface\n", Q_FUNC_INFO);
+}
+
+QWaylandXdgSurface *QWaylandXdgShellPrivate::xdgSurfaceFromSurface(QWaylandSurface *surface)
+{
+ for (QWaylandXdgSurface *xdgSurface : qAsConst(m_xdgSurfaces)) {
+ if (surface == xdgSurface->surface())
+ return xdgSurface;
+ }
+ return nullptr;
+}
+
+void QWaylandXdgShellPrivate::xdg_wm_base_destroy(Resource *resource)
+{
+ if (!m_xdgSurfaces.values(resource->client()).empty())
+ wl_resource_post_error(resource->handle, XDG_WM_BASE_ERROR_DEFUNCT_SURFACES,
+ "xdg_shell was destroyed before children");
+
+ wl_resource_destroy(resource->handle);
+}
+
+void QWaylandXdgShellPrivate::xdg_wm_base_create_positioner(QtWaylandServer::xdg_wm_base::Resource *resource, uint32_t id)
+{
+ QWaylandResource positionerResource(wl_resource_create(resource->client(), &xdg_positioner_interface,
+ wl_resource_get_version(resource->handle), id));
+
+ new QWaylandXdgPositioner(positionerResource);
+}
+
+void QWaylandXdgShellPrivate::xdg_wm_base_get_xdg_surface(Resource *resource, uint32_t id, wl_resource *surfaceResource)
+{
+ Q_Q(QWaylandXdgShell);
+ QWaylandSurface *surface = QWaylandSurface::fromResource(surfaceResource);
+
+ if (surface->role() != nullptr) {
+ wl_resource_post_error(resource->handle, XDG_WM_BASE_ERROR_ROLE,
+ "wl_surface@%d, already has role %s\n",
+ wl_resource_get_id(surface->resource()),
+ surface->role()->name().constData());
+ return;
+ }
+
+ if (surface->hasContent()) {
+ //TODO: According to the spec, this is a client error, but there's no appropriate error code
+ qWarning() << "get_xdg_surface requested on a xdg_surface with content";
+ }
+
+ QWaylandResource xdgSurfaceResource(wl_resource_create(resource->client(), &xdg_surface_interface,
+ wl_resource_get_version(resource->handle), id));
+
+ QWaylandXdgSurface *xdgSurface = new QWaylandXdgSurface(q, surface, xdgSurfaceResource);
+
+ registerXdgSurface(xdgSurface);
+ emit q->xdgSurfaceCreated(xdgSurface);
+}
+
+void QWaylandXdgShellPrivate::xdg_wm_base_pong(Resource *resource, uint32_t serial)
+{
+ Q_UNUSED(resource);
+ Q_Q(QWaylandXdgShell);
+ if (m_pings.remove(serial))
+ emit q->pong(serial);
+ else
+ qWarning("Received an unexpected pong!");
+}
+
+/*!
+ * \qmltype XdgShell
+ * \inqmlmodule QtWayland.Compositor
+ * \since 5.12
+ * \brief Provides an extension for desktop-style user interfaces.
+ *
+ * The XdgShell extension provides a way to associate a XdgToplevel or XdgPopup
+ * with a regular Wayland surface. Using the XdgToplevel interface, the client
+ * can request that the surface is resized, moved, and so on.
+ *
+ * XdgShell corresponds to the Wayland interface, \c xdg_shell.
+ *
+ * To provide the functionality of the shell extension in a compositor, create
+ * an instance of the XdgShell component and add it to the list of extensions
+ * supported by the compositor:
+ * \code
+ * import QtWayland.Compositor 1.3
+ *
+ * WaylandCompositor {
+ * XdgShell {
+ * // ...
+ * }
+ * }
+ * \endcode
+ */
+
+/*!
+ * \class QWaylandXdgShell
+ * \inmodule QtWaylandCompositor
+ * \since 5.12
+ * \brief The QWaylandXdgShell class is an extension for desktop-style user interfaces.
+ *
+ * The QWaylandXdgShell extension provides a way to associate a QWaylandXdgToplevel or
+ * QWaylandXdgPopup with a regular Wayland surface. Using the QWaylandXdgToplevel interface,
+ * the client can request that the surface is resized, moved, and so on.
+ *
+ * QWaylandXdgShell corresponds to the Wayland interface, \c xdg_shell.
+ */
+
+/*!
+ * Constructs a QWaylandXdgShell object.
+ */
+QWaylandXdgShell::QWaylandXdgShell()
+ : QWaylandShellTemplate<QWaylandXdgShell>(*new QWaylandXdgShellPrivate())
+{
+}
+
+/*!
+ * Constructs a QWaylandXdgShell object for the provided \a compositor.
+ */
+QWaylandXdgShell::QWaylandXdgShell(QWaylandCompositor *compositor)
+ : QWaylandShellTemplate<QWaylandXdgShell>(compositor, *new QWaylandXdgShellPrivate())
+{
+}
+
+/*!
+ * Initializes the shell extension.
+ */
+void QWaylandXdgShell::initialize()
+{
+ Q_D(QWaylandXdgShell);
+ QWaylandShellTemplate::initialize();
+ QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
+ if (!compositor) {
+ qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandXdgShell";
+ return;
+ }
+ d->init(compositor->display(), 1);
+
+ handleSeatChanged(compositor->defaultSeat(), nullptr);
+
+ connect(compositor, &QWaylandCompositor::defaultSeatChanged,
+ this, &QWaylandXdgShell::handleSeatChanged);
+}
+
+/*!
+ * Returns the Wayland interface for the QWaylandXdgShell.
+ */
+const struct wl_interface *QWaylandXdgShell::interface()
+{
+ return QWaylandXdgShellPrivate::interface();
+}
+
+QByteArray QWaylandXdgShell::interfaceName()
+{
+ return QWaylandXdgShellPrivate::interfaceName();
+}
+
+/*!
+ * \qmlmethod void QtWaylandCompositor::XdgShell::ping(WaylandClient client)
+ *
+ * Sends a ping event to \a client. If the client replies to the event the
+ * \l pong signal will be emitted.
+ */
+
+/*!
+ * Sends a ping event to \a client. If the client replies to the event the
+ * \l pong signal will be emitted.
+ */
+uint QWaylandXdgShell::ping(QWaylandClient *client)
+{
+ Q_D(QWaylandXdgShell);
+
+ QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
+ Q_ASSERT(compositor);
+
+ uint32_t serial = compositor->nextSerial();
+
+ QWaylandXdgShellPrivate::Resource *clientResource = d->resourceMap().value(client->client(), nullptr);
+ Q_ASSERT(clientResource);
+
+ d->ping(clientResource, serial);
+ return serial;
+}
+
+void QWaylandXdgShell::handleSeatChanged(QWaylandSeat *newSeat, QWaylandSeat *oldSeat)
+{
+ if (oldSeat != nullptr) {
+ disconnect(oldSeat, &QWaylandSeat::keyboardFocusChanged,
+ this, &QWaylandXdgShell::handleFocusChanged);
+ }
+
+ if (newSeat != nullptr) {
+ connect(newSeat, &QWaylandSeat::keyboardFocusChanged,
+ this, &QWaylandXdgShell::handleFocusChanged);
+ }
+}
+
+void QWaylandXdgShell::handleFocusChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface)
+{
+ Q_D(QWaylandXdgShell);
+
+ QWaylandXdgSurface *newXdgSurface = d->xdgSurfaceFromSurface(newSurface);
+ QWaylandXdgSurface *oldXdgSurface = d->xdgSurfaceFromSurface(oldSurface);
+
+ if (newXdgSurface)
+ QWaylandXdgSurfacePrivate::get(newXdgSurface)->handleFocusReceived();
+
+ if (oldXdgSurface)
+ QWaylandXdgSurfacePrivate::get(oldXdgSurface)->handleFocusLost();
+}
+
+QWaylandXdgSurfacePrivate::QWaylandXdgSurfacePrivate()
+{
+}
+
+void QWaylandXdgSurfacePrivate::setWindowType(Qt::WindowType windowType)
+{
+ if (m_windowType == windowType)
+ return;
+
+ m_windowType = windowType;
+
+ Q_Q(QWaylandXdgSurface);
+ emit q->windowTypeChanged();
+}
+
+void QWaylandXdgSurfacePrivate::handleFocusLost()
+{
+ if (m_toplevel)
+ QWaylandXdgToplevelPrivate::get(m_toplevel)->handleFocusLost();
+}
+
+void QWaylandXdgSurfacePrivate::handleFocusReceived()
+{
+ if (m_toplevel)
+ QWaylandXdgToplevelPrivate::get(m_toplevel)->handleFocusReceived();
+}
+
+QRect QWaylandXdgSurfacePrivate::calculateFallbackWindowGeometry() const
+{
+ // TODO: The unset window geometry should include subsurfaces as well, so this solution
+ // won't work too well on those kinds of clients.
+ return QRect(QPoint(0, 0), m_surface->size() / m_surface->bufferScale());
+}
+
+void QWaylandXdgSurfacePrivate::updateFallbackWindowGeometry()
+{
+ Q_Q(QWaylandXdgSurface);
+ if (!m_unsetWindowGeometry)
+ return;
+
+ const QRect unsetGeometry = calculateFallbackWindowGeometry();
+ if (unsetGeometry == m_windowGeometry)
+ return;
+
+ m_windowGeometry = unsetGeometry;
+ emit q->windowGeometryChanged();
+}
+
+void QWaylandXdgSurfacePrivate::xdg_surface_destroy_resource(QtWaylandServer::xdg_surface::Resource *resource)
+{
+ Q_UNUSED(resource);
+ Q_Q(QWaylandXdgSurface);
+ QWaylandXdgShellPrivate::get(m_xdgShell)->unregisterXdgSurface(q);
+ delete q;
+}
+
+void QWaylandXdgSurfacePrivate::xdg_surface_destroy(QtWaylandServer::xdg_surface::Resource *resource)
+{
+ wl_resource_destroy(resource->handle);
+}
+
+void QWaylandXdgSurfacePrivate::xdg_surface_get_toplevel(QtWaylandServer::xdg_surface::Resource *resource, uint32_t id)
+{
+ Q_Q(QWaylandXdgSurface);
+
+ if (m_toplevel || m_popup) {
+ wl_resource_post_error(resource->handle, XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED,
+ "xdg_surface already has a role object");
+ return;
+ }
+
+ if (!m_surface->setRole(QWaylandXdgToplevel::role(), resource->handle, XDG_WM_BASE_ERROR_ROLE))
+ return;
+
+ QWaylandResource topLevelResource(wl_resource_create(resource->client(), &xdg_toplevel_interface,
+ wl_resource_get_version(resource->handle), id));
+
+ m_toplevel = new QWaylandXdgToplevel(q, topLevelResource);
+ emit q->toplevelCreated();
+ emit m_xdgShell->toplevelCreated(m_toplevel, q);
+}
+
+void QWaylandXdgSurfacePrivate::xdg_surface_get_popup(QtWaylandServer::xdg_surface::Resource *resource, uint32_t id, wl_resource *parentResource, wl_resource *positionerResource)
+{
+ Q_Q(QWaylandXdgSurface);
+
+ if (m_toplevel || m_popup) {
+ wl_resource_post_error(resource->handle, XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED,
+ "xdg_surface already has a role object");
+ return;
+ }
+
+ QWaylandXdgSurface *parent = QWaylandXdgSurface::fromResource(parentResource);
+ if (!parent) {
+ wl_resource_post_error(resource->handle, XDG_WM_BASE_ERROR_INVALID_POPUP_PARENT,
+ "xdg_surface.get_popup with invalid popup parent");
+ return;
+ }
+
+ QWaylandXdgPositioner *positioner = QWaylandXdgPositioner::fromResource(positionerResource);
+ if (!positioner) {
+ wl_resource_post_error(resource->handle, XDG_WM_BASE_ERROR_INVALID_POSITIONER,
+ "xdg_surface.get_popup without positioner");
+ return;
+ }
+ if (!positioner->m_data.isComplete()) {
+ QWaylandXdgPositionerData p = positioner->m_data;
+ wl_resource_post_error(resource->handle, XDG_WM_BASE_ERROR_INVALID_POSITIONER,
+ "xdg_surface.get_popup with invalid positioner (size: %dx%d, anchorRect: %dx%d)",
+ p.size.width(), p.size.height(), p.anchorRect.width(), p.anchorRect.height());
+ return;
+ }
+
+ if (!m_surface->setRole(QWaylandXdgPopup::role(), resource->handle, XDG_WM_BASE_ERROR_ROLE))
+ return;
+
+ QWaylandResource popupResource(wl_resource_create(resource->client(), &xdg_popup_interface,
+ wl_resource_get_version(resource->handle), id));
+
+ m_popup = new QWaylandXdgPopup(q, parent, positioner, popupResource);
+ emit q->popupCreated();
+ emit m_xdgShell->popupCreated(m_popup, q);
+}
+
+void QWaylandXdgSurfacePrivate::xdg_surface_ack_configure(QtWaylandServer::xdg_surface::Resource *resource, uint32_t serial)
+{
+ if (m_toplevel) {
+ QWaylandXdgToplevelPrivate::get(m_toplevel)->handleAckConfigure(serial);
+ } else if (m_popup) {
+ QWaylandXdgPopupPrivate::get(m_popup)->handleAckConfigure(serial);
+ } else {
+ wl_resource_post_error(resource->handle, XDG_SURFACE_ERROR_NOT_CONSTRUCTED,
+ "ack_configure requested on an unconstructed xdg_surface");
+ }
+}
+
+void QWaylandXdgSurfacePrivate::xdg_surface_set_window_geometry(QtWaylandServer::xdg_surface::Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ Q_Q(QWaylandXdgSurface);
+
+ if (!q->surface()->role()) {
+ wl_resource_post_error(resource->handle, XDG_SURFACE_ERROR_NOT_CONSTRUCTED,
+ "set_window_geometry requested on an unconstructed xdg_surface");
+ return;
+ }
+
+ if (width <= 0 || height <= 0) {
+ // The protocol spec says "setting an invalid size will raise an error". But doesn't tell
+ // which error to raise, and there's no fitting error in the xdg_surface_error enum.
+ // So until this is fixed, just output a warning and return.
+ qWarning() << "Invalid (non-positive) dimensions received in set_window_geometry";
+ return;
+ }
+
+ m_unsetWindowGeometry = false;
+
+ QRect geometry(x, y, width, height);
+
+ if (m_windowGeometry == geometry)
+ return;
+
+ m_windowGeometry = geometry;
+ emit q->windowGeometryChanged();
+}
+
+/*!
+ * \qmltype XdgSurface
+ * \inqmlmodule QtWayland.Compositor
+ * \since 5.12
+ * \brief XdgSurface provides desktop-style compositor-specific features to an xdg surface.
+ *
+ * This type is part of the \l{XdgShell} extension and provides a way to
+ * extend the functionality of an existing \l{WaylandSurface} with features
+ * specific to desktop-style compositors, such as resizing and moving the
+ * surface.
+ *
+ * It corresponds to the Wayland interface \c xdg_surface.
+ */
+
+/*!
+ * \class QWaylandXdgSurface
+ * \inmodule QtWaylandCompositor
+ * \since 5.12
+ * \brief The QWaylandXdgSurface class provides desktop-style compositor-specific features to an xdg surface.
+ *
+ * This class is part of the QWaylandXdgShell extension and provides a way to
+ * extend the functionality of an existing QWaylandSurface with features
+ * specific to desktop-style compositors, such as resizing and moving the
+ * surface.
+ *
+ * It corresponds to the Wayland interface \c xdg_surface.
+ */
+
+/*!
+ * Constructs a QWaylandXdgSurface.
+ */
+QWaylandXdgSurface::QWaylandXdgSurface()
+ : QWaylandShellSurfaceTemplate<QWaylandXdgSurface>(*new QWaylandXdgSurfacePrivate)
+{
+}
+
+/*!
+ * Constructs a QWaylandXdgSurface for \a surface and initializes it with the
+ * given \a xdgShell, \a surface, and resource \a res.
+ */
+QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *xdgShell, QWaylandSurface *surface, const QWaylandResource &res)
+ : QWaylandShellSurfaceTemplate<QWaylandXdgSurface>(*new QWaylandXdgSurfacePrivate)
+{
+ initialize(xdgShell, surface, res);
+}
+
+/*!
+ * \qmlmethod void QtWaylandCompositor::XdgSurface::initialize(object xdgShell, object surface, object client, int id)
+ *
+ * Initializes the XdgSurface, associating it with the given \a xdgShell, \a surface,
+ * \a client, and \a id.
+ */
+
+/*!
+ * Initializes the QWaylandXdgSurface, associating it with the given \a xdgShell, \a surface
+ * and \a resource.
+ */
+void QWaylandXdgSurface::initialize(QWaylandXdgShell *xdgShell, QWaylandSurface *surface, const QWaylandResource &resource)
+{
+ Q_D(QWaylandXdgSurface);
+ d->m_xdgShell = xdgShell;
+ d->m_surface = surface;
+ d->init(resource.resource());
+ setExtensionContainer(surface);
+ d->m_windowGeometry = d->calculateFallbackWindowGeometry();
+ connect(surface, &QWaylandSurface::sizeChanged, this, &QWaylandXdgSurface::handleSurfaceSizeChanged);
+ connect(surface, &QWaylandSurface::bufferScaleChanged, this, &QWaylandXdgSurface::handleBufferScaleChanged);
+ emit shellChanged();
+ emit surfaceChanged();
+ QWaylandCompositorExtension::initialize();
+}
+
+/*!
+ * \qmlproperty enum QtWaylandCompositor::XdgSurface::windowType
+ *
+ * This property holds the window type of the XdgSurface.
+ */
+Qt::WindowType QWaylandXdgSurface::windowType() const
+{
+ Q_D(const QWaylandXdgSurface);
+ return d->m_windowType;
+}
+
+/*!
+ * \qmlproperty rect QtWaylandCompositor::XdgSurface::windowGeometry
+ *
+ * This property holds the window geometry of the QWaylandXdgSurface. The window
+ * geometry describes the window's visible bounds from the user's perspective.
+ * The geometry includes title bars and borders if drawn by the client, but
+ * excludes drop shadows. It is meant to be used for aligning and tiling
+ * windows.
+ */
+
+/*!
+ * \property QWaylandXdgSurface::windowGeometry
+ *
+ * This property holds the window geometry of the QWaylandXdgSurface. The window
+ * geometry describes the window's visible bounds from the user's perspective.
+ * The geometry includes title bars and borders if drawn by the client, but
+ * excludes drop shadows. It is meant to be used for aligning and tiling
+ * windows.
+ */
+QRect QWaylandXdgSurface::windowGeometry() const
+{
+ Q_D(const QWaylandXdgSurface);
+ return d->m_windowGeometry;
+}
+
+/*!
+ * \internal
+ */
+void QWaylandXdgSurface::initialize()
+{
+ QWaylandCompositorExtension::initialize();
+}
+
+void QWaylandXdgSurface::handleSurfaceSizeChanged()
+{
+ Q_D(QWaylandXdgSurface);
+ d->updateFallbackWindowGeometry();
+}
+
+void QWaylandXdgSurface::handleBufferScaleChanged()
+{
+ Q_D(QWaylandXdgSurface);
+ d->updateFallbackWindowGeometry();
+}
+
+/*!
+ * \qmlproperty XdgShell QtWaylandCompositor::XdgSurface::shell
+ *
+ * This property holds the shell associated with this XdgSurface.
+ */
+
+/*!
+ * \property QWaylandXdgSurface::shell
+ *
+ * This property holds the shell associated with this QWaylandXdgSurface.
+ */
+QWaylandXdgShell *QWaylandXdgSurface::shell() const
+{
+ Q_D(const QWaylandXdgSurface);
+ return d->m_xdgShell;
+}
+
+/*!
+ * \qmlproperty WaylandSurface QtWaylandCompositor::XdgSurface::surface
+ *
+ * This property holds the surface associated with this XdgSurface.
+ */
+
+/*!
+ * \property QWaylandXdgSurface::surface
+ *
+ * This property holds the surface associated with this QWaylandXdgSurface.
+ */
+QWaylandSurface *QWaylandXdgSurface::surface() const
+{
+ Q_D(const QWaylandXdgSurface);
+ return d->m_surface;
+}
+
+/*!
+ * \qmlproperty XdgToplevel QtWaylandCompositor::XdgSurface::toplevel
+ *
+ * This property holds the properties and methods that are specific to the
+ * toplevel XdgSurface.
+ *
+ * \sa popup, XdgShell::toplevelCreated
+ */
+
+/*!
+ * \property QWaylandXdgSurface::toplevel
+ *
+ * This property holds the properties and methods that are specific to the
+ * toplevel QWaylandXdgSurface.
+ *
+ * \sa QWaylandXdgSurface::popup, QWaylandXdgShell::toplevelCreated
+ */
+QWaylandXdgToplevel *QWaylandXdgSurface::toplevel() const
+{
+ Q_D(const QWaylandXdgSurface);
+ return d->m_toplevel;
+}
+
+/*!
+ * \qmlproperty XdgPopup QtWaylandCompositor::XdgSurface::popup
+ *
+ * This property holds the properties and methods that are specific to the
+ * popup XdgSurface.
+ *
+ * \sa toplevel, XdgShell::popupCreated
+ */
+
+/*!
+ * \property QWaylandXdgSurface::popup
+ *
+ * This property holds the properties and methods that are specific to the
+ * popup QWaylandXdgSurface.
+ *
+ * \sa QWaylandXdgSurface::toplevel, QWaylandXdgShell::popupCreated
+ */
+QWaylandXdgPopup *QWaylandXdgSurface::popup() const
+{
+ Q_D(const QWaylandXdgSurface);
+ return d->m_popup;
+}
+
+/*!
+ * Returns the Wayland interface for the QWaylandXdgSurface.
+ */
+const wl_interface *QWaylandXdgSurface::interface()
+{
+ return QWaylandXdgSurfacePrivate::interface();
+}
+
+/*!
+ * \internal
+ */
+QByteArray QWaylandXdgSurface::interfaceName()
+{
+ return QWaylandXdgSurfacePrivate::interfaceName();
+}
+
+/*!
+ * Returns the QWaylandXdgSurface corresponding to the \a resource.
+ */
+QWaylandXdgSurface *QWaylandXdgSurface::fromResource(wl_resource *resource)
+{
+ auto xsResource = QWaylandXdgSurfacePrivate::Resource::fromResource(resource);
+ if (!xsResource)
+ return nullptr;
+ return static_cast<QWaylandXdgSurfacePrivate *>(xsResource->xdg_surface_object)->q_func();
+}
+
+#ifdef QT_WAYLAND_COMPOSITOR_QUICK
+QWaylandQuickShellIntegration *QWaylandXdgSurface::createIntegration(QWaylandQuickShellSurfaceItem *item)
+{
+ Q_D(const QWaylandXdgSurface);
+
+ if (d->m_toplevel)
+ return new QtWayland::XdgToplevelIntegration(item);
+
+ if (d->m_popup)
+ return new QtWayland::XdgPopupIntegration(item);
+
+ return nullptr;
+}
+#endif
+
+/*!
+ * \qmltype XdgToplevel
+ * \inqmlmodule QtWayland.Compositor
+ * \since 5.12
+ * \brief XdgToplevel represents the toplevel window specific parts of an xdg surface.
+ *
+ * This type is part of the \l{XdgShell} extension and provides a way to
+ * extend the functionality of an XdgSurface with features
+ * specific to desktop-style windows.
+ *
+ * It corresponds to the Wayland interface \c xdg_toplevel.
+ */
+
+/*!
+ * \class QWaylandXdgToplevel
+ * \inmodule QtWaylandCompositor
+ * \since 5.12
+ * \brief The QWaylandXdgToplevel class represents the toplevel window specific parts of an xdg surface.
+ *
+ * This class is part of the QWaylandXdgShell extension and provides a way to
+ * extend the functionality of an QWaylandXdgSurface with features
+ * specific to desktop-style windows.
+ *
+ * It corresponds to the Wayland interface \c xdg_toplevel.
+ */
+
+/*!
+ * Constructs a QWaylandXdgToplevel for the given \a xdgSurface and \a resource.
+ */
+QWaylandXdgToplevel::QWaylandXdgToplevel(QWaylandXdgSurface *xdgSurface, QWaylandResource &resource)
+ : QObject(*new QWaylandXdgToplevelPrivate(xdgSurface, resource))
+{
+ QVector<QWaylandXdgToplevel::State> states;
+ sendConfigure({0, 0}, states);
+}
+
+QWaylandXdgToplevel::~QWaylandXdgToplevel()
+{
+ Q_D(QWaylandXdgToplevel);
+ // Usually, the decoration is destroyed by the client (according to the protocol),
+ // but if the client misbehaves, or is shut down, we need to clean up here.
+ if (Q_UNLIKELY(d->m_decoration))
+ wl_resource_destroy(d->m_decoration->resource()->handle);
+ Q_ASSERT(!d->m_decoration);
+}
+
+/*!
+ * \qmlproperty XdgToplevel QtWaylandCompositor::XdgToplevel::parentToplevel
+ *
+ * This property holds the XdgToplevel parent of this XdgToplevel.
+ */
+
+/*!
+ * \property QWaylandXdgToplevel::parentToplevel
+ *
+ * This property holds the XdgToplevel parent of this XdgToplevel.
+ *
+ */
+QWaylandXdgToplevel *QWaylandXdgToplevel::parentToplevel() const
+{
+ Q_D(const QWaylandXdgToplevel);
+ return d->m_parentToplevel;
+}
+
+/*!
+ * \qmlproperty string QtWaylandCompositor::XdgToplevel::title
+ *
+ * This property holds the title of the XdgToplevel.
+ */
+
+/*!
+ * \property QWaylandXdgToplevel::title
+ *
+ * This property holds the title of the QWaylandXdgToplevel.
+ */
+QString QWaylandXdgToplevel::title() const
+{
+ Q_D(const QWaylandXdgToplevel);
+ return d->m_title;
+}
+
+/*!
+ * \qmlproperty string QtWaylandCompositor::XdgToplevel::appId
+ *
+ * This property holds the app id of the XdgToplevel.
+ */
+
+/*!
+ * \property QWaylandXdgToplevel::appId
+ *
+ * This property holds the app id of the QWaylandXdgToplevel.
+ */
+QString QWaylandXdgToplevel::appId() const
+{
+ Q_D(const QWaylandXdgToplevel);
+ return d->m_appId;
+}
+
+/*!
+ * \qmlproperty size QtWaylandCompositor::XdgToplevel::maxSize
+ *
+ * This property holds the maximum size of the XdgToplevel as requested by the client.
+ *
+ * The compositor is free to ignore this value and request a larger size.
+ */
+
+/*!
+ * \property QWaylandXdgToplevel::maxSize
+ *
+ * This property holds the maximum size of the QWaylandXdgToplevel.
+ *
+ * The compositor is free to ignore this value and request a larger size.
+ */
+QSize QWaylandXdgToplevel::maxSize() const
+{
+ Q_D(const QWaylandXdgToplevel);
+ return d->m_maxSize;
+}
+
+/*!
+ * \qmlproperty size QtWaylandCompositor::XdgToplevel::minSize
+ *
+ * This property holds the minimum size of the XdgToplevel as requested by the client.
+ *
+ * The compositor is free to ignore this value and request a smaller size.
+ */
+
+/*!
+ * \property QWaylandXdgToplevel::minSize
+ *
+ * This property holds the minimum size of the QWaylandXdgToplevel.
+ *
+ * The compositor is free to ignore this value and request a smaller size.
+ */
+QSize QWaylandXdgToplevel::minSize() const
+{
+ Q_D(const QWaylandXdgToplevel);
+ return d->m_minSize;
+}
+
+/*!
+ * \property QWaylandXdgToplevel::states
+ *
+ * This property holds the last states the client acknowledged for this QWaylandToplevel.
+ */
+QVector<QWaylandXdgToplevel::State> QWaylandXdgToplevel::states() const
+{
+ Q_D(const QWaylandXdgToplevel);
+ return d->m_lastAckedConfigure.states;
+}
+
+/*!
+ * \qmlproperty bool QtWaylandCompositor::XdgToplevel::maximized
+ *
+ * This property holds whether the client has acknowledged that it should be maximized.
+ */
+
+/*!
+ * \property QWaylandXdgToplevel::maximized
+ *
+ * This property holds whether the client has acknowledged that it should be maximized.
+ */
+bool QWaylandXdgToplevel::maximized() const
+{
+ Q_D(const QWaylandXdgToplevel);
+ return d->m_lastAckedConfigure.states.contains(QWaylandXdgToplevel::State::MaximizedState);
+}
+
+/*!
+ * \qmlproperty bool QtWaylandCompositor::XdgToplevel::fullscreen
+ *
+ * This property holds whether the client has acknowledged that it should be fullscreen.
+ */
+
+/*!
+ * \property QWaylandXdgToplevel::fullscreen
+ *
+ * This property holds whether the client has acknowledged that it should be fullscreen.
+ */
+bool QWaylandXdgToplevel::fullscreen() const
+{
+ Q_D(const QWaylandXdgToplevel);
+ return d->m_lastAckedConfigure.states.contains(QWaylandXdgToplevel::State::FullscreenState);
+}
+
+/*!
+ * \qmlproperty bool QtWaylandCompositor::XdgToplevel::resizing
+ *
+ * This property holds whether the client has acknowledged that it is being resized.
+ */
+
+/*!
+ * \property QWaylandXdgToplevel::resizing
+ *
+ * This property holds whether the client has acknowledged that it is being resized.
+ */
+bool QWaylandXdgToplevel::resizing() const
+{
+ Q_D(const QWaylandXdgToplevel);
+ return d->m_lastAckedConfigure.states.contains(QWaylandXdgToplevel::State::ResizingState);
+}
+
+/*!
+ * \qmlproperty bool QtWaylandCompositor::XdgToplevel::activated
+ *
+ * This property holds whether toplevel is drawing itself as having input focus.
+ */
+
+/*!
+ * \property QWaylandXdgToplevel::activated
+ *
+ * This property holds whether toplevel is drawing itself as having input focus.
+ */
+bool QWaylandXdgToplevel::activated() const
+{
+ Q_D(const QWaylandXdgToplevel);
+ return d->m_lastAckedConfigure.states.contains(QWaylandXdgToplevel::State::ActivatedState);
+}
+
+/*!
+ * \enum QWaylandXdgToplevel::DecorationMode
+ *
+ * This enum type is used to specify the window decoration mode for toplevel windows.
+ *
+ * \value ServerSideDecoration The compositor should draw window decorations.
+ * \value ClientSideDecoration The client should draw window decorations.
+ */
+
+/*!
+ * \qmlproperty enumeration QtWaylandCompositor::XdgToplevel::decorationMode
+ *
+ * This property holds the current window decoration mode for this toplevel.
+ *
+ * The possible values are:
+ * \value XdgToplevel.ServerSideDecoration The compositor should draw window decorations.
+ * \value XdgToplevel.ClientSideDecoration The client should draw window decorations.
+ *
+ * \sa XdgDecorationManagerV1
+ */
+
+/*!
+ * \property QWaylandXdgToplevel::decorationMode
+ *
+ * This property holds the current window decoration mode for this toplevel.
+ *
+ * \sa QWaylandXdgDecorationManagerV1
+ */
+QWaylandXdgToplevel::DecorationMode QWaylandXdgToplevel::decorationMode() const
+{
+ Q_D(const QWaylandXdgToplevel);
+ return d->m_decoration ? d->m_decoration->configuredMode() : DecorationMode::ClientSideDecoration;
+}
+
+/*!
+ * \qmlmethod size QtWaylandCompositor::XdgToplevel::sizeForResize(size size, point delta, uint edges)
+ *
+ * Convenience for computing the new size given the current \a size, a \a delta, and
+ * the \a edges active in the drag.
+ */
+
+/*!
+ * Convenience for computing the new size given the current \a size, a \a delta, and
+ * the \a edges active in the drag.
+ */
+QSize QWaylandXdgToplevel::sizeForResize(const QSizeF &size, const QPointF &delta, Qt::Edges edges) const
+{
+ qreal width = size.width();
+ qreal height = size.height();
+ if (edges & Qt::LeftEdge)
+ width -= delta.x();
+ else if (edges & Qt::RightEdge)
+ width += delta.x();
+
+ if (edges & Qt::TopEdge)
+ height -= delta.y();
+ else if (edges & Qt::BottomEdge)
+ height += delta.y();
+
+ QSize newSize = QSize(width, height)
+ .expandedTo(minSize())
+ .expandedTo({1, 1}); // We don't want to send a size of (0,0) as that means that the client decides
+
+ if (maxSize().isValid())
+ newSize = newSize.boundedTo(maxSize());
+
+ return newSize;
+}
+
+/*!
+ * Sends a configure event to the client. Parameter \a size contains the pixel size
+ * of the surface. A size of zero means the client is free to decide the size.
+ * Known \a states are enumerated in QWaylandXdgToplevel::State.
+ */
+uint QWaylandXdgToplevel::sendConfigure(const QSize &size, const QVector<QWaylandXdgToplevel::State> &states)
+{
+ if (!size.isValid()) {
+ qWarning() << "Can't configure xdg_toplevel with an invalid size" << size;
+ return 0;
+ }
+ Q_D(QWaylandXdgToplevel);
+ auto statesBytes = QByteArray::fromRawData(reinterpret_cast<const char *>(states.data()),
+ states.size() * static_cast<int>(sizeof(State)));
+ uint32_t serial = d->m_xdgSurface->surface()->compositor()->nextSerial();
+ d->m_pendingConfigures.append(QWaylandXdgToplevelPrivate::ConfigureEvent{states, size, serial});
+ d->send_configure(size.width(), size.height(), statesBytes);
+ QWaylandXdgSurfacePrivate::get(d->m_xdgSurface)->send_configure(serial);
+ return serial;
+}
+
+/*!
+ * \qmlmethod int QtWaylandCompositor::XdgToplevel::sendConfigure(size size, list<int> states)
+ *
+ * Sends a configure event to the client. \a size contains the pixel size of the surface.
+ * A size of zero means the client is free to decide the size.
+ * Known \a states are enumerated in XdgToplevel::State.
+ */
+uint QWaylandXdgToplevel::sendConfigure(const QSize &size, const QVector<int> &states)
+{
+ QVector<State> s;
+ for (auto state : states)
+ s << State(state);
+ return sendConfigure(size, s);
+}
+
+/*!
+ * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendClose()
+ *
+ * Sends a close event to the client. The client may choose to ignore the event.
+ */
+
+/*!
+ * Sends a close event to the client. The client may choose to ignore the event.
+ */
+void QWaylandXdgToplevel::sendClose()
+{
+ Q_D(QWaylandXdgToplevel);
+ d->send_close();
+}
+
+/*!
+ * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendMaximized(size size)
+ *
+ * Convenience for sending a configure event with the maximized state set, and
+ * fullscreen and resizing removed. The activated state is left in its current state.
+ *
+ * \a size is the new size of the window.
+ */
+
+/*!
+ * Convenience for sending a configure event with the maximized state set, and
+ * fullscreen and resizing removed. The activated state is left in its current state.
+ *
+ * \a size is the new size of the window.
+ */
+uint QWaylandXdgToplevel::sendMaximized(const QSize &size)
+{
+ Q_D(QWaylandXdgToplevel);
+ QWaylandXdgToplevelPrivate::ConfigureEvent conf = d->lastSentConfigure();
+
+ if (!conf.states.contains(QWaylandXdgToplevel::State::MaximizedState))
+ conf.states.append(QWaylandXdgToplevel::State::MaximizedState);
+ conf.states.removeOne(QWaylandXdgToplevel::State::FullscreenState);
+ conf.states.removeOne(QWaylandXdgToplevel::State::ResizingState);
+
+ return sendConfigure(size, conf.states);
+}
+
+/*!
+ * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendUnmaximized(size size)
+ *
+ * Convenience for sending a configure event with the maximized, fullscreen and
+ * resizing states removed, and fullscreen and resizing removed. The activated
+ * state is left in its current state.
+ *
+ * \a size is the new size of the window. If \a size is zero, the client decides the size.
+ */
+
+/*!
+ * Convenience for sending a configure event with the maximized, fullscreen and
+ * resizing states removed, and fullscreen and resizing removed. The activated
+ * state is left in its current state.
+ *
+ * \a size is the new size of the window. If \a size is zero, the client decides the size.
+ */
+uint QWaylandXdgToplevel::sendUnmaximized(const QSize &size)
+{
+ Q_D(QWaylandXdgToplevel);
+ QWaylandXdgToplevelPrivate::ConfigureEvent conf = d->lastSentConfigure();
+
+ conf.states.removeOne(QWaylandXdgToplevel::State::MaximizedState);
+ conf.states.removeOne(QWaylandXdgToplevel::State::FullscreenState);
+ conf.states.removeOne(QWaylandXdgToplevel::State::ResizingState);
+
+ return sendConfigure(size, conf.states);
+
+}
+
+/*!
+ * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendFullscreen(size size)
+ *
+ * Convenience for sending a configure event with the fullscreen state set, and
+ * maximized and resizing removed. The activated state is left in its current state.
+ *
+ * \sa sendUnmaximized
+ *
+ * \a size is the new size of the window.
+ */
+
+/*!
+ * Convenience for sending a configure event with the fullscreen state set, and
+ * maximized and resizing removed. The activated state is left in its current state.
+ *
+ * \sa sendUnmaximized
+ *
+ * \a size is the new size of the window.
+ */
+uint QWaylandXdgToplevel::sendFullscreen(const QSize &size)
+{
+ Q_D(QWaylandXdgToplevel);
+ QWaylandXdgToplevelPrivate::ConfigureEvent conf = d->lastSentConfigure();
+
+ if (!conf.states.contains(QWaylandXdgToplevel::State::FullscreenState))
+ conf.states.append(QWaylandXdgToplevel::State::FullscreenState);
+ conf.states.removeOne(QWaylandXdgToplevel::State::MaximizedState);
+ conf.states.removeOne(QWaylandXdgToplevel::State::ResizingState);
+
+ return sendConfigure(size, conf.states);
+}
+
+/*!
+ * \qmlmethod void QtWaylandCompositor::XdgToplevel::sendResizing(size maxSize)
+ *
+ * Convenience for sending a configure event with the resizing state set, and
+ * maximized and fullscreen removed. The activated state is left in its current state.
+ *
+ * \a maxSize is the new size of the window.
+ */
+
+/*!
+ * Convenience for sending a configure event with the resizing state set, and
+ * maximized and fullscreen removed. The activated state is left in its current state.
+ *
+ * \a maxSize is the new size of the window.
+ */
+uint QWaylandXdgToplevel::sendResizing(const QSize &maxSize)
+{
+ Q_D(QWaylandXdgToplevel);
+ QWaylandXdgToplevelPrivate::ConfigureEvent conf = d->lastSentConfigure();
+
+ if (!conf.states.contains(QWaylandXdgToplevel::State::ResizingState))
+ conf.states.append(QWaylandXdgToplevel::State::ResizingState);
+ conf.states.removeOne(QWaylandXdgToplevel::State::MaximizedState);
+ conf.states.removeOne(QWaylandXdgToplevel::State::FullscreenState);
+
+ return sendConfigure(maxSize, conf.states);
+}
+
+/*!
+ * Returns the surface role for the QWaylandToplevel.
+ */
+QWaylandSurfaceRole *QWaylandXdgToplevel::role()
+{
+ return &QWaylandXdgToplevelPrivate::s_role;
+}
+
+/*!
+ * Returns the QWaylandXdgToplevel corresponding to the \a resource.
+ */
+QWaylandXdgToplevel *QWaylandXdgToplevel::fromResource(wl_resource *resource)
+{
+ if (auto *r = QWaylandXdgToplevelPrivate::Resource::fromResource(resource))
+ return static_cast<QWaylandXdgToplevelPrivate *>(r->xdg_toplevel_object)->q_func();
+ return nullptr;
+}
+
+/*!
+ * \qmlsignal QtWaylandCompositor::XdgShell::xdgSurfaceCreated(XdgSurface xdgSurface)
+ *
+ * This signal is emitted when the client has created a \c xdg_surface.
+ * Note that \a xdgSurface is not mapped, i.e. according to the \c xdg-shell
+ * protocol it should not be displayed, until it has received a role object.
+ *
+ * \sa toplevelCreated(), popupCreated()
+ */
+
+/*!
+ * \fn void QWaylandXdgShell::xdgSurfaceCreated(QWaylandXdgSurface *xdgSurface)
+ *
+ * This signal is emitted when the client has created a \c xdg_surface.
+ * Note that \a xdgSurface is not mapped, i.e. according to the \c xdg-shell
+ * protocol it should not be displayed, until it has received a role object.
+ *
+ * \sa toplevelCreated(), popupCreated()
+ */
+
+/*!
+ * \qmlsignal QtWaylandCompositor::XdgShell::toplevelCreated(XdgToplevel toplevel, XdgSurface xdgSurface)
+ *
+ * This signal is emitted when the client has created a \c xdg_toplevel.
+ * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or
+ * WaylandQuickItem for displaying \a toplevel in a QtQuick scene.
+ *
+ * \a xdgSurface is the XdgSurface \a toplevel is the role object for.
+ */
+
+/*!
+ * \fn void QWaylandXdgShell::toplevelCreated(QWaylandXdgToplevel *toplevel, QWaylandXdgSurface *xdgSurface)
+ *
+ * This signal is emitted when the client has created a \c xdg_toplevel.
+ * A common use case is to let the handler of this signal instantiate a QWaylandShellSurfaceItem or
+ * QWaylandQuickItem for displaying \a toplevel in a QtQuick scene.
+ *
+ * \a xdgSurface is the XdgSurface \a toplevel is the role object for.
+ */
+
+/*!
+ * \qmlsignal QtWaylandCompositor::XdgShell::popupCreated(XdgPopup popup, XdgSurface xdgSurface)
+ *
+ * This signal is emitted when the client has created a \c xdg_popup.
+ * A common use case is to let the handler of this signal instantiate a ShellSurfaceItem or
+ * WaylandQuickItem for displaying \a popup in a QtQuick scene.
+ *
+ * \a xdgSurface is the XdgSurface \a popup is the role object for.
+ */
+
+/*!
+ * \fn void QWaylandXdgShell::popupCreated(QWaylandXdgPopup *popup, QWaylandXdgSurface *xdgSurface)
+ *
+ * This signal is emitted when the client has created a \c xdg_popup.
+ * A common use case is to let the handler of this signal instantiate a QWaylandShellSurfaceItem or
+ * QWaylandQuickItem for displaying \a popup in a QtQuick scene.
+ *
+ * \a xdgSurface is the XdgSurface \a popup is the role object for.
+ */
+
+/*!
+ * \qmlsignal QtWaylandCompositor::XdgShell::pong(int serial)
+ *
+ * This signal is emitted when the client has responded to a ping event with serial, \a serial.
+ *
+ * \sa ping()
+ */
+
+/*!
+ * \fn void QWaylandXdgShell::pong(uint serial)
+ *
+ * This signal is emitted when the client has responded to a ping event with serial, \a serial.
+ *
+ * \sa QWaylandXdgShell::ping()
+ */
+
+QList<int> QWaylandXdgToplevel::statesAsInts() const
+{
+ QList<int> list;
+ Q_FOREACH (uint state, states()) {
+ list << static_cast<int>(state);
+ }
+ return list;
+}
+
+QWaylandSurfaceRole QWaylandXdgToplevelPrivate::s_role("xdg_toplevel");
+
+QWaylandXdgToplevelPrivate::QWaylandXdgToplevelPrivate(QWaylandXdgSurface *xdgSurface, const QWaylandResource &resource)
+ : m_xdgSurface(xdgSurface)
+{
+ init(resource.resource());
+}
+
+void QWaylandXdgToplevelPrivate::handleAckConfigure(uint serial)
+{
+ Q_Q(QWaylandXdgToplevel);
+ ConfigureEvent config;
+ Q_FOREVER {
+ if (m_pendingConfigures.empty()) {
+ qWarning("Toplevel received an unexpected ack_configure!");
+ return;
+ }
+
+ // This won't work unless there always is a toplevel.configure for each xdgsurface.configure
+ config = m_pendingConfigures.takeFirst();
+
+ if (config.serial == serial)
+ break;
+ }
+
+ QVector<uint> changedStates;
+ std::set_symmetric_difference(
+ m_lastAckedConfigure.states.begin(), m_lastAckedConfigure.states.end(),
+ config.states.begin(), config.states.end(),
+ std::back_inserter(changedStates));
+
+ m_lastAckedConfigure = config;
+
+ for (uint state : changedStates) {
+ switch (state) {
+ case state_maximized:
+ emit q->maximizedChanged();
+ break;
+ case state_fullscreen:
+ emit q->fullscreenChanged();
+ break;
+ case state_resizing:
+ emit q->resizingChanged();
+ break;
+ case state_activated:
+ emit q->activatedChanged();
+ break;
+ }
+ }
+
+ if (!changedStates.empty())
+ emit q->statesChanged();
+}
+
+void QWaylandXdgToplevelPrivate::handleFocusLost()
+{
+ Q_Q(QWaylandXdgToplevel);
+ QWaylandXdgToplevelPrivate::ConfigureEvent current = lastSentConfigure();
+ current.states.removeOne(QWaylandXdgToplevel::State::ActivatedState);
+ q->sendConfigure(current.size, current.states);
+}
+
+void QWaylandXdgToplevelPrivate::handleFocusReceived()
+{
+ Q_Q(QWaylandXdgToplevel);
+ QWaylandXdgToplevelPrivate::ConfigureEvent current = lastSentConfigure();
+ if (!current.states.contains(QWaylandXdgToplevel::State::ActivatedState)) {
+ current.states.push_back(QWaylandXdgToplevel::State::ActivatedState);
+ q->sendConfigure(current.size, current.states);
+ }
+}
+
+Qt::Edges QWaylandXdgToplevelPrivate::convertToEdges(resize_edge edge)
+{
+ return Qt::Edges(((edge & 0b1100) >> 1) | ((edge & 0b0010) << 2) | (edge & 0b0001));
+}
+
+void QWaylandXdgToplevelPrivate::xdg_toplevel_destroy_resource(QtWaylandServer::xdg_toplevel::Resource *resource)
+{
+ Q_UNUSED(resource);
+ Q_Q(QWaylandXdgToplevel);
+ delete q;
+}
+
+void QWaylandXdgToplevelPrivate::xdg_toplevel_destroy(QtWaylandServer::xdg_toplevel::Resource *resource)
+{
+ if (Q_UNLIKELY(m_decoration))
+ qWarning() << "Client error: xdg_toplevel destroyed before its decoration object";
+
+ wl_resource_destroy(resource->handle);
+ //TODO: Should the xdg surface be desroyed as well? Or is it allowed to recreate a new toplevel for it?
+}
+
+void QWaylandXdgToplevelPrivate::xdg_toplevel_set_parent(QtWaylandServer::xdg_toplevel::Resource *resource, wl_resource *parent)
+{
+ Q_UNUSED(resource);
+ QWaylandXdgToplevel *parentToplevel = QWaylandXdgToplevel::fromResource(parent);
+
+ Q_Q(QWaylandXdgToplevel);
+
+ if (m_parentToplevel != parentToplevel) {
+ m_parentToplevel = parentToplevel;
+ emit q->parentToplevelChanged();
+ }
+
+ if (m_parentToplevel && m_xdgSurface->windowType() != Qt::WindowType::SubWindow) {
+ // There's a parent now, which means the surface is transient
+ QWaylandXdgSurfacePrivate::get(m_xdgSurface)->setWindowType(Qt::WindowType::SubWindow);
+ } else if (!m_parentToplevel && m_xdgSurface->windowType() != Qt::WindowType::Window) {
+ // When the surface has no parent it is toplevel
+ QWaylandXdgSurfacePrivate::get(m_xdgSurface)->setWindowType(Qt::WindowType::Window);
+ }
+}
+
+void QWaylandXdgToplevelPrivate::xdg_toplevel_set_title(QtWaylandServer::xdg_toplevel::Resource *resource, const QString &title)
+{
+ Q_UNUSED(resource);
+ if (title == m_title)
+ return;
+ Q_Q(QWaylandXdgToplevel);
+ m_title = title;
+ emit q->titleChanged();
+}
+
+void QWaylandXdgToplevelPrivate::xdg_toplevel_set_app_id(QtWaylandServer::xdg_toplevel::Resource *resource, const QString &app_id)
+{
+ Q_UNUSED(resource);
+ if (app_id == m_appId)
+ return;
+ Q_Q(QWaylandXdgToplevel);
+ m_appId = app_id;
+ emit q->appIdChanged();
+}
+
+void QWaylandXdgToplevelPrivate::xdg_toplevel_show_window_menu(QtWaylandServer::xdg_toplevel::Resource *resource, wl_resource *seatResource, uint32_t serial, int32_t x, int32_t y)
+{
+ Q_UNUSED(resource);
+ Q_UNUSED(serial);
+ QPoint position(x, y);
+ auto seat = QWaylandSeat::fromSeatResource(seatResource);
+ Q_Q(QWaylandXdgToplevel);
+ emit q->showWindowMenu(seat, position);
+}
+
+void QWaylandXdgToplevelPrivate::xdg_toplevel_move(Resource *resource, wl_resource *seatResource, uint32_t serial)
+{
+ Q_UNUSED(resource);
+ Q_UNUSED(serial);
+ Q_Q(QWaylandXdgToplevel);
+ QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource);
+ emit q->startMove(seat);
+}
+
+void QWaylandXdgToplevelPrivate::xdg_toplevel_resize(QtWaylandServer::xdg_toplevel::Resource *resource, wl_resource *seatResource, uint32_t serial, uint32_t edges)
+{
+ Q_UNUSED(resource);
+ Q_UNUSED(serial);
+ Q_Q(QWaylandXdgToplevel);
+ QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource);
+ emit q->startResize(seat, convertToEdges(resize_edge(edges)));
+}
+
+void QWaylandXdgToplevelPrivate::xdg_toplevel_set_max_size(QtWaylandServer::xdg_toplevel::Resource *resource, int32_t width, int32_t height)
+{
+ Q_UNUSED(resource);
+
+ QSize maxSize(width, height);
+ if (width == 0 && height == 0)
+ maxSize = QSize(); // Wayland size of zero means unspecified which best translates to invalid
+
+ if (m_maxSize == maxSize)
+ return;
+
+ if (width < 0 || height < 0) {
+ // The spec says raise a protocol error, but there's no matching error defined
+ qWarning() << "Received a xdg_toplevel.set_max_size request with a negative size";
+ return;
+ }
+
+ if (m_minSize.isValid() && maxSize.isValid() &&
+ (maxSize.width() < m_minSize.width() || maxSize.height() < m_minSize.height())) {
+ // The spec says raise a protocol error, but there's no matching error defined
+ qWarning() << "Received a xdg_toplevel.set_max_size request with a size smaller than the minimium size";
+ return;
+ }
+
+ else
+ m_maxSize = maxSize;
+
+ Q_Q(QWaylandXdgToplevel);
+ emit q->maxSizeChanged();
+}
+
+void QWaylandXdgToplevelPrivate::xdg_toplevel_set_min_size(QtWaylandServer::xdg_toplevel::Resource *resource, int32_t width, int32_t height)
+{
+ Q_UNUSED(resource);
+
+ QSize minSize(width, height);
+ if (width == 0 && height == 0)
+ minSize = QSize(); // Wayland size of zero means unspecified
+
+ if (m_minSize == minSize)
+ return;
+
+ if (width < 0 || height < 0) {
+ // The spec says raise a protocol error, but there's no matching error defined
+ qWarning() << "Received a xdg_toplevel.set_min_size request with a negative size";
+ return;
+ }
+
+ if (m_maxSize.isValid() && minSize.isValid() &&
+ (minSize.width() > m_maxSize.width() || minSize.height() > m_maxSize.height())) {
+ // The spec says raise a protocol error, but there's no matching error defined
+ qWarning() << "Received a xdg_toplevel.set_min_size request with a size larger than the maximum size";
+ return;
+ }
+
+ else
+ m_minSize = minSize;
+
+ Q_Q(QWaylandXdgToplevel);
+ emit q->minSizeChanged();
+}
+
+void QWaylandXdgToplevelPrivate::xdg_toplevel_set_maximized(QtWaylandServer::xdg_toplevel::Resource *resource)
+{
+ Q_UNUSED(resource);
+ Q_Q(QWaylandXdgToplevel);
+ emit q->setMaximized();
+}
+
+void QWaylandXdgToplevelPrivate::xdg_toplevel_unset_maximized(QtWaylandServer::xdg_toplevel::Resource *resource)
+{
+ Q_UNUSED(resource);
+ Q_Q(QWaylandXdgToplevel);
+ emit q->unsetMaximized();
+}
+
+void QWaylandXdgToplevelPrivate::xdg_toplevel_set_fullscreen(QtWaylandServer::xdg_toplevel::Resource *resource, wl_resource *output_res)
+{
+ Q_UNUSED(resource);
+ Q_Q(QWaylandXdgToplevel);
+ QWaylandOutput *output = output_res ? QWaylandOutput::fromResource(output_res) : nullptr;
+ emit q->setFullscreen(output);
+}
+
+void QWaylandXdgToplevelPrivate::xdg_toplevel_unset_fullscreen(QtWaylandServer::xdg_toplevel::Resource *resource)
+{
+ Q_UNUSED(resource);
+ Q_Q(QWaylandXdgToplevel);
+ emit q->unsetFullscreen();
+}
+
+void QWaylandXdgToplevelPrivate::xdg_toplevel_set_minimized(QtWaylandServer::xdg_toplevel::Resource *resource)
+{
+ Q_UNUSED(resource);
+ Q_Q(QWaylandXdgToplevel);
+ emit q->setMinimized();
+}
+
+/*!
+ * \qmltype XdgPopup
+ * \inqmlmodule QtWayland.Compositor
+ * \since 5.12
+ * \brief XdgPopup represents the popup specific parts of and xdg surface.
+ *
+ * This type is part of the \l{XdgShell} extension and provides a way to extend
+ * extend the functionality of an \l{XdgSurface} with features
+ * specific to desktop-style menus for an xdg surface.
+ *
+ * It corresponds to the Wayland interface \c xdg_popup.
+ */
+
+/*!
+ * \class QWaylandXdgPopup
+ * \inmodule QtWaylandCompositor
+ * \since 5.12
+ * \brief The QWaylandXdgPopup class represents the popup specific parts of an xdg surface.
+ *
+ * This class is part of the QWaylandXdgShell extension and provides a way to
+ * extend the functionality of a QWaylandXdgSurface with features
+ * specific to desktop-style menus for an xdg surface.
+ *
+ * It corresponds to the Wayland interface \c xdg_popup.
+ */
+
+/*!
+ * Constructs a QWaylandXdgPopup.
+ */
+QWaylandXdgPopup::QWaylandXdgPopup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parentXdgSurface,
+ QWaylandXdgPositioner *positioner, QWaylandResource &resource)
+ : QObject(*new QWaylandXdgPopupPrivate(xdgSurface, parentXdgSurface, positioner, resource))
+{
+}
+
+/*!
+ * \qmlproperty XdgSurface QtWaylandCompositor::XdgPopup::xdgSurface
+ *
+ * This property holds the XdgSurface associated with this XdgPopup.
+ */
+
+/*!
+ * \property QWaylandXdgPopup::xdgSurface
+ *
+ * This property holds the QWaylandXdgSurface associated with this QWaylandXdgPopup.
+ */
+QWaylandXdgSurface *QWaylandXdgPopup::xdgSurface() const
+{
+ Q_D(const QWaylandXdgPopup);
+ return d->m_xdgSurface;
+}
+
+/*!
+ * \qmlproperty XdgSurface QtWaylandCompositor::XdgPopup::parentXdgSurface
+ *
+ * This property holds the XdgSurface associated with the parent of this XdgPopup.
+ */
+
+/*!
+ * \property QWaylandXdgPopup::parentXdgSurface
+ *
+ * This property holds the QWaylandXdgSurface associated with the parent of this
+ * QWaylandXdgPopup.
+ */
+QWaylandXdgSurface *QWaylandXdgPopup::parentXdgSurface() const
+{
+ Q_D(const QWaylandXdgPopup);
+ return d->m_parentXdgSurface;
+}
+
+/*!
+ * \qmlproperty rect QtWaylandCompositor::XdgPopup::configuredGeometry
+ *
+ * The window geometry the popup received in the configure event. Relative to the
+ * upper left corner of the parent surface.
+ */
+
+/*!
+ * \property QWaylandXdgPopup::configuredGeometry
+ *
+ * The window geometry the popup received in the configure event. Relative to the
+ * upper left corner of the parent surface.
+ */
+QRect QWaylandXdgPopup::configuredGeometry() const
+{
+ Q_D(const QWaylandXdgPopup);
+ return d->m_geometry;
+}
+
+/*!
+ * \qmlproperty rect QtWaylandCompositor::XdgPopup::anchorRect
+ *
+ * The anchor rectangle relative to the parent window geometry that the child
+ * surface should be placed relative to.
+ */
+
+/*!
+ * \property QWaylandXdgPopup::anchorRect
+ *
+ * Returns the anchor rectangle relative to the parent window geometry that the child
+ * surface should be placed relative to.
+ */
+QRect QWaylandXdgPopup::anchorRect() const
+{
+ Q_D(const QWaylandXdgPopup);
+ return d->m_positionerData.anchorRect;
+}
+
+/*!
+ * \qmlproperty enumeration QtWaylandCompositor::XdgPopup::anchorEdges
+ *
+ * This property holds the set of edges on the anchor rect that the child surface should be placed
+ * relative to. If no edges are specified in a direction, the anchor point should be
+ * centered between the edges.
+ *
+ * The possible values are:
+ * \value Qt.TopEdge The top edge of the rectangle.
+ * \value Qt.LeftEdge The left edge of the rectangle.
+ * \value Qt.RightEdge The right edge of the rectangle.
+ * \value Qt.BottomEdge The bottom edge of the rectangle.
+ */
+
+/*!
+ * \property QWaylandXdgPopup::anchorEdges
+ *
+ * Returns the set of edges on the anchor rect that the child surface should be placed
+ * relative to. If no edges are specified in a direction, the anchor point should be
+ * centered between the edges.
+ */
+Qt::Edges QWaylandXdgPopup::anchorEdges() const
+{
+ Q_D(const QWaylandXdgPopup);
+ return d->m_positionerData.anchorEdges;
+}
+
+/*!
+ * \qmlproperty rect QtWaylandCompositor::XdgPopup::gravityEdges
+ *
+ * Specifies in what direction the surface should be positioned, relative to the anchor
+ * point.
+ *
+ * The possible values are:
+ * \value Qt.TopEdge The surface should slide towards the top of the screen.
+ * \value Qt.LeftEdge The surface should slide towards the left of the screen.
+ * \value Qt.RightEdge The surface should slide towards the right of the screen.
+ * \value Qt.BottomEdge The surface should slide towards the bottom of the screen.
+ */
+
+/*!
+ * \property QWaylandXdgPopup::gravityEdges
+ *
+ * Specifies in what direction the surface should be positioned, relative to the anchor
+ * point.
+ */
+Qt::Edges QWaylandXdgPopup::gravityEdges() const
+{
+ Q_D(const QWaylandXdgPopup);
+ return d->m_positionerData.gravityEdges;
+}
+
+/*!
+ * \qmlproperty enumeration QtWaylandCompositor::XdgPopup::slideConstraints
+ *
+ * This property holds the orientations in which the child should slide to fit within the screen.
+ *
+ * Possible values:
+ * \value Qt.Horizontal Horizontal
+ * \value Qt.Vertical Vertical
+ */
+
+/*!
+ * \property QWaylandXdgPopup::slideConstraints
+ *
+ * This property holds the orientations in which the child should slide to fit within the screen.
+ */
+Qt::Orientations QWaylandXdgPopup::slideConstraints() const
+{
+ Q_D(const QWaylandXdgPopup);
+ const uint flags = d->m_positionerData.constraintAdjustments;
+
+ Qt::Orientations constraints = 0;
+
+ if (flags & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X)
+ constraints |= Qt::Horizontal;
+ if (flags & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y)
+ constraints |= Qt::Vertical;
+
+ return constraints;
+}
+
+/*!
+ * \qmlproperty enumeration QtWaylandCompositor::XdgPopup::flipConstraints
+ *
+ * This property holds the orientations in which the child should flip to fit within the screen.
+ *
+ * Possible values:
+ * \value Qt.Horizontal Horizontal
+ * \value Qt.Vertical Vertical
+ */
+
+/*!
+ * \property QWaylandXdgPopup::flipConstraints
+ *
+ * This property holds the orientations in which the child should flip to fit within the screen.
+ */
+Qt::Orientations QWaylandXdgPopup::flipConstraints() const
+{
+ Q_D(const QWaylandXdgPopup);
+ const uint flags = d->m_positionerData.constraintAdjustments;
+
+ Qt::Orientations constraints = 0;
+
+ if (flags & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X)
+ constraints |= Qt::Horizontal;
+ if (flags & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y)
+ constraints |= Qt::Vertical;
+
+ return constraints;
+}
+
+/*!
+ * \qmlproperty enumeration QtWaylandCompositor::XdgPopup::resizeConstraints
+ *
+ * This property holds the orientations in which the child should resize to fit within the screen.
+ *
+ * Possible values:
+ * \value Qt.Horizontal Horizontal
+ * \value Qt.Vertical Vertical
+ */
+
+/*!
+ * \property QWaylandXdgPopup::resizeConstraints
+ *
+ * This property holds the orientations in which the child should resize to fit within the screen.
+ */
+Qt::Orientations QWaylandXdgPopup::resizeConstraints() const
+{
+ Q_D(const QWaylandXdgPopup);
+ const uint flags = d->m_positionerData.constraintAdjustments;
+
+ Qt::Orientations constraints = 0;
+
+ if (flags & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X)
+ constraints |= Qt::Horizontal;
+ if (flags & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y)
+ constraints |= Qt::Vertical;
+
+ return constraints;
+}
+
+/*!
+ * \qmlproperty point QtWaylandCompositor::XdgPopup::offset
+ *
+ * The position relative to the position of the anchor on the anchor rectangle and
+ * the anchor on the surface.
+ */
+
+/*!
+ * \property QWaylandXdgPopup::offset
+ *
+ * Returns the surface position relative to the position of the anchor on the anchor
+ * rectangle and the anchor on the surface.
+ */
+QPoint QWaylandXdgPopup::offset() const
+{
+ Q_D(const QWaylandXdgPopup);
+ return d->m_positionerData.offset;
+}
+
+/*!
+ * \qmlproperty size QtWaylandCompositor::XdgPopup::positionerSize
+ *
+ * The size requested for the window geometry by the positioner object.
+ */
+
+/*!
+ * \property QWaylandXdgPopup::positionerSize
+ *
+ * Returns the size requested for the window geometry by the positioner object.
+ */
+QSize QWaylandXdgPopup::positionerSize() const
+{
+ Q_D(const QWaylandXdgPopup);
+ return d->m_positionerData.size;
+}
+
+/*!
+ * \qmlproperty point QtWaylandCompositor::XdgPopup::unconstrainedPosition
+ *
+ * The position of the surface relative to the parent window geometry if the surface
+ * is not constrained. I.e. when not moved to fit inside the screen or similar.
+ */
+
+/*!
+ * \property QWaylandXdgPopup::unconstrainedPosition
+ *
+ * The position of the surface relative to the parent window geometry if the surface
+ * is not constrained. I.e. when not moved to fit inside the screen or similar.
+ */
+QPoint QWaylandXdgPopup::unconstrainedPosition() const
+{
+ Q_D(const QWaylandXdgPopup);
+ return d->m_positionerData.unconstrainedPosition();
+}
+
+/*!
+ * \qmlmethod int QtWaylandCompositor::XdgPopup::sendConfigure(rect geometry)
+ *
+ * Sends a configure event to the client. \a geometry contains the window geometry
+ * relative to the upper left corner of the window geometry of the parent surface.
+ *
+ * This implicitly sends a configure event to the corresponding XdgSurface as well.
+ */
+
+/*!
+ * Sends a configure event to the client. \a geometry contains the window geometry
+ * relative to the upper left corner of the window geometry of the parent surface.
+ *
+ * This implicitly sends a configure event to the corresponding QWaylandXdgSurface
+ * as well.
+ */
+uint QWaylandXdgPopup::sendConfigure(const QRect &geometry)
+{
+ Q_D(QWaylandXdgPopup);
+ return d->sendConfigure(geometry);
+}
+
+/*!
+ * Returns the surface role for the QWaylandPopup.
+ */
+QWaylandSurfaceRole *QWaylandXdgPopup::role()
+{
+ return &QWaylandXdgPopupPrivate::s_role;
+}
+
+QWaylandXdgPopupPrivate::QWaylandXdgPopupPrivate(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parentXdgSurface,
+ QWaylandXdgPositioner *positioner, const QWaylandResource &resource)
+ : m_xdgSurface(xdgSurface)
+ , m_parentXdgSurface(parentXdgSurface)
+{
+ init(resource.resource());
+ m_positionerData = positioner->m_data;
+
+ if (!m_positionerData.isComplete())
+ qWarning() << "Trying to create xdg popup with incomplete positioner";
+
+ QWaylandXdgSurfacePrivate::get(m_xdgSurface)->setWindowType(Qt::WindowType::Popup);
+
+ //TODO: positioner rect may not extend parent's window geometry, enforce this?
+ //TODO: Need an API for sending a different initial configure
+ sendConfigure(QRect(m_positionerData.unconstrainedPosition(), m_positionerData.size));
+}
+
+void QWaylandXdgPopupPrivate::handleAckConfigure(uint serial)
+{
+ Q_Q(QWaylandXdgPopup);
+ ConfigureEvent config;
+ Q_FOREVER {
+ if (m_pendingConfigures.empty()) {
+ qWarning("Popup received an unexpected ack_configure!");
+ return;
+ }
+
+ // This won't work unless there always is a popup.configure for each xdgsurface.configure
+ config = m_pendingConfigures.takeFirst();
+
+ if (config.serial == serial)
+ break;
+ }
+
+ if (m_geometry == config.geometry)
+ return;
+
+ m_geometry = config.geometry;
+ emit q->configuredGeometryChanged();
+}
+
+uint QWaylandXdgPopupPrivate::sendConfigure(const QRect &geometry)
+{
+ uint32_t serial = m_xdgSurface->surface()->compositor()->nextSerial();
+ m_pendingConfigures.append(QWaylandXdgPopupPrivate::ConfigureEvent{geometry, serial});
+ send_configure(geometry.x(), geometry.y(), geometry.width(), geometry.height());
+ QWaylandXdgSurfacePrivate::get(m_xdgSurface)->send_configure(serial);
+ return serial;
+}
+
+void QWaylandXdgPopupPrivate::xdg_popup_destroy(QtWaylandServer::xdg_popup::Resource *resource)
+{
+ Q_UNUSED(resource);
+ qWarning() << Q_FUNC_INFO << "Not implemented"; //TODO
+}
+
+void QWaylandXdgPopupPrivate::xdg_popup_grab(QtWaylandServer::xdg_popup::Resource *resource, wl_resource *seat, uint32_t serial)
+{
+ Q_UNUSED(resource);
+ Q_UNUSED(serial);
+ Q_UNUSED(seat);
+ qWarning() << Q_FUNC_INFO << "Not implemented"; //TODO
+ //switch keyboard focus
+ //eventually send configure with activated.
+}
+
+QWaylandSurfaceRole QWaylandXdgPopupPrivate::s_role("xdg_popup");
+
+QWaylandXdgPositionerData::QWaylandXdgPositionerData()
+ : offset(0, 0)
+{}
+
+bool QWaylandXdgPositionerData::isComplete() const
+{
+ return size.width() > 0 && size.height() > 0 && anchorRect.size().width() > 0 && anchorRect.size().height() > 0;
+}
+
+QPoint QWaylandXdgPositionerData::anchorPoint() const
+{
+ int yPosition = 0;
+ if (anchorEdges & Qt::TopEdge)
+ yPosition = anchorRect.top();
+ else if (anchorEdges & Qt::BottomEdge)
+ yPosition = anchorRect.bottom() + 1;
+ else
+ yPosition = anchorRect.top() + anchorRect.height() / 2;
+
+ int xPosition = 0;
+ if (anchorEdges & Qt::LeftEdge)
+ xPosition = anchorRect.left();
+ else if (anchorEdges & Qt::RightEdge)
+ xPosition = anchorRect.right() + 1;
+ else
+ xPosition = anchorRect.left() + anchorRect.width() / 2;
+
+ return QPoint(xPosition, yPosition);
+}
+
+QPoint QWaylandXdgPositionerData::unconstrainedPosition() const
+{
+ int gravityOffsetY = 0;
+ if (gravityEdges & Qt::TopEdge)
+ gravityOffsetY = -size.height();
+ else if (!(gravityEdges & Qt::BottomEdge))
+ gravityOffsetY = -size.height() / 2;
+
+ int gravityOffsetX = 0;
+ if (gravityEdges & Qt::LeftEdge)
+ gravityOffsetX = -size.width();
+ else if (!(gravityEdges & Qt::RightEdge))
+ gravityOffsetX = -size.width() / 2;
+
+ QPoint gravityOffset(gravityOffsetX, gravityOffsetY);
+ return anchorPoint() + gravityOffset + offset;
+}
+
+QWaylandXdgPositioner::QWaylandXdgPositioner(const QWaylandResource &resource)
+{
+ init(resource.resource());
+}
+
+void QWaylandXdgPositioner::xdg_positioner_destroy_resource(QtWaylandServer::xdg_positioner::Resource *resource)
+{
+ Q_UNUSED(resource);
+ delete this;
+}
+
+void QWaylandXdgPositioner::xdg_positioner_destroy(QtWaylandServer::xdg_positioner::Resource *resource)
+{
+ wl_resource_destroy(resource->handle);
+}
+
+void QWaylandXdgPositioner::xdg_positioner_set_size(QtWaylandServer::xdg_positioner::Resource *resource, int32_t width, int32_t height)
+{
+ if (width <= 0 || height <= 0) {
+ wl_resource_post_error(resource->handle, XDG_POSITIONER_ERROR_INVALID_INPUT,
+ "xdg_positioner.set_size requested with non-positive dimensions");
+ return;
+ }
+
+ QSize size(width, height);
+ m_data.size = size;
+}
+
+void QWaylandXdgPositioner::xdg_positioner_set_anchor_rect(QtWaylandServer::xdg_positioner::Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ if (width <= 0 || height <= 0) {
+ wl_resource_post_error(resource->handle, XDG_POSITIONER_ERROR_INVALID_INPUT,
+ "xdg_positioner.set_anchor_rect requested with non-positive dimensions");
+ return;
+ }
+
+ QRect anchorRect(x, y, width, height);
+ m_data.anchorRect = anchorRect;
+}
+
+void QWaylandXdgPositioner::xdg_positioner_set_anchor(QtWaylandServer::xdg_positioner::Resource *resource, uint32_t anchor)
+{
+ Qt::Edges anchorEdges = convertToEdges(xdg_positioner::anchor(anchor));
+
+ if ((anchorEdges & Qt::BottomEdge && anchorEdges & Qt::TopEdge) ||
+ (anchorEdges & Qt::LeftEdge && anchorEdges & Qt::RightEdge)) {
+ wl_resource_post_error(resource->handle, XDG_POSITIONER_ERROR_INVALID_INPUT,
+ "xdg_positioner.set_anchor requested with parallel edges");
+ return;
+ }
+
+ m_data.anchorEdges = anchorEdges;
+}
+
+void QWaylandXdgPositioner::xdg_positioner_set_gravity(QtWaylandServer::xdg_positioner::Resource *resource, uint32_t gravity)
+{
+ Qt::Edges gravityEdges = convertToEdges(xdg_positioner::gravity(gravity));
+
+ if ((gravityEdges & Qt::BottomEdge && gravityEdges & Qt::TopEdge) ||
+ (gravityEdges & Qt::LeftEdge && gravityEdges & Qt::RightEdge)) {
+ wl_resource_post_error(resource->handle, XDG_POSITIONER_ERROR_INVALID_INPUT,
+ "xdg_positioner.set_gravity requested with parallel edges");
+ return;
+ }
+
+ m_data.gravityEdges = gravityEdges;
+}
+
+void QWaylandXdgPositioner::xdg_positioner_set_constraint_adjustment(QtWaylandServer::xdg_positioner::Resource *resource, uint32_t constraint_adjustment)
+{
+ Q_UNUSED(resource);
+ m_data.constraintAdjustments = constraint_adjustment;
+}
+
+void QWaylandXdgPositioner::xdg_positioner_set_offset(QtWaylandServer::xdg_positioner::Resource *resource, int32_t x, int32_t y)
+{
+ Q_UNUSED(resource);
+ m_data.offset = QPoint(x, y);
+}
+
+QWaylandXdgPositioner *QWaylandXdgPositioner::fromResource(wl_resource *resource)
+{
+ if (auto *r = Resource::fromResource(resource))
+ return static_cast<QWaylandXdgPositioner *>(r->xdg_positioner_object);
+ return nullptr;
+}
+
+Qt::Edges QWaylandXdgPositioner::convertToEdges(anchor anchor)
+{
+ switch (anchor) {
+ case anchor_none:
+ return Qt::Edges();
+ case anchor_top:
+ return Qt::TopEdge;
+ case anchor_bottom:
+ return Qt::BottomEdge;
+ case anchor_left:
+ return Qt::LeftEdge;
+ case anchor_right:
+ return Qt::RightEdge;
+ case anchor_top_left:
+ return Qt::TopEdge | Qt::LeftEdge;
+ case anchor_bottom_left:
+ return Qt::BottomEdge | Qt::LeftEdge;
+ case anchor_top_right:
+ return Qt::TopEdge | Qt::RightEdge;
+ case anchor_bottom_right:
+ return Qt::BottomEdge | Qt::RightEdge;
+ default:
+ qWarning() << "Unknown Wayland xdg edge" << anchor;
+ return Qt::Edges();
+ }
+}
+
+Qt::Edges QWaylandXdgPositioner::convertToEdges(QWaylandXdgPositioner::gravity gravity)
+{
+ return convertToEdges(anchor(gravity));
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwaylandxdgshell.h b/src/compositor/extensions/qwaylandxdgshell.h
new file mode 100644
index 000000000..71454f929
--- /dev/null
+++ b/src/compositor/extensions/qwaylandxdgshell.h
@@ -0,0 +1,275 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXDGSHELL_H
+#define QWAYLANDXDGSHELL_H
+
+#include <QtWaylandCompositor/QWaylandCompositorExtension>
+#include <QtWaylandCompositor/QWaylandResource>
+#include <QtWaylandCompositor/QWaylandShell>
+#include <QtWaylandCompositor/QWaylandShellSurface>
+#include <QtWaylandCompositor/qwaylandquickchildren.h>
+
+#include <QtCore/QRect>
+
+struct wl_resource;
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandClient;
+class QWaylandOutput;
+class QWaylandSeat;
+class QWaylandSurface;
+class QWaylandSurfaceRole;
+class QWaylandXdgShellPrivate;
+class QWaylandXdgSurface;
+class QWaylandXdgSurfacePrivate;
+class QWaylandXdgToplevel;
+class QWaylandXdgToplevelPrivate;
+class QWaylandXdgPopup;
+class QWaylandXdgPopupPrivate;
+class QWaylandXdgPositioner;
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShell : public QWaylandShellTemplate<QWaylandXdgShell>
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandXdgShell)
+public:
+ explicit QWaylandXdgShell();
+ explicit QWaylandXdgShell(QWaylandCompositor *compositor);
+
+ void initialize() override;
+
+ static const struct wl_interface *interface();
+ static QByteArray interfaceName();
+
+public Q_SLOTS:
+ uint ping(QWaylandClient *client);
+
+Q_SIGNALS:
+ void xdgSurfaceCreated(QWaylandXdgSurface *xdgSurface);
+ void toplevelCreated(QWaylandXdgToplevel *toplevel, QWaylandXdgSurface *xdgSurface);
+ void popupCreated(QWaylandXdgPopup *popup, QWaylandXdgSurface *xdgSurface);
+ void pong(uint serial);
+
+private Q_SLOTS:
+ void handleSeatChanged(QWaylandSeat *newSeat, QWaylandSeat *oldSeat);
+ void handleFocusChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface);
+};
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurface : public QWaylandShellSurfaceTemplate<QWaylandXdgSurface>
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandXdgSurface)
+ Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgSurface)
+ Q_PROPERTY(QWaylandXdgShell *shell READ shell NOTIFY shellChanged)
+ Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged)
+ Q_PROPERTY(QWaylandXdgToplevel *toplevel READ toplevel NOTIFY toplevelCreated)
+ Q_PROPERTY(QWaylandXdgPopup *popup READ popup NOTIFY popupCreated)
+ Q_PROPERTY(QRect windowGeometry READ windowGeometry NOTIFY windowGeometryChanged)
+
+public:
+ explicit QWaylandXdgSurface();
+ explicit QWaylandXdgSurface(QWaylandXdgShell* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource);
+
+ Q_INVOKABLE void initialize(QWaylandXdgShell* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource);
+
+ Qt::WindowType windowType() const override;
+
+ QWaylandXdgShell *shell() const;
+ QWaylandSurface *surface() const;
+ QWaylandXdgToplevel *toplevel() const;
+ QWaylandXdgPopup *popup() const;
+ QRect windowGeometry() const;
+
+ static const struct wl_interface *interface();
+ static QByteArray interfaceName();
+ static QWaylandXdgSurface *fromResource(::wl_resource *resource);
+
+#ifdef QT_WAYLAND_COMPOSITOR_QUICK
+ QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override;
+#endif
+
+Q_SIGNALS:
+ void shellChanged();
+ void surfaceChanged();
+ void toplevelCreated();
+ void popupCreated();
+ void windowGeometryChanged();
+
+private:
+ void initialize() override;
+
+private Q_SLOTS:
+ void handleSurfaceSizeChanged();
+ void handleBufferScaleChanged();
+};
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevel : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandXdgToplevel)
+ Q_PROPERTY(QWaylandXdgToplevel *parentToplevel READ parentToplevel NOTIFY parentToplevelChanged)
+ Q_PROPERTY(QString title READ title NOTIFY titleChanged)
+ Q_PROPERTY(QString appId READ appId NOTIFY appIdChanged)
+ Q_PROPERTY(QSize maxSize READ maxSize NOTIFY maxSizeChanged)
+ Q_PROPERTY(QSize minSize READ minSize NOTIFY minSizeChanged)
+ Q_PROPERTY(QList<int> states READ statesAsInts NOTIFY statesChanged)
+ Q_PROPERTY(bool maximized READ maximized NOTIFY maximizedChanged)
+ Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged)
+ Q_PROPERTY(bool resizing READ resizing NOTIFY resizingChanged)
+ Q_PROPERTY(bool activated READ activated NOTIFY activatedChanged)
+ Q_PROPERTY(enum DecorationMode decorationMode READ decorationMode NOTIFY decorationModeChanged)
+public:
+ enum State : uint {
+ MaximizedState = 1,
+ FullscreenState = 2,
+ ResizingState = 3,
+ ActivatedState = 4
+ };
+ Q_ENUM(State)
+
+ enum DecorationMode {
+ ClientSideDecoration = 1,
+ ServerSideDecoration = 2,
+ };
+ Q_ENUM(DecorationMode)
+
+ explicit QWaylandXdgToplevel(QWaylandXdgSurface *xdgSurface, QWaylandResource &resource);
+ ~QWaylandXdgToplevel() override;
+
+ QWaylandXdgToplevel *parentToplevel() const;
+
+ QString title() const;
+ QString appId() const;
+ QSize maxSize() const;
+ QSize minSize() const;
+ QVector<QWaylandXdgToplevel::State> states() const;
+ bool maximized() const;
+ bool fullscreen() const;
+ bool resizing() const;
+ bool activated() const;
+ DecorationMode decorationMode() const;
+
+ Q_INVOKABLE QSize sizeForResize(const QSizeF &size, const QPointF &delta, Qt::Edges edges) const;
+ uint sendConfigure(const QSize &size, const QVector<State> &states);
+ Q_INVOKABLE uint sendConfigure(const QSize &size, const QVector<int> &states);
+ Q_INVOKABLE void sendClose();
+ Q_INVOKABLE uint sendMaximized(const QSize &size);
+ Q_INVOKABLE uint sendUnmaximized(const QSize &size = QSize(0, 0));
+ Q_INVOKABLE uint sendFullscreen(const QSize &size);
+ Q_INVOKABLE uint sendResizing(const QSize &maxSize);
+
+ static QWaylandSurfaceRole *role();
+ static QWaylandXdgToplevel *fromResource(::wl_resource *resource);
+
+Q_SIGNALS:
+ void parentToplevelChanged();
+ void titleChanged();
+ void appIdChanged();
+ void maxSizeChanged();
+ void minSizeChanged();
+ void startMove(QWaylandSeat *seat);
+ void startResize(QWaylandSeat *seat, Qt::Edges edges);
+ void statesChanged();
+ void maximizedChanged();
+ void fullscreenChanged();
+ void resizingChanged();
+ void activatedChanged();
+
+ void showWindowMenu(QWaylandSeat *seat, const QPoint &localSurfacePosition);
+ void setMaximized();
+ void unsetMaximized();
+ void setFullscreen(QWaylandOutput *output);
+ void unsetFullscreen();
+ void setMinimized();
+
+ void decorationModeChanged();
+
+private:
+ QList<int> statesAsInts() const;
+};
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopup : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandXdgPopup)
+ Q_PROPERTY(QWaylandXdgSurface *xdgSurface READ xdgSurface)
+ Q_PROPERTY(QWaylandXdgSurface *parentXdgSurface READ parentXdgSurface)
+ Q_PROPERTY(QRect configuredGeometry READ configuredGeometry NOTIFY configuredGeometryChanged)
+
+ // Positioner properties
+ Q_PROPERTY(QRect anchorRect READ anchorRect CONSTANT)
+ Q_PROPERTY(Qt::Edges anchorEdges READ anchorEdges CONSTANT)
+ Q_PROPERTY(Qt::Edges gravityEdges READ gravityEdges CONSTANT)
+ Q_PROPERTY(Qt::Orientations slideConstraints READ slideConstraints CONSTANT)
+ Q_PROPERTY(Qt::Orientations flipConstraints READ flipConstraints CONSTANT)
+ Q_PROPERTY(Qt::Orientations resizeConstraints READ resizeConstraints CONSTANT)
+ Q_PROPERTY(QPoint offset READ offset CONSTANT)
+ Q_PROPERTY(QSize positionerSize READ positionerSize CONSTANT)
+ Q_PROPERTY(QPoint unconstrainedPosition READ unconstrainedPosition CONSTANT)
+public:
+ QWaylandXdgSurface *xdgSurface() const;
+ QWaylandXdgSurface *parentXdgSurface() const;
+ QRect configuredGeometry() const;
+
+ // Positioner properties
+ QRect anchorRect() const;
+ Qt::Edges anchorEdges() const ;
+ Qt::Edges gravityEdges() const ;
+ Qt::Orientations slideConstraints() const;
+ Qt::Orientations flipConstraints() const;
+ Qt::Orientations resizeConstraints() const;
+ QPoint offset() const;
+ QSize positionerSize() const;
+ QPoint unconstrainedPosition() const;
+
+ Q_INVOKABLE uint sendConfigure(const QRect &geometry);
+
+ static QWaylandSurfaceRole *role();
+
+Q_SIGNALS:
+ void configuredGeometryChanged();
+
+private:
+ explicit QWaylandXdgPopup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parentXdgSurface,
+ QWaylandXdgPositioner *positioner, QWaylandResource &resource);
+ friend class QWaylandXdgSurfacePrivate;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXDGSHELL_H
diff --git a/src/compositor/extensions/qwaylandxdgshell_p.h b/src/compositor/extensions/qwaylandxdgshell_p.h
new file mode 100644
index 000000000..5ef8bde3d
--- /dev/null
+++ b/src/compositor/extensions/qwaylandxdgshell_p.h
@@ -0,0 +1,244 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXDGSHELL_P_H
+#define QWAYLANDXDGSHELL_P_H
+
+#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h>
+#include <QtWaylandCompositor/private/qwayland-server-xdg-shell.h>
+
+#include <QtWaylandCompositor/QWaylandXdgShell>
+
+#include <QtWaylandCompositor/private/qwaylandxdgdecorationv1_p.h>
+
+#include <QtCore/QSet>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+struct Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPositionerData {
+ QSize size;
+ QRect anchorRect;
+ Qt::Edges anchorEdges = 0;
+ Qt::Edges gravityEdges = 0;
+ uint constraintAdjustments = XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE;
+ QPoint offset;
+ QWaylandXdgPositionerData();
+ bool isComplete() const;
+ QPoint anchorPoint() const;
+ QPoint unconstrainedPosition() const;
+};
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellPrivate
+ : public QWaylandCompositorExtensionPrivate
+ , public QtWaylandServer::xdg_wm_base
+{
+ Q_DECLARE_PUBLIC(QWaylandXdgShell)
+public:
+ QWaylandXdgShellPrivate();
+ void ping(Resource *resource, uint32_t serial);
+ void registerXdgSurface(QWaylandXdgSurface *xdgSurface);
+ void unregisterXdgSurface(QWaylandXdgSurface *xdgSurface);
+ static QWaylandXdgShellPrivate *get(QWaylandXdgShell *xdgShell) { return xdgShell->d_func(); }
+
+ QSet<uint32_t> m_pings;
+ QMultiMap<struct wl_client *, QWaylandXdgSurface *> m_xdgSurfaces;
+
+ QWaylandXdgSurface *xdgSurfaceFromSurface(QWaylandSurface *surface);
+
+protected:
+ void xdg_wm_base_destroy(Resource *resource) override;
+ void xdg_wm_base_create_positioner(Resource *resource, uint32_t id) override;
+ void xdg_wm_base_get_xdg_surface(Resource *resource, uint32_t id,
+ struct ::wl_resource *surface) override;
+ void xdg_wm_base_pong(Resource *resource, uint32_t serial) override;
+};
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfacePrivate
+ : public QWaylandCompositorExtensionPrivate
+ , public QtWaylandServer::xdg_surface
+{
+ Q_DECLARE_PUBLIC(QWaylandXdgSurface)
+public:
+ QWaylandXdgSurfacePrivate();
+ void setWindowType(Qt::WindowType windowType);
+ void handleFocusLost();
+ void handleFocusReceived();
+ static QWaylandXdgSurfacePrivate *get(QWaylandXdgSurface *xdgSurface) { return xdgSurface->d_func(); }
+
+ QRect calculateFallbackWindowGeometry() const;
+ void updateFallbackWindowGeometry();
+
+private:
+ QWaylandXdgShell *m_xdgShell = nullptr;
+ QWaylandSurface *m_surface = nullptr;
+
+ QWaylandXdgToplevel *m_toplevel = nullptr;
+ QWaylandXdgPopup *m_popup = nullptr;
+ QRect m_windowGeometry;
+ bool m_unsetWindowGeometry = true;
+ QMargins m_windowMargins;
+ Qt::WindowType m_windowType = Qt::WindowType::Window;
+
+ void xdg_surface_destroy_resource(Resource *resource) override;
+ void xdg_surface_destroy(Resource *resource) override;
+ void xdg_surface_get_toplevel(Resource *resource, uint32_t id) override;
+ void xdg_surface_get_popup(Resource *resource, uint32_t id, struct ::wl_resource *parent, struct ::wl_resource *positioner) override;
+ void xdg_surface_ack_configure(Resource *resource, uint32_t serial) override;
+ void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
+};
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevelPrivate : public QObjectPrivate, public QtWaylandServer::xdg_toplevel
+{
+ Q_DECLARE_PUBLIC(QWaylandXdgToplevel)
+public:
+ struct ConfigureEvent {
+ QVector<QWaylandXdgToplevel::State> states;
+ QSize size = {0, 0};
+ uint serial = 0;
+ };
+
+ QWaylandXdgToplevelPrivate(QWaylandXdgSurface *xdgSurface, const QWaylandResource& resource);
+ ConfigureEvent lastSentConfigure() const { return m_pendingConfigures.empty() ? m_lastAckedConfigure : m_pendingConfigures.last(); }
+ void handleAckConfigure(uint serial); //TODO: move?
+ void handleFocusLost();
+ void handleFocusReceived();
+
+ static QWaylandXdgToplevelPrivate *get(QWaylandXdgToplevel *toplevel) { return toplevel->d_func(); }
+ static Qt::Edges convertToEdges(resize_edge edge);
+
+protected:
+
+ void xdg_toplevel_destroy_resource(Resource *resource) override;
+
+ void xdg_toplevel_destroy(Resource *resource) override;
+ void xdg_toplevel_set_parent(Resource *resource, struct ::wl_resource *parent) override;
+ void xdg_toplevel_set_title(Resource *resource, const QString &title) override;
+ void xdg_toplevel_set_app_id(Resource *resource, const QString &app_id) override;
+ void xdg_toplevel_show_window_menu(Resource *resource, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y) override;
+ void xdg_toplevel_move(Resource *resource, struct ::wl_resource *seatResource, uint32_t serial) override;
+ void xdg_toplevel_resize(Resource *resource, struct ::wl_resource *seat, uint32_t serial, uint32_t edges) override;
+ void xdg_toplevel_set_max_size(Resource *resource, int32_t width, int32_t height) override;
+ void xdg_toplevel_set_min_size(Resource *resource, int32_t width, int32_t height) override;
+ void xdg_toplevel_set_maximized(Resource *resource) override;
+ void xdg_toplevel_unset_maximized(Resource *resource) override;
+ void xdg_toplevel_set_fullscreen(Resource *resource, struct ::wl_resource *output) override;
+ void xdg_toplevel_unset_fullscreen(Resource *resource) override;
+ void xdg_toplevel_set_minimized(Resource *resource) override;
+
+public:
+ QWaylandXdgSurface *m_xdgSurface = nullptr;
+ QWaylandXdgToplevel *m_parentToplevel = nullptr;
+ QList<ConfigureEvent> m_pendingConfigures;
+ ConfigureEvent m_lastAckedConfigure;
+ QString m_title;
+ QString m_appId;
+ QSize m_maxSize;
+ QSize m_minSize = {0, 0};
+ QWaylandXdgToplevelDecorationV1 *m_decoration = nullptr;
+
+ static QWaylandSurfaceRole s_role;
+};
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupPrivate : public QObjectPrivate, public QtWaylandServer::xdg_popup
+{
+ Q_DECLARE_PUBLIC(QWaylandXdgPopup)
+public:
+ struct ConfigureEvent {
+ QRect geometry;
+ uint serial;
+ };
+
+ QWaylandXdgPopupPrivate(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parentXdgSurface,
+ QWaylandXdgPositioner *positioner, const QWaylandResource& resource);
+
+ void handleAckConfigure(uint serial);
+
+ static QWaylandXdgPopupPrivate *get(QWaylandXdgPopup *popup) { return popup->d_func(); }
+
+ static QWaylandSurfaceRole s_role;
+
+private:
+ uint sendConfigure(const QRect &geometry);
+
+protected:
+ void xdg_popup_destroy(Resource *resource) override;
+ void xdg_popup_grab(Resource *resource, struct ::wl_resource *seat, uint32_t serial) override;
+
+private:
+ QWaylandXdgSurface *m_xdgSurface = nullptr;
+ QWaylandXdgSurface *m_parentXdgSurface = nullptr;
+ QWaylandXdgPositionerData m_positionerData;
+ QRect m_geometry;
+ QList<ConfigureEvent> m_pendingConfigures;
+};
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPositioner : public QtWaylandServer::xdg_positioner
+{
+public:
+ QWaylandXdgPositioner(const QWaylandResource& resource);
+ static QWaylandXdgPositioner *fromResource(wl_resource *resource);
+ static Qt::Edges convertToEdges(anchor anchor);
+ static Qt::Edges convertToEdges(gravity gravity);
+
+protected:
+ void xdg_positioner_destroy_resource(Resource *resource) override; //TODO: do something special here?
+
+ void xdg_positioner_destroy(Resource *resource) override;
+ void xdg_positioner_set_size(Resource *resource, int32_t width, int32_t height) override;
+ void xdg_positioner_set_anchor_rect(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
+ void xdg_positioner_set_anchor(Resource *resource, uint32_t anchor) override;
+ void xdg_positioner_set_gravity(Resource *resource, uint32_t gravity) override;
+ void xdg_positioner_set_constraint_adjustment(Resource *resource, uint32_t constraint_adjustment) override;
+ void xdg_positioner_set_offset(Resource *resource, int32_t x, int32_t y) override;
+
+public:
+ QWaylandXdgPositionerData m_data;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXDGSHELL_P_H
diff --git a/src/compositor/extensions/qwaylandxdgshellintegration.cpp b/src/compositor/extensions/qwaylandxdgshellintegration.cpp
new file mode 100644
index 000000000..cc8faf6c7
--- /dev/null
+++ b/src/compositor/extensions/qwaylandxdgshellintegration.cpp
@@ -0,0 +1,300 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshellintegration_p.h"
+
+#include <QtWaylandCompositor/QWaylandXdgSurface>
+#include <QtWaylandCompositor/QWaylandCompositor>
+#include <QtWaylandCompositor/QWaylandSeat>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWayland {
+
+static void handlePopupCreated(QWaylandQuickShellSurfaceItem *parentItem, QWaylandXdgPopup *popup)
+{
+ if (parentItem->shellSurface() == popup->parentXdgSurface())
+ QWaylandQuickShellSurfaceItemPrivate::get(parentItem)->maybeCreateAutoPopup(popup->xdgSurface());
+}
+
+XdgToplevelIntegration::XdgToplevelIntegration(QWaylandQuickShellSurfaceItem *item)
+ : QWaylandQuickShellIntegration(item)
+ , m_item(item)
+ , m_xdgSurface(qobject_cast<QWaylandXdgSurface *>(item->shellSurface()))
+ , m_toplevel(m_xdgSurface->toplevel())
+ , grabberState(GrabberState::Default)
+{
+ Q_ASSERT(m_toplevel);
+
+ m_item->setSurface(m_xdgSurface->surface());
+
+ connect(m_toplevel, &QWaylandXdgToplevel::startMove, this, &XdgToplevelIntegration::handleStartMove);
+ connect(m_toplevel, &QWaylandXdgToplevel::startResize, this, &XdgToplevelIntegration::handleStartResize);
+ connect(m_toplevel, &QWaylandXdgToplevel::setMaximized, this, &XdgToplevelIntegration::handleSetMaximized);
+ connect(m_toplevel, &QWaylandXdgToplevel::unsetMaximized, this, &XdgToplevelIntegration::handleUnsetMaximized);
+ connect(m_toplevel, &QWaylandXdgToplevel::maximizedChanged, this, &XdgToplevelIntegration::handleMaximizedChanged);
+ connect(m_toplevel, &QWaylandXdgToplevel::setFullscreen, this, &XdgToplevelIntegration::handleSetFullscreen);
+ connect(m_toplevel, &QWaylandXdgToplevel::unsetFullscreen, this, &XdgToplevelIntegration::handleUnsetFullscreen);
+ connect(m_toplevel, &QWaylandXdgToplevel::fullscreenChanged, this, &XdgToplevelIntegration::handleFullscreenChanged);
+ connect(m_toplevel, &QWaylandXdgToplevel::activatedChanged, this, &XdgToplevelIntegration::handleActivatedChanged);
+ connect(m_xdgSurface->shell(), &QWaylandXdgShell::popupCreated, this, [item](QWaylandXdgPopup *popup, QWaylandXdgSurface *){
+ handlePopupCreated(item, popup);
+ });
+ connect(m_xdgSurface->surface(), &QWaylandSurface::sizeChanged, this, &XdgToplevelIntegration::handleSurfaceSizeChanged);
+ connect(m_toplevel, &QObject::destroyed, this, &XdgToplevelIntegration::handleToplevelDestroyed);
+}
+
+bool XdgToplevelIntegration::mouseMoveEvent(QMouseEvent *event)
+{
+ if (grabberState == GrabberState::Resize) {
+ Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event));
+ if (!resizeState.initialized) {
+ resizeState.initialMousePos = event->windowPos();
+ resizeState.initialized = true;
+ return true;
+ }
+ QPointF delta = m_item->mapToSurface(event->windowPos() - resizeState.initialMousePos);
+ QSize newSize = m_toplevel->sizeForResize(resizeState.initialWindowSize, delta, resizeState.resizeEdges);
+ m_toplevel->sendResizing(newSize);
+ } else if (grabberState == GrabberState::Move) {
+ Q_ASSERT(moveState.seat == m_item->compositor()->seatFor(event));
+ QQuickItem *moveItem = m_item->moveItem();
+ if (!moveState.initialized) {
+ moveState.initialOffset = moveItem->mapFromItem(nullptr, event->windowPos());
+ moveState.initialized = true;
+ return true;
+ }
+ if (!moveItem->parentItem())
+ return true;
+ QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->windowPos());
+ moveItem->setPosition(parentPos - moveState.initialOffset);
+ }
+ return false;
+}
+
+bool XdgToplevelIntegration::mouseReleaseEvent(QMouseEvent *event)
+{
+ Q_UNUSED(event);
+
+ if (grabberState != GrabberState::Default) {
+ grabberState = GrabberState::Default;
+ return true;
+ }
+ return false;
+}
+
+void XdgToplevelIntegration::handleStartMove(QWaylandSeat *seat)
+{
+ grabberState = GrabberState::Move;
+ moveState.seat = seat;
+ moveState.initialized = false;
+}
+
+void XdgToplevelIntegration::handleStartResize(QWaylandSeat *seat, Qt::Edges edges)
+{
+ grabberState = GrabberState::Resize;
+ resizeState.seat = seat;
+ resizeState.resizeEdges = edges;
+ resizeState.initialWindowSize = m_xdgSurface->windowGeometry().size();
+ resizeState.initialPosition = m_item->moveItem()->position();
+ resizeState.initialSurfaceSize = m_item->surface()->size();
+ resizeState.initialized = false;
+}
+
+void XdgToplevelIntegration::handleSetMaximized()
+{
+ if (!m_item->view()->isPrimary())
+ return;
+
+ QVector<QWaylandXdgToplevel::State> states = m_toplevel->states();
+
+ if (!states.contains(QWaylandXdgToplevel::State::FullscreenState) && !states.contains(QWaylandXdgToplevel::State::MaximizedState)) {
+ windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size();
+ windowedGeometry.initialPosition = m_item->moveItem()->position();
+ }
+
+ // Any prior output-resize handlers are irrelevant at this point.
+ disconnect(nonwindowedState.sizeChangedConnection);
+ nonwindowedState.output = m_item->view()->output();
+ nonwindowedState.sizeChangedConnection = connect(nonwindowedState.output, &QWaylandOutput::availableGeometryChanged, this, &XdgToplevelIntegration::handleMaximizedSizeChanged);
+ handleMaximizedSizeChanged();
+}
+
+void XdgToplevelIntegration::handleMaximizedSizeChanged()
+{
+ // Insurance against handleToplevelDestroyed() not managing to disconnect this
+ // handler in time.
+ if (m_toplevel == nullptr)
+ return;
+
+ m_toplevel->sendMaximized(nonwindowedState.output->availableGeometry().size() / nonwindowedState.output->scaleFactor());
+}
+
+void XdgToplevelIntegration::handleUnsetMaximized()
+{
+ if (!m_item->view()->isPrimary())
+ return;
+
+ // If no prior windowed size was recorded, send a 0x0 configure event
+ // to allow the client to choose its preferred size.
+ if (windowedGeometry.initialWindowSize.isValid())
+ m_toplevel->sendUnmaximized(windowedGeometry.initialWindowSize);
+ else
+ m_toplevel->sendUnmaximized();
+}
+
+void XdgToplevelIntegration::handleMaximizedChanged()
+{
+ if (m_toplevel->maximized()) {
+ QWaylandOutput *output = m_item->view()->output();
+ m_item->moveItem()->setPosition(output->position() + output->availableGeometry().topLeft());
+ } else {
+ m_item->moveItem()->setPosition(windowedGeometry.initialPosition);
+ }
+}
+
+void XdgToplevelIntegration::handleSetFullscreen()
+{
+ if (!m_item->view()->isPrimary())
+ return;
+
+ QVector<QWaylandXdgToplevel::State> states = m_toplevel->states();
+
+ if (!states.contains(QWaylandXdgToplevel::State::FullscreenState) && !states.contains(QWaylandXdgToplevel::State::MaximizedState)) {
+ windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size();
+ windowedGeometry.initialPosition = m_item->moveItem()->position();
+ }
+
+ // Any prior output-resize handlers are irrelevant at this point.
+ disconnect(nonwindowedState.sizeChangedConnection);
+ nonwindowedState.output = m_item->view()->output();
+ nonwindowedState.sizeChangedConnection = connect(nonwindowedState.output, &QWaylandOutput::geometryChanged, this, &XdgToplevelIntegration::handleFullscreenSizeChanged);
+ handleFullscreenSizeChanged();
+}
+
+void XdgToplevelIntegration::handleFullscreenSizeChanged()
+{
+ // Insurance against handleToplevelDestroyed() not managing to disconnect this
+ // handler in time.
+ if (m_toplevel == nullptr)
+ return;
+
+ m_toplevel->sendFullscreen(nonwindowedState.output->geometry().size() / nonwindowedState.output->scaleFactor());
+}
+
+void XdgToplevelIntegration::handleUnsetFullscreen()
+{
+ if (!m_item->view()->isPrimary())
+ return;
+
+ // If no prior windowed size was recorded, send a 0x0 configure event
+ // to allow the client to choose its preferred size.
+ if (windowedGeometry.initialWindowSize.isValid())
+ m_toplevel->sendUnmaximized(windowedGeometry.initialWindowSize);
+ else
+ m_toplevel->sendUnmaximized();
+}
+
+void XdgToplevelIntegration::handleFullscreenChanged()
+{
+ if (m_toplevel->fullscreen()) {
+ QWaylandOutput *output = m_item->view()->output();
+ m_item->moveItem()->setPosition(output->position() + output->geometry().topLeft());
+ } else {
+ m_item->moveItem()->setPosition(windowedGeometry.initialPosition);
+ }
+}
+
+void XdgToplevelIntegration::handleActivatedChanged()
+{
+ if (m_toplevel->activated())
+ m_item->raise();
+}
+
+void XdgToplevelIntegration::handleSurfaceSizeChanged()
+{
+ if (grabberState == GrabberState::Resize) {
+ qreal x = resizeState.initialPosition.x();
+ qreal y = resizeState.initialPosition.y();
+ if (resizeState.resizeEdges & Qt::TopEdge)
+ y += resizeState.initialSurfaceSize.height() - m_item->surface()->size().height();
+
+ if (resizeState.resizeEdges & Qt::LeftEdge)
+ x += resizeState.initialSurfaceSize.width() - m_item->surface()->size().width();
+ m_item->moveItem()->setPosition(QPointF(x, y));
+ }
+}
+
+void XdgToplevelIntegration::handleToplevelDestroyed()
+{
+ // Disarm any handlers that might fire on the now-stale toplevel pointer
+ nonwindowedState.output = nullptr;
+ disconnect(nonwindowedState.sizeChangedConnection);
+}
+
+XdgPopupIntegration::XdgPopupIntegration(QWaylandQuickShellSurfaceItem *item)
+ : m_item(item)
+ , m_xdgSurface(qobject_cast<QWaylandXdgSurface *>(item->shellSurface()))
+ , m_popup(m_xdgSurface->popup())
+{
+ Q_ASSERT(m_popup);
+
+ m_item->setSurface(m_xdgSurface->surface());
+ handleGeometryChanged();
+
+ connect(m_popup, &QWaylandXdgPopup::configuredGeometryChanged, this, &XdgPopupIntegration::handleGeometryChanged);
+ connect(m_xdgSurface->shell(), &QWaylandXdgShell::popupCreated, this, [item](QWaylandXdgPopup *popup, QWaylandXdgSurface *){
+ handlePopupCreated(item, popup);
+ });
+}
+
+void XdgPopupIntegration::handleGeometryChanged()
+{
+ if (m_item->view()->output()) {
+ const QPoint windowOffset = m_popup->parentXdgSurface()->windowGeometry().topLeft();
+ const QPoint position = m_popup->unconstrainedPosition() + windowOffset;
+ //TODO: positioner size or other size...?
+ const float scaleFactor = m_item->view()->output()->scaleFactor();
+ //TODO check positioner constraints etc... sliding, flipping
+ m_item->moveItem()->setPosition(position * scaleFactor);
+ } else {
+ qWarning() << "XdgPopupIntegration popup item without output" << m_item;
+ }
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwaylandxdgshellintegration_p.h b/src/compositor/extensions/qwaylandxdgshellintegration_p.h
new file mode 100644
index 000000000..34e3873d5
--- /dev/null
+++ b/src/compositor/extensions/qwaylandxdgshellintegration_p.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXDGSHELLINTEGRATION_H
+#define QWAYLANDXDGSHELLINTEGRATION_H
+
+#include <QtWaylandCompositor/private/qwaylandquickshellsurfaceitem_p.h>
+#include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem>
+#include <QtWaylandCompositor/QWaylandXdgToplevel>
+
+QT_BEGIN_NAMESPACE
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+class QWaylandXdgSurface;
+
+namespace QtWayland {
+
+class XdgToplevelIntegration : public QWaylandQuickShellIntegration
+{
+ Q_OBJECT
+public:
+ XdgToplevelIntegration(QWaylandQuickShellSurfaceItem *item);
+ bool mouseMoveEvent(QMouseEvent *event) override;
+ bool mouseReleaseEvent(QMouseEvent *event) override;
+
+private Q_SLOTS:
+ void handleStartMove(QWaylandSeat *seat);
+ void handleStartResize(QWaylandSeat *seat, Qt::Edges edges);
+ void handleSetMaximized();
+ void handleUnsetMaximized();
+ void handleMaximizedChanged();
+ void handleSetFullscreen();
+ void handleUnsetFullscreen();
+ void handleFullscreenChanged();
+ void handleActivatedChanged();
+ void handleSurfaceSizeChanged();
+ void handleToplevelDestroyed();
+ void handleMaximizedSizeChanged();
+ void handleFullscreenSizeChanged();
+
+private:
+ QWaylandQuickShellSurfaceItem *m_item = nullptr;
+ QWaylandXdgSurface *m_xdgSurface = nullptr;
+ QWaylandXdgToplevel *m_toplevel = nullptr;
+
+ enum class GrabberState {
+ Default,
+ Resize,
+ Move
+ };
+ GrabberState grabberState;
+
+ struct {
+ QWaylandSeat *seat = nullptr;
+ QPointF initialOffset;
+ bool initialized;
+ } moveState;
+
+ struct {
+ QWaylandSeat *seat = nullptr;
+ Qt::Edges resizeEdges;
+ QSizeF initialWindowSize;
+ QPointF initialMousePos;
+ QPointF initialPosition;
+ QSize initialSurfaceSize;
+ bool initialized;
+ } resizeState;
+
+ struct {
+ QSize initialWindowSize;
+ QPointF initialPosition;
+ } windowedGeometry;
+
+ struct {
+ QWaylandOutput *output = nullptr;
+ QMetaObject::Connection sizeChangedConnection; // Depending on whether maximized or fullscreen,
+ // will be hooked to geometry-changed or available-
+ // geometry-changed.
+ } nonwindowedState;
+};
+
+class XdgPopupIntegration : public QWaylandQuickShellIntegration
+{
+ Q_OBJECT
+public:
+ XdgPopupIntegration(QWaylandQuickShellSurfaceItem *item);
+
+private Q_SLOTS:
+ void handleGeometryChanged();
+
+private:
+ QWaylandQuickShellSurfaceItem *m_item = nullptr;
+ QWaylandXdgSurface *m_xdgSurface = nullptr;
+ QWaylandXdgPopup *m_popup = nullptr;
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXDGSHELLINTEGRATION_H
diff --git a/src/compositor/extensions/qwaylandxdgshellv5.cpp b/src/compositor/extensions/qwaylandxdgshellv5.cpp
index 6bfaf7a61..a6e88aabb 100644
--- a/src/compositor/extensions/qwaylandxdgshellv5.cpp
+++ b/src/compositor/extensions/qwaylandxdgshellv5.cpp
@@ -148,7 +148,7 @@ void QWaylandXdgShellV5Private::xdg_shell_get_xdg_surface(Resource *resource, ui
if (!surface->setRole(QWaylandXdgSurfaceV5::role(), resource->handle, XDG_SHELL_ERROR_ROLE))
return;
- QWaylandResource xdgSurfaceResource(wl_resource_create(resource->client(), &xdg_surface_interface,
+ QWaylandResource xdgSurfaceResource(wl_resource_create(resource->client(), &xdg_surface_v5_interface,
wl_resource_get_version(resource->handle), id));
emit q->xdgSurfaceRequested(surface, xdgSurfaceResource);
@@ -166,10 +166,10 @@ void QWaylandXdgShellV5Private::xdg_shell_get_xdg_surface(Resource *resource, ui
void QWaylandXdgShellV5Private::xdg_shell_use_unstable_version(Resource *resource, int32_t version)
{
- if (xdg_shell::version_current != version) {
+ if (xdg_shell_v5::version_current != version) {
wl_resource_post_error(resource->handle, WL_DISPLAY_ERROR_INVALID_OBJECT,
"incompatible version, server is %d, but client wants %d",
- xdg_shell::version_current, version);
+ xdg_shell_v5::version_current, version);
}
}
@@ -193,7 +193,7 @@ void QWaylandXdgShellV5Private::xdg_shell_get_xdg_popup(Resource *resource, uint
return;
}
- QWaylandResource xdgPopupResource (wl_resource_create(resource->client(), &xdg_popup_interface,
+ QWaylandResource xdgPopupResource (wl_resource_create(resource->client(), &xdg_popup_v5_interface,
wl_resource_get_version(resource->handle), id));
QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource);
QPoint position(x, y);
@@ -521,6 +521,8 @@ void QWaylandXdgPopupV5Private::xdg_popup_destroy(Resource *resource)
* }
* }
* \endcode
+ *
+ * \deprecated
*/
/*!
@@ -534,6 +536,8 @@ void QWaylandXdgPopupV5Private::xdg_popup_destroy(Resource *resource)
* can request that the surface is resized, moved, and so on.
*
* QWaylandXdgShellV5 corresponds to the Wayland interface \c xdg_shell.
+ *
+ * \deprecated
*/
/*!
@@ -762,6 +766,8 @@ void QWaylandXdgShellV5::handleFocusChanged(QWaylandSurface *newSurface, QWaylan
* compositors, such as resizing and moving the surface.
*
* It corresponds to the Wayland interface \c xdg_surface for the unstable xdg-shell protocol v5.
+ *
+ * \deprecated
*/
/*!
@@ -776,6 +782,8 @@ void QWaylandXdgShellV5::handleFocusChanged(QWaylandSurface *newSurface, QWaylan
* surface.
*
* It corresponds to the Wayland interface xdg_surface.
+ *
+ * \deprecated
*/
/*!
@@ -1318,6 +1326,8 @@ QWaylandQuickShellIntegration *QWaylandXdgSurfaceV5::createIntegration(QWaylandQ
* using xdg-shell.
*
* It corresponds to the Wayland interface \c xdg_popup for the unstable xdg-shell protocol v5.
+ *
+ * \deprecated
*/
/*!
@@ -1331,6 +1341,8 @@ QWaylandQuickShellIntegration *QWaylandXdgSurfaceV5::createIntegration(QWaylandQ
* specific to desktop-style menus for an xdg surface.
*
* It corresponds to the Wayland interface xdg_popup.
+ *
+ * \deprecated
*/
/*!
diff --git a/src/compositor/extensions/qwaylandxdgshellv5.h b/src/compositor/extensions/qwaylandxdgshellv5.h
index 05b49f6ef..f989d04c7 100644
--- a/src/compositor/extensions/qwaylandxdgshellv5.h
+++ b/src/compositor/extensions/qwaylandxdgshellv5.h
@@ -44,6 +44,7 @@
#include <QtWaylandCompositor/QWaylandResource>
#include <QtWaylandCompositor/QWaylandShell>
#include <QtWaylandCompositor/QWaylandShellSurface>
+#include <QtWaylandCompositor/qwaylandquickchildren.h>
#include <QtCore/QRect>
@@ -98,6 +99,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfaceV5 : public QWaylandShellSur
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandXdgSurfaceV5)
+ Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgSurfaceV5)
Q_PROPERTY(QWaylandXdgShellV5 *shell READ shell NOTIFY shellChanged)
Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged)
Q_PROPERTY(QWaylandXdgSurfaceV5 *parentSurface READ parentSurface NOTIFY parentSurfaceChanged)
@@ -212,6 +214,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurfa
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandXdgPopupV5)
+ Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgPopupV5)
Q_PROPERTY(QWaylandXdgShellV5 *shell READ shell NOTIFY shellChanged)
Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged)
Q_PROPERTY(QWaylandSurface *parentSurface READ parentSurface NOTIFY parentSurfaceChanged)
diff --git a/src/compositor/extensions/qwaylandxdgshellv5_p.h b/src/compositor/extensions/qwaylandxdgshellv5_p.h
index b0b51698d..681c4537b 100644
--- a/src/compositor/extensions/qwaylandxdgshellv5_p.h
+++ b/src/compositor/extensions/qwaylandxdgshellv5_p.h
@@ -41,7 +41,7 @@
#define QWAYLANDXDGSHELLV5_P_H
#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h>
-#include <QtWaylandCompositor/private/qwayland-server-xdg-shell.h>
+#include <QtWaylandCompositor/private/qwayland-server-xdg-shell-unstable-v5_p.h>
#include <QtWaylandCompositor/QWaylandXdgShellV5>
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellV5Private
: public QWaylandCompositorExtensionPrivate
- , public QtWaylandServer::xdg_shell
+ , public QtWaylandServer::xdg_shell_v5
{
Q_DECLARE_PUBLIC(QWaylandXdgShellV5)
public:
@@ -95,7 +95,7 @@ protected:
class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfaceV5Private
: public QWaylandCompositorExtensionPrivate
- , public QtWaylandServer::xdg_surface
+ , public QtWaylandServer::xdg_surface_v5
{
Q_DECLARE_PUBLIC(QWaylandXdgSurfaceV5)
public:
@@ -158,7 +158,7 @@ private:
class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupV5Private
: public QWaylandCompositorExtensionPrivate
- , public QtWaylandServer::xdg_popup
+ , public QtWaylandServer::xdg_popup_v5
{
Q_DECLARE_PUBLIC(QWaylandXdgPopupV5)
@@ -172,7 +172,7 @@ public:
QPoint m_position;
void xdg_popup_destroy_resource(Resource *resource) override;
- void xdg_popup_destroy(xdg_popup::Resource *resource) override;
+ void xdg_popup_destroy(xdg_popup_v5::Resource *resource) override;
static QWaylandSurfaceRole s_role;
};
diff --git a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp b/src/compositor/extensions/qwaylandxdgshellv5integration.cpp
index a349a25aa..ea04a33d2 100644
--- a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp
+++ b/src/compositor/extensions/qwaylandxdgshellv5integration.cpp
@@ -50,6 +50,12 @@ QT_BEGIN_NAMESPACE
namespace QtWayland {
+static void handlePopupCreated(QWaylandQuickShellSurfaceItem *parentItem, QWaylandXdgPopupV5 *popup)
+{
+ if (parentItem->surface() == popup->parentSurface())
+ QWaylandQuickShellSurfaceItemPrivate::get(parentItem)->maybeCreateAutoPopup(popup);
+}
+
XdgShellV5Integration::XdgShellV5Integration(QWaylandQuickShellSurfaceItem *item)
: QWaylandQuickShellIntegration(item)
, m_item(item)
@@ -66,6 +72,9 @@ XdgShellV5Integration::XdgShellV5Integration(QWaylandQuickShellSurfaceItem *item
connect(m_xdgSurface, &QWaylandXdgSurfaceV5::maximizedChanged, this, &XdgShellV5Integration::handleMaximizedChanged);
connect(m_xdgSurface, &QWaylandXdgSurfaceV5::activatedChanged, this, &XdgShellV5Integration::handleActivatedChanged);
connect(m_xdgSurface->surface(), &QWaylandSurface::sizeChanged, this, &XdgShellV5Integration::handleSurfaceSizeChanged);
+ connect(m_xdgSurface->shell(), &QWaylandXdgShellV5::xdgPopupCreated, this, [item](QWaylandXdgPopupV5 *popup){
+ handlePopupCreated(item, popup);
+ });
}
XdgShellV5Integration::~XdgShellV5Integration()
@@ -213,6 +222,9 @@ XdgPopupV5Integration::XdgPopupV5Integration(QWaylandQuickShellSurfaceItem *item
QWaylandQuickShellEventFilter::startFilter(client, [shell]() { shell->closeAllPopups(); });
connect(m_xdgPopup, &QWaylandXdgPopupV5::destroyed, this, &XdgPopupV5Integration::handlePopupDestroyed);
+ connect(m_xdgPopup->shell(), &QWaylandXdgShellV5::xdgPopupCreated, this, [item](QWaylandXdgPopupV5 *popup) {
+ handlePopupCreated(item, popup);
+ });
}
XdgPopupV5Integration::~XdgPopupV5Integration()
diff --git a/src/compositor/extensions/qwaylandxdgshellv6.cpp b/src/compositor/extensions/qwaylandxdgshellv6.cpp
index 61625cf9c..a8b0d3914 100644
--- a/src/compositor/extensions/qwaylandxdgshellv6.cpp
+++ b/src/compositor/extensions/qwaylandxdgshellv6.cpp
@@ -934,9 +934,14 @@ QSize QWaylandXdgToplevelV6::sizeForResize(const QSizeF &size, const QPointF &de
else if (edges & Qt::BottomEdge)
height += delta.y();
- //TODO: use minSize given by the client here instead
- QSizeF newSize(qMax(width, 1.0), qMax(height, 1.0));
- return newSize.toSize();
+ QSize newSize = QSize(width, height)
+ .expandedTo(minSize())
+ .expandedTo({1, 1}); // We don't want to send a size of (0,0) as that means that the client decides
+
+ if (maxSize().isValid())
+ newSize = newSize.boundedTo(maxSize());
+
+ return newSize;
}
/*!
@@ -1054,6 +1059,8 @@ uint QWaylandXdgToplevelV6::sendUnmaximized(const QSize &size)
* Convenience for sending a configure event with the fullscreen state set, and
* maximized and resizing removed. The activated state is left in its current state.
*
+ * \sa sendUnmaximized
+ *
* \a size is the new size of the window.
*/
@@ -1061,6 +1068,8 @@ uint QWaylandXdgToplevelV6::sendUnmaximized(const QSize &size)
* Convenience for sending a configure event with the fullscreen state set, and
* maximized and resizing removed. The activated state is left in its current state.
*
+ * \sa sendUnmaximized
+ *
* \a size is the new size of the window.
*/
uint QWaylandXdgToplevelV6::sendFullscreen(const QSize &size)
@@ -1924,8 +1933,6 @@ void QWaylandXdgPositionerV6::zxdg_positioner_v6_destroy(QtWaylandServer::zxdg_p
void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_size(QtWaylandServer::zxdg_positioner_v6::Resource *resource, int32_t width, int32_t height)
{
- Q_UNUSED(resource);
-
if (width <= 0 || height <= 0) {
wl_resource_post_error(resource->handle, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT,
"zxdg_positioner_v6.set_size requested with non-positive dimensions");
@@ -1938,8 +1945,6 @@ void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_size(QtWaylandServer::zxdg_
void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_anchor_rect(QtWaylandServer::zxdg_positioner_v6::Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
{
- Q_UNUSED(resource);
-
if (width <= 0 || height <= 0) {
wl_resource_post_error(resource->handle, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT,
"zxdg_positioner_v6.set_anchor_rect requested with non-positive dimensions");
@@ -1952,8 +1957,6 @@ void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_anchor_rect(QtWaylandServer
void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_anchor(QtWaylandServer::zxdg_positioner_v6::Resource *resource, uint32_t anchor)
{
- Q_UNUSED(resource);
-
Qt::Edges anchorEdges = QWaylandXdgShellV6Private::convertToEdges(anchor);
if ((anchorEdges & Qt::BottomEdge && anchorEdges & Qt::TopEdge) ||
@@ -1968,7 +1971,6 @@ void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_anchor(QtWaylandServer::zxd
void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_gravity(QtWaylandServer::zxdg_positioner_v6::Resource *resource, uint32_t gravity)
{
- Q_UNUSED(resource);
Qt::Edges gravityEdges = QWaylandXdgShellV6Private::convertToEdges(gravity);
if ((gravityEdges & Qt::BottomEdge && gravityEdges & Qt::TopEdge) ||
@@ -1995,7 +1997,9 @@ void QWaylandXdgPositionerV6::zxdg_positioner_v6_set_offset(QtWaylandServer::zxd
QWaylandXdgPositionerV6 *QWaylandXdgPositionerV6::fromResource(wl_resource *resource)
{
- return static_cast<QWaylandXdgPositionerV6 *>(Resource::fromResource(resource)->zxdg_positioner_v6_object);
+ if (auto *r = Resource::fromResource(resource))
+ return static_cast<QWaylandXdgPositionerV6 *>(r->zxdg_positioner_v6_object);
+ return nullptr;
}
QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwaylandxdgshellv6.h b/src/compositor/extensions/qwaylandxdgshellv6.h
index 8c5eee8a2..b9c47c578 100644
--- a/src/compositor/extensions/qwaylandxdgshellv6.h
+++ b/src/compositor/extensions/qwaylandxdgshellv6.h
@@ -41,6 +41,7 @@
#include <QtWaylandCompositor/QWaylandResource>
#include <QtWaylandCompositor/QWaylandShell>
#include <QtWaylandCompositor/QWaylandShellSurface>
+#include <QtWaylandCompositor/qwaylandquickchildren.h>
#include <QtCore/QRect>
@@ -93,6 +94,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfaceV6 : public QWaylandShellSur
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandXdgSurfaceV6)
+ Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgSurfaceV6)
Q_PROPERTY(QWaylandXdgShellV6 *shell READ shell NOTIFY shellChanged)
Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged)
Q_PROPERTY(QWaylandXdgToplevelV6 *toplevel READ toplevel NOTIFY toplevelCreated)
diff --git a/src/compositor/extensions/qwaylandxdgshellv6integration.cpp b/src/compositor/extensions/qwaylandxdgshellv6integration.cpp
index 94a03ec02..61a9092a3 100644
--- a/src/compositor/extensions/qwaylandxdgshellv6integration.cpp
+++ b/src/compositor/extensions/qwaylandxdgshellv6integration.cpp
@@ -44,6 +44,12 @@ QT_BEGIN_NAMESPACE
namespace QtWayland {
+static void handlePopupCreated(QWaylandQuickShellSurfaceItem *parentItem, QWaylandXdgPopupV6 *popup)
+{
+ if (parentItem->shellSurface() == popup->parentXdgSurface())
+ QWaylandQuickShellSurfaceItemPrivate::get(parentItem)->maybeCreateAutoPopup(popup->xdgSurface());
+}
+
XdgToplevelV6Integration::XdgToplevelV6Integration(QWaylandQuickShellSurfaceItem *item)
: QWaylandQuickShellIntegration(item)
, m_item(item)
@@ -54,13 +60,21 @@ XdgToplevelV6Integration::XdgToplevelV6Integration(QWaylandQuickShellSurfaceItem
Q_ASSERT(m_toplevel);
m_item->setSurface(m_xdgSurface->surface());
+
connect(m_toplevel, &QWaylandXdgToplevelV6::startMove, this, &XdgToplevelV6Integration::handleStartMove);
connect(m_toplevel, &QWaylandXdgToplevelV6::startResize, this, &XdgToplevelV6Integration::handleStartResize);
connect(m_toplevel, &QWaylandXdgToplevelV6::setMaximized, this, &XdgToplevelV6Integration::handleSetMaximized);
connect(m_toplevel, &QWaylandXdgToplevelV6::unsetMaximized, this, &XdgToplevelV6Integration::handleUnsetMaximized);
connect(m_toplevel, &QWaylandXdgToplevelV6::maximizedChanged, this, &XdgToplevelV6Integration::handleMaximizedChanged);
+ connect(m_toplevel, &QWaylandXdgToplevelV6::setFullscreen, this, &XdgToplevelV6Integration::handleSetFullscreen);
+ connect(m_toplevel, &QWaylandXdgToplevelV6::unsetFullscreen, this, &XdgToplevelV6Integration::handleUnsetFullscreen);
+ connect(m_toplevel, &QWaylandXdgToplevelV6::fullscreenChanged, this, &XdgToplevelV6Integration::handleFullscreenChanged);
connect(m_toplevel, &QWaylandXdgToplevelV6::activatedChanged, this, &XdgToplevelV6Integration::handleActivatedChanged);
+ connect(m_xdgSurface->shell(), &QWaylandXdgShellV6::popupCreated, this, [item](QWaylandXdgPopupV6 *popup, QWaylandXdgSurfaceV6 *){
+ handlePopupCreated(item, popup);
+ });
connect(m_xdgSurface->surface(), &QWaylandSurface::sizeChanged, this, &XdgToplevelV6Integration::handleSurfaceSizeChanged);
+ connect(m_toplevel, &QObject::destroyed, this, &XdgToplevelV6Integration::handleToplevelDestroyed);
}
bool XdgToplevelV6Integration::mouseMoveEvent(QMouseEvent *event)
@@ -125,11 +139,28 @@ void XdgToplevelV6Integration::handleSetMaximized()
if (!m_item->view()->isPrimary())
return;
- maximizeState.initialWindowSize = m_xdgSurface->windowGeometry().size();
- maximizeState.initialPosition = m_item->moveItem()->position();
+ QVector<QWaylandXdgToplevelV6::State> states = m_toplevel->states();
+
+ if (!states.contains(QWaylandXdgToplevelV6::State::FullscreenState) && !states.contains(QWaylandXdgToplevelV6::State::MaximizedState)) {
+ windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size();
+ windowedGeometry.initialPosition = m_item->moveItem()->position();
+ }
+
+ // Any prior output-resize handlers are irrelevant at this point.
+ disconnect(nonwindowedState.sizeChangedConnection);
+ nonwindowedState.output = m_item->view()->output();
+ nonwindowedState.sizeChangedConnection = connect(nonwindowedState.output, &QWaylandOutput::availableGeometryChanged, this, &XdgToplevelV6Integration::handleMaximizedSizeChanged);
+ handleMaximizedSizeChanged();
+}
+
+void XdgToplevelV6Integration::handleMaximizedSizeChanged()
+{
+ // Insurance against handleToplevelDestroyed() not managing to disconnect this
+ // handler in time.
+ if (m_toplevel == nullptr)
+ return;
- QWaylandOutput *output = m_item->view()->output();
- m_toplevel->sendMaximized(output->availableGeometry().size() / output->scaleFactor());
+ m_toplevel->sendMaximized(nonwindowedState.output->availableGeometry().size() / nonwindowedState.output->scaleFactor());
}
void XdgToplevelV6Integration::handleUnsetMaximized()
@@ -137,7 +168,12 @@ void XdgToplevelV6Integration::handleUnsetMaximized()
if (!m_item->view()->isPrimary())
return;
- m_toplevel->sendUnmaximized(maximizeState.initialWindowSize);
+ // If no prior windowed size was recorded, send a 0x0 configure event
+ // to allow the client to choose its preferred size.
+ if (windowedGeometry.initialWindowSize.isValid())
+ m_toplevel->sendUnmaximized(windowedGeometry.initialWindowSize);
+ else
+ m_toplevel->sendUnmaximized();
}
void XdgToplevelV6Integration::handleMaximizedChanged()
@@ -146,7 +182,59 @@ void XdgToplevelV6Integration::handleMaximizedChanged()
QWaylandOutput *output = m_item->view()->output();
m_item->moveItem()->setPosition(output->position() + output->availableGeometry().topLeft());
} else {
- m_item->moveItem()->setPosition(maximizeState.initialPosition);
+ m_item->moveItem()->setPosition(windowedGeometry.initialPosition);
+ }
+}
+
+void XdgToplevelV6Integration::handleSetFullscreen()
+{
+ if (!m_item->view()->isPrimary())
+ return;
+
+ QVector<QWaylandXdgToplevelV6::State> states = m_toplevel->states();
+
+ if (!states.contains(QWaylandXdgToplevelV6::State::FullscreenState) && !states.contains(QWaylandXdgToplevelV6::State::MaximizedState)) {
+ windowedGeometry.initialWindowSize = m_xdgSurface->windowGeometry().size();
+ windowedGeometry.initialPosition = m_item->moveItem()->position();
+ }
+
+ // Any prior output-resize handlers are irrelevant at this point.
+ disconnect(nonwindowedState.sizeChangedConnection);
+ nonwindowedState.output = m_item->view()->output();
+ nonwindowedState.sizeChangedConnection = connect(nonwindowedState.output, &QWaylandOutput::geometryChanged, this, &XdgToplevelV6Integration::handleFullscreenSizeChanged);
+ handleFullscreenSizeChanged();
+}
+
+void XdgToplevelV6Integration::handleFullscreenSizeChanged()
+{
+ // Insurance against handleToplevelDestroyed() not managing to disconnect this
+ // handler in time.
+ if (m_toplevel == nullptr)
+ return;
+
+ m_toplevel->sendFullscreen(nonwindowedState.output->geometry().size() / nonwindowedState.output->scaleFactor());
+}
+
+void XdgToplevelV6Integration::handleUnsetFullscreen()
+{
+ if (!m_item->view()->isPrimary())
+ return;
+
+ // If no prior windowed size was recorded, send a 0x0 configure event
+ // to allow the client to choose its preferred size.
+ if (windowedGeometry.initialWindowSize.isValid())
+ m_toplevel->sendUnmaximized(windowedGeometry.initialWindowSize);
+ else
+ m_toplevel->sendUnmaximized();
+}
+
+void XdgToplevelV6Integration::handleFullscreenChanged()
+{
+ if (m_toplevel->fullscreen()) {
+ QWaylandOutput *output = m_item->view()->output();
+ m_item->moveItem()->setPosition(output->position() + output->geometry().topLeft());
+ } else {
+ m_item->moveItem()->setPosition(windowedGeometry.initialPosition);
}
}
@@ -170,6 +258,13 @@ void XdgToplevelV6Integration::handleSurfaceSizeChanged()
}
}
+void XdgToplevelV6Integration::handleToplevelDestroyed()
+{
+ // Disarm any handlers that might fire on the now-stale toplevel pointer
+ nonwindowedState.output = nullptr;
+ disconnect(nonwindowedState.sizeChangedConnection);
+}
+
XdgPopupV6Integration::XdgPopupV6Integration(QWaylandQuickShellSurfaceItem *item)
: m_item(item)
, m_xdgSurface(qobject_cast<QWaylandXdgSurfaceV6 *>(item->shellSurface()))
@@ -181,6 +276,9 @@ XdgPopupV6Integration::XdgPopupV6Integration(QWaylandQuickShellSurfaceItem *item
handleGeometryChanged();
connect(m_popup, &QWaylandXdgPopupV6::configuredGeometryChanged, this, &XdgPopupV6Integration::handleGeometryChanged);
+ connect(m_xdgSurface->shell(), &QWaylandXdgShellV6::popupCreated, this, [item](QWaylandXdgPopupV6 *popup, QWaylandXdgSurfaceV6 *){
+ handlePopupCreated(item, popup);
+ });
}
void XdgPopupV6Integration::handleGeometryChanged()
diff --git a/src/compositor/extensions/qwaylandxdgshellv6integration_p.h b/src/compositor/extensions/qwaylandxdgshellv6integration_p.h
index 4ccabfa98..5b56af89b 100644
--- a/src/compositor/extensions/qwaylandxdgshellv6integration_p.h
+++ b/src/compositor/extensions/qwaylandxdgshellv6integration_p.h
@@ -72,8 +72,14 @@ private Q_SLOTS:
void handleSetMaximized();
void handleUnsetMaximized();
void handleMaximizedChanged();
+ void handleSetFullscreen();
+ void handleUnsetFullscreen();
+ void handleFullscreenChanged();
void handleActivatedChanged();
void handleSurfaceSizeChanged();
+ void handleToplevelDestroyed();
+ void handleMaximizedSizeChanged();
+ void handleFullscreenSizeChanged();
private:
QWaylandQuickShellSurfaceItem *m_item = nullptr;
@@ -106,7 +112,14 @@ private:
struct {
QSize initialWindowSize;
QPointF initialPosition;
- } maximizeState;
+ } windowedGeometry;
+
+ struct {
+ QWaylandOutput *output = nullptr;
+ QMetaObject::Connection sizeChangedConnection; // Depending on whether maximized or fullscreen,
+ // will be hooked to geometry-changed or available-
+ // geometry-changed.
+ } nonwindowedState;
};
class XdgPopupV6Integration : public QWaylandQuickShellIntegration
diff --git a/src/compositor/extensions/qwlqtkey.cpp b/src/compositor/extensions/qwlqtkey.cpp
index 73d06ae6b..94a2b5a77 100644
--- a/src/compositor/extensions/qwlqtkey.cpp
+++ b/src/compositor/extensions/qwlqtkey.cpp
@@ -48,7 +48,7 @@ namespace QtWayland {
QtKeyExtensionGlobal::QtKeyExtensionGlobal(QWaylandCompositor *compositor)
: QWaylandCompositorExtensionTemplate(compositor)
- , QtWaylandServer::qt_key_extension(compositor->display(), 2)
+ , QtWaylandServer::zqt_key_v1(compositor->display(), 1)
, m_compositor(compositor)
{
}
@@ -60,15 +60,15 @@ bool QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, QWaylandSurface *sur
Resource *target = surface ? resourceMap().value(surface->waylandClient()) : 0;
if (target) {
- send_qtkey(target->handle,
- surface ? surface->resource() : nullptr,
- time, event->type(), event->key(), event->modifiers(),
- event->nativeScanCode(),
- event->nativeVirtualKey(),
- event->nativeModifiers(),
- event->text(),
- event->isAutoRepeat(),
- event->count());
+ send_key(target->handle,
+ surface ? surface->resource() : nullptr,
+ time, event->type(), event->key(), event->modifiers(),
+ event->nativeScanCode(),
+ event->nativeVirtualKey(),
+ event->nativeModifiers(),
+ event->text(),
+ event->isAutoRepeat(),
+ event->count());
return true;
}
diff --git a/src/compositor/extensions/qwlqtkey_p.h b/src/compositor/extensions/qwlqtkey_p.h
index d3f573757..4944829ef 100644
--- a/src/compositor/extensions/qwlqtkey_p.h
+++ b/src/compositor/extensions/qwlqtkey_p.h
@@ -53,7 +53,7 @@
#include <QtWaylandCompositor/QWaylandCompositorExtensionTemplate>
#include <QtWaylandCompositor/QWaylandCompositor>
-#include <QtWaylandCompositor/private/qwayland-server-qtkey-extension.h>
+#include <QtWaylandCompositor/private/qwayland-server-qt-key-unstable-v1.h>
#include <wayland-util.h>
@@ -64,7 +64,7 @@ class QKeyEvent;
namespace QtWayland {
-class QtKeyExtensionGlobal : public QWaylandCompositorExtensionTemplate<QtKeyExtensionGlobal>, public QtWaylandServer::qt_key_extension
+class QtKeyExtensionGlobal : public QWaylandCompositorExtensionTemplate<QtKeyExtensionGlobal>, public QtWaylandServer::zqt_key_v1
{
Q_OBJECT
public:
diff --git a/src/compositor/wayland_wrapper/qwlregion.cpp b/src/compositor/wayland_wrapper/qwlregion.cpp
index 040538411..52c19e946 100644
--- a/src/compositor/wayland_wrapper/qwlregion.cpp
+++ b/src/compositor/wayland_wrapper/qwlregion.cpp
@@ -54,7 +54,9 @@ Region::~Region()
Region *Region::fromResource(struct ::wl_resource *resource)
{
- return static_cast<Region *>(Resource::fromResource(resource)->region_object);
+ if (auto *r = Resource::fromResource(resource))
+ return static_cast<Region *>(r->region_object);
+ return nullptr;
}
void Region::region_destroy_resource(Resource *)
diff --git a/src/extensions/README.md b/src/extensions/README.md
new file mode 100644
index 000000000..f75e0f236
--- /dev/null
+++ b/src/extensions/README.md
@@ -0,0 +1,18 @@
+# Internal Qt protocol extensions
+
+The protocol extensions in this folder are considered implementation details of
+Qt. I.e. they may removed, renamed or changed without warning.
+
+## Suffixed protocols
+
+For protocols that have a version suffix, however, we will strive to not break
+backwards compatibility without bumping the suffix (renaming the protocol).
+E.g.: If your client sees a `zqt_key_v1` global, it can safely bind to it:
+the key event will always take the same number of arguments, regardless of
+compositor version.
+
+This is important also within a Qt-only scope if there are multiple versions of
+Qt on the system. Consider for instance an application statically linked to Qt
+(such as Qt Creator) running against a Qt compositor installed by the distro).
+In such cases we don't want the compositor and client to disagree on the
+protocol definition.
diff --git a/src/extensions/qtkey-extension.xml b/src/extensions/qt-key-unstable-v1.xml
index 34cf24797..0f8d8284c 100644
--- a/src/extensions/qtkey-extension.xml
+++ b/src/extensions/qt-key-unstable-v1.xml
@@ -1,7 +1,7 @@
-<protocol name="qtkey_extension">
+<protocol name="qt_key_unstable_v1">
<copyright>
- Copyright (C) 2015 The Qt Company Ltd.
+ Copyright (C) 2018 The Qt Company Ltd.
Contact: http://www.qt.io/licensing/
This file is part of the plugins of the Qt Toolkit.
@@ -38,26 +38,36 @@
$QT_END_LICENSE$
</copyright>
- <interface name="qt_key_extension" version="2">
- <event name="qtkey">
- <description summary="qtkey event">
- Serialized QKeyEvent
- </description>
-
- <arg name="surface" type="object" interface="wl_surface"/>
- <arg name="time" type="uint"/>
- <arg name="type" type="uint"/>
- <arg name="key" type="uint"/>
- <arg name="modifiers" type="uint"/>
- <arg name="nativeScanCode" type="uint"/>
- <arg name="nativeVirtualKey" type="uint"/>
- <arg name="nativeModifiers" type="uint"/>
- <arg name="text" type="string"/>
- <arg name="autorepeat" type="uint"/>
- <arg name="count" type="uint"/>
- </event>
+ <interface name="zqt_key_v1" version="1">
+ <description summary="send serialized QKeyEvents">
+ This protocol is independent of the Wayland seat concept. Its
+ intention is to let a QKeyEvent be transferred from a Qt compositor
+ to a Qt client without losing or adding false information by going
+ through wl_seat and wl_keyboard.
- <request name="dummy">
- </request>
+ Note: This protocol is considered private to Qt. We will do our
+ best to bump version numbers when we make backwards compatible
+ changes, bump the protocol name and interface suffixes when we make
+ backwards incompatible changes, but we provide no guarantees. We
+ may also remove the protocol without warning. Implement this at
+ your own risk.
+ </description>
+ <event name="key">
+ <description summary="send key event">
+ The key event notifies the client that a QKeyEvent has occurred on
+ the server side.
+ </description>
+ <arg name="surface" type="object" interface="wl_surface"/>
+ <arg name="time" type="uint"/>
+ <arg name="type" type="uint"/>
+ <arg name="key" type="uint"/>
+ <arg name="modifiers" type="uint"/>
+ <arg name="nativeScanCode" type="uint"/>
+ <arg name="nativeVirtualKey" type="uint"/>
+ <arg name="nativeModifiers" type="uint"/>
+ <arg name="text" type="string"/>
+ <arg name="autorepeat" type="uint"/>
+ <arg name="count" type="uint"/>
+ </event>
</interface>
</protocol>
diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp
index 4478b9fdf..cd0f285cd 100644
--- a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp
+++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp
@@ -124,6 +124,33 @@ EGLDisplay QWaylandBrcmEglIntegration::eglDisplay() const
return m_eglDisplay;
}
+void *QWaylandBrcmEglIntegration::nativeResource(NativeResource resource)
+{
+ switch (resource) {
+ case EglDisplay:
+ return m_eglDisplay;
+ default:
+ break;
+ }
+ return nullptr;
+}
+
+void *QWaylandBrcmEglIntegration::nativeResourceForContext(NativeResource resource, QPlatformOpenGLContext *context)
+{
+ Q_ASSERT(context);
+ switch (resource) {
+ case EglConfig:
+ return static_cast<QWaylandBrcmGLContext *>(context)->eglConfig();
+ case EglContext:
+ return static_cast<QWaylandBrcmGLContext *>(context)->eglContext();
+ case EglDisplay:
+ return m_eglDisplay;
+ default:
+ break;
+ }
+ return nullptr;
+}
+
}
QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h
index 651400d87..5e8a3bf46 100644
--- a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h
+++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h
@@ -82,6 +82,9 @@ public:
PFNEGLCREATEGLOBALIMAGEBRCMPROC eglCreateGlobalImageBRCM;
PFNEGLDESTROYGLOBALIMAGEBRCMPROC eglDestroyGlobalImageBRCM;
+ void *nativeResource(NativeResource resource) override;
+ void *nativeResourceForContext(NativeResource resource, QPlatformOpenGLContext *context) override;
+
private:
static void wlDisplayHandleGlobal(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version);
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
index 3b9001475..e2b131964 100644
--- a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
@@ -62,7 +62,7 @@ QWaylandEglWindow::QWaylandEglWindow(QWindow *window)
if (mDisplay->supportsWindowDecoration())
fmt.setAlphaBufferSize(8);
m_eglConfig = q_configFromGLFormat(m_clientBufferIntegration->eglDisplay(), fmt);
- m_format = q_glFormatFromConfig(m_clientBufferIntegration->eglDisplay(), m_eglConfig);
+ m_format = q_glFormatFromConfig(m_clientBufferIntegration->eglDisplay(), m_eglConfig, fmt);
// Do not create anything from here. This platform window may belong to a
// RasterGLSurface window which may have pure raster content. In this case, where the
@@ -133,13 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
m_resize = true;
}
- } else if (create) {
- m_waylandEglWindow = wl_egl_window_create(object(), sizeWithMargins.width(), sizeWithMargins.height());
+ } else if (create && wl_surface::isInitialized()) {
+ ::wl_surface *wlSurface = wl_surface::object();
+ m_waylandEglWindow = wl_egl_window_create(wlSurface, sizeWithMargins.width(), sizeWithMargins.height());
}
- if (!m_eglSurface && create) {
+ if (!m_eglSurface && m_waylandEglWindow && create) {
EGLNativeWindowType eglw = (EGLNativeWindowType) m_waylandEglWindow;
m_eglSurface = eglCreateWindowSurface(m_clientBufferIntegration->eglDisplay(), m_eglConfig, eglw, 0);
+ if (Q_UNLIKELY(m_eglSurface == EGL_NO_SURFACE))
+ qCWarning(lcQpaWayland, "Could not create EGL surface (EGL error 0x%x)\n", eglGetError);
}
}
}
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
index 6e48659da..4f2aa8af5 100644
--- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
@@ -234,7 +234,7 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, QWaylandDisplay *dis
if (static_cast<QWaylandIntegration *>(QGuiApplicationPrivate::platformIntegration())->display()->supportsWindowDecoration())
fmt.setAlphaBufferSize(8);
m_config = q_configFromGLFormat(m_eglDisplay, fmt);
- m_format = q_glFormatFromConfig(m_eglDisplay, m_config);
+ m_format = q_glFormatFromConfig(m_eglDisplay, m_config, fmt);
m_shareEGLContext = share ? static_cast<QWaylandGLContext *>(share)->eglContext() : EGL_NO_CONTEXT;
QVector<EGLint> eglContextAttrs;
@@ -412,7 +412,7 @@ bool QWaylandGLContext::makeCurrent(QPlatformSurface *surface)
window->createDecoration();
if (eglSurface == EGL_NO_SURFACE) {
- window->updateSurface(window->isExposed());
+ window->updateSurface(true);
eglSurface = window->eglSurface();
}
diff --git a/src/imports/compositor/WaylandCursorItem.qml b/src/imports/compositor/WaylandCursorItem.qml
index 0f5b289e1..331784109 100644
--- a/src/imports/compositor/WaylandCursorItem.qml
+++ b/src/imports/compositor/WaylandCursorItem.qml
@@ -39,28 +39,32 @@
import QtQuick 2.0
import QtWayland.Compositor 1.0
+import QtQuick.Window 2.11
WaylandQuickItem {
id: cursorItem
property QtObject seat
property int hotspotX: 0
property int hotspotY: 0
+ // If we've set an output scale factor different from the device pixel ratio
+ // then the item will be rendered scaled, so we need to shift the hotspot accordingly
+ property real scaleCorrection: output ? output.scaleFactor / Screen.devicePixelRatio : 1
visible: cursorItem.surface != null
inputEventsEnabled: false
enabled: false
- transform: Translate { x: -hotspotX; y: -hotspotY }
-
- onSeatChanged: {
- if (!seat)
- return;
- seat.cursorSurfaceRequest.connect(setCursorSurface);
+ transform: Translate {
+ x: -hotspotX * scaleCorrection
+ y: -hotspotY * scaleCorrection
}
- function setCursorSurface(surface, hotspotX, hotspotY) {
- cursorItem.surface = surface;
- cursorItem.hotspotX = hotspotX;
- cursorItem.hotspotY = hotspotY;
+ Connections {
+ target: seat
+ onCursorSurfaceRequest: {
+ cursorItem.surface = surface;
+ cursorItem.hotspotX = hotspotX;
+ cursorItem.hotspotY = hotspotY;
+ }
}
WaylandQuickItem {
diff --git a/src/imports/compositor/qwaylandquickcompositorplugin.cpp b/src/imports/compositor/qwaylandquickcompositorplugin.cpp
index e877f6927..1c576b6a1 100644
--- a/src/imports/compositor/qwaylandquickcompositorplugin.cpp
+++ b/src/imports/compositor/qwaylandquickcompositorplugin.cpp
@@ -63,6 +63,8 @@
#include <QtWaylandCompositor/QWaylandTextInputManager>
#include <QtWaylandCompositor/QWaylandXdgShellV5>
#include <QtWaylandCompositor/QWaylandXdgShellV6>
+#include <QtWaylandCompositor/QWaylandXdgShell>
+#include <QtWaylandCompositor/QWaylandXdgDecorationManagerV1>
#include <QtWaylandCompositor/QWaylandIviApplication>
#include <QtWaylandCompositor/QWaylandIviSurface>
@@ -77,6 +79,8 @@ Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandIviApplication)
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandWlShell)
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandXdgShellV5)
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandXdgShellV6)
+Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandXdgShell)
+Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandXdgDecorationManagerV1)
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandTextInputManager)
class QmlUrlResolver
@@ -162,6 +166,13 @@ public:
qmlRegisterType<QWaylandXdgSurfaceV6>(uri, 1, 1, "XdgSurfaceV6");
qmlRegisterUncreatableType<QWaylandXdgToplevelV6>(uri, 1, 1, "XdgToplevelV6", QObject::tr("Cannot create instance of XdgShellToplevelV6"));
qmlRegisterUncreatableType<QWaylandXdgPopupV6>(uri, 1, 1, "XdgPopupV6", QObject::tr("Cannot create instance of XdgShellPopupV6"));
+
+ qmlRegisterType<QWaylandXdgShellQuickExtension>(uri, 1, 3, "XdgShell");
+ qmlRegisterType<QWaylandXdgSurface>(uri, 1, 3, "XdgSurface");
+ qmlRegisterUncreatableType<QWaylandXdgToplevel>(uri, 1, 3, "XdgToplevel", QObject::tr("Cannot create instance of XdgShellToplevel"));
+ qmlRegisterUncreatableType<QWaylandXdgPopup>(uri, 1, 3, "XdgPopup", QObject::tr("Cannot create instance of XdgShellPopup"));
+
+ qmlRegisterType<QWaylandXdgDecorationManagerV1QuickExtension>(uri, 1, 3, "XdgDecorationManagerV1");
}
};
//![class decl]
diff --git a/src/plugins/decorations/bradient/main.cpp b/src/plugins/decorations/bradient/main.cpp
index 9a7e91e6f..3fa723446 100644
--- a/src/plugins/decorations/bradient/main.cpp
+++ b/src/plugins/decorations/bradient/main.cpp
@@ -55,72 +55,8 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
#define BUTTON_SPACING 5
-
-#if QT_CONFIG(imageformat_xpm)
-# define BUTTON_WIDTH 10
-
-static const char * const qt_close_xpm[] = {
-"10 10 2 1",
-"# c #000000",
-". c None",
-"..........",
-".##....##.",
-"..##..##..",
-"...####...",
-"....##....",
-"...####...",
-"..##..##..",
-".##....##.",
-"..........",
-".........."};
-
-static const char * const qt_maximize_xpm[]={
-"10 10 2 1",
-"# c #000000",
-". c None",
-"#########.",
-"#########.",
-"#.......#.",
-"#.......#.",
-"#.......#.",
-"#.......#.",
-"#.......#.",
-"#.......#.",
-"#########.",
-".........."};
-
-static const char * const qt_minimize_xpm[] = {
-"10 10 2 1",
-"# c #000000",
-". c None",
-"..........",
-"..........",
-"..........",
-"..........",
-"..........",
-"..........",
-"..........",
-".#######..",
-".#######..",
-".........."};
-
-static const char * const qt_normalizeup_xpm[] = {
-"10 10 2 1",
-"# c #000000",
-". c None",
-"...######.",
-"...######.",
-"...#....#.",
-".######.#.",
-".######.#.",
-".#....###.",
-".#....#...",
-".#....#...",
-".######...",
-".........."};
-#else
-# define BUTTON_WIDTH 22
-#endif
+#define BUTTON_WIDTH 18
+#define BUTTONS_RIGHT_MARGIN 8
enum Button
{
@@ -151,6 +87,7 @@ private:
QRectF minimizeButtonRect() const;
QColor m_foregroundColor;
+ QColor m_foregroundInactiveColor;
QColor m_backgroundColor;
QStaticText m_windowTitle;
Button m_clicking = None;
@@ -161,8 +98,9 @@ private:
QWaylandBradientDecoration::QWaylandBradientDecoration()
{
QPalette palette;
- m_foregroundColor = palette.color(QPalette::Active, QPalette::HighlightedText);
- m_backgroundColor = palette.color(QPalette::Active, QPalette::Highlight);
+ m_foregroundColor = palette.color(QPalette::Active, QPalette::WindowText);
+ m_backgroundColor = palette.color(QPalette::Active, QPalette::Window);
+ m_foregroundInactiveColor = palette.color(QPalette::Disabled, QPalette::WindowText);
QTextOption option(Qt::AlignHCenter | Qt::AlignVCenter);
option.setWrapMode(QTextOption::NoWrap);
@@ -171,19 +109,19 @@ QWaylandBradientDecoration::QWaylandBradientDecoration()
QRectF QWaylandBradientDecoration::closeButtonRect() const
{
- return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH - BUTTON_SPACING * 2,
+ return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH - BUTTON_SPACING * 0 - BUTTONS_RIGHT_MARGIN,
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
}
QRectF QWaylandBradientDecoration::maximizeButtonRect() const
{
- return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH * 2 - BUTTON_SPACING * 3,
+ return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH * 2 - BUTTON_SPACING * 1 - BUTTONS_RIGHT_MARGIN,
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
}
QRectF QWaylandBradientDecoration::minimizeButtonRect() const
{
- return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH * 3 - BUTTON_SPACING * 4,
+ return QRectF(window()->frameGeometry().width() - BUTTON_WIDTH * 3 - BUTTON_SPACING * 2 - BUTTONS_RIGHT_MARGIN,
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
}
@@ -194,6 +132,7 @@ QMargins QWaylandBradientDecoration::margins() const
void QWaylandBradientDecoration::paint(QPaintDevice *device)
{
+ bool active = window()->handle()->isActive();
QRect surfaceRect(QPoint(), window()->frameGeometry().size());
QRect clips[] =
{
@@ -209,16 +148,12 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
p.setRenderHint(QPainter::Antialiasing);
// Title bar
- QLinearGradient grad(top.topLeft(), top.bottomLeft());
- QColor base(m_backgroundColor);
- grad.setColorAt(0, base.lighter(100));
- grad.setColorAt(1, base.darker(180));
QPainterPath roundedRect;
- roundedRect.addRoundedRect(surfaceRect, 6, 6);
+ roundedRect.addRoundedRect(surfaceRect, 3, 3);
for (int i = 0; i < 4; ++i) {
p.save();
p.setClipRect(clips[i]);
- p.fillPath(roundedRect, grad);
+ p.fillPath(roundedRect, m_backgroundColor);
p.restore();
}
@@ -249,12 +184,12 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
p.save();
p.setClipRect(titleBar);
- p.setPen(m_foregroundColor);
+ p.setPen(active ? m_foregroundColor : m_foregroundInactiveColor);
QSizeF size = m_windowTitle.size();
int dx = (top.width() - size.width()) /2;
int dy = (top.height()- size.height()) /2;
QFont font = p.font();
- font.setBold(true);
+ font.setPixelSize(14);
p.setFont(font);
QPoint windowTitlePoint(top.topLeft().x() + dx,
top.topLeft().y() + dy);
@@ -262,38 +197,16 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
p.restore();
}
-#if QT_CONFIG(imageformat_xpm)
- p.save();
-
- // Close button
- QPixmap closePixmap(qt_close_xpm);
- p.drawPixmap(closeButtonRect(), closePixmap, closePixmap.rect());
-
- // Maximize button
- QPixmap maximizePixmap(waylandWindow()->isMaximized()
- ? qt_normalizeup_xpm : qt_maximize_xpm);
- p.drawPixmap(maximizeButtonRect(), maximizePixmap, maximizePixmap.rect());
-
- // Minimize button
- QPixmap minimizePixmap(qt_minimize_xpm);
- p.drawPixmap(minimizeButtonRect(), minimizePixmap, minimizePixmap.rect());
-
- p.restore();
-#else
- // We don't need antialiasing from now on
- p.setRenderHint(QPainter::Antialiasing, false);
-
QRectF rect;
// Default pen
- QPen pen(m_foregroundColor);
+ QPen pen(active ? m_foregroundColor : m_foregroundInactiveColor);
p.setPen(pen);
// Close button
p.save();
rect = closeButtonRect();
- p.drawRect(rect);
- qreal crossSize = rect.height() / 2;
+ qreal crossSize = rect.height() / 2.3;
QPointF crossCenter(rect.center());
QRectF crossRect(crossCenter.x() - crossSize / 2, crossCenter.y() - crossSize / 2, crossSize, crossSize);
pen.setWidth(2);
@@ -304,15 +217,16 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
// Maximize button
p.save();
- p.drawRect(maximizeButtonRect());
- rect = maximizeButtonRect().adjusted(5, 5, -5, -5);
- if (waylandWindow()->isMaximized()) {
- QRectF rect1 = rect.adjusted(rect.width() / 3, 0, 0, -rect.height() / 3);
- QRectF rect2 = rect.adjusted(0, rect.height() / 4, -rect.width() / 4, 0);
+ p.setRenderHint(QPainter::Antialiasing, false);
+ rect = maximizeButtonRect().adjusted(4, 5, -4, -5);
+ if ((window()->windowStates() & Qt::WindowMaximized)) {
+ qreal inset = 2;
+ QRectF rect1 = rect.adjusted(inset, 0, 0, -inset);
+ QRectF rect2 = rect.adjusted(0, inset, -inset, 0);
p.drawRect(rect1);
+ p.setBrush(m_backgroundColor); // need to cover up some lines from the other rect
p.drawRect(rect2);
} else {
- p.setPen(m_foregroundColor);
p.drawRect(rect);
p.drawLine(rect.left(), rect.top() + 1, rect.right(), rect.top() + 1);
}
@@ -320,13 +234,12 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
// Minimize button
p.save();
- p.drawRect(minimizeButtonRect());
+ p.setRenderHint(QPainter::Antialiasing, false);
rect = minimizeButtonRect().adjusted(5, 5, -5, -5);
pen.setWidth(2);
p.setPen(pen);
p.drawLine(rect.bottomLeft(), rect.bottomRight());
p.restore();
-#endif
}
bool QWaylandBradientDecoration::clickButton(Qt::MouseButtons b, Button btn)
@@ -351,16 +264,7 @@ bool QWaylandBradientDecoration::handleMouse(QWaylandInputDevice *inputDevice, c
Q_UNUSED(global);
// Figure out what area mouse is in
- if (closeButtonRect().contains(local)) {
- if (clickButton(b, Close))
- QWindowSystemInterface::handleCloseEvent(window());
- } else if (maximizeButtonRect().contains(local)) {
- if (clickButton(b, Maximize))
- window()->setWindowState(waylandWindow()->isMaximized() ? Qt::WindowNoState : Qt::WindowMaximized);
- } else if (minimizeButtonRect().contains(local)) {
- if (clickButton(b, Minimize))
- window()->setWindowState(Qt::WindowMinimized);
- } else if (local.y() <= margins().top()) {
+ if (local.y() <= margins().top()) {
processMouseTop(inputDevice,local,b,mods);
} else if (local.y() > window()->height() + margins().top()) {
processMouseBottom(inputDevice,local,b,mods);
@@ -390,7 +294,7 @@ bool QWaylandBradientDecoration::handleTouch(QWaylandInputDevice *inputDevice, c
if (closeButtonRect().contains(local))
QWindowSystemInterface::handleCloseEvent(window());
else if (maximizeButtonRect().contains(local))
- window()->setWindowState(waylandWindow()->isMaximized() ? Qt::WindowNoState : Qt::WindowMaximized);
+ window()->setWindowStates(window()->windowStates() ^ Qt::WindowMaximized);
else if (minimizeButtonRect().contains(local))
window()->setWindowState(Qt::WindowMinimized);
else if (local.y() <= margins().top())
@@ -419,19 +323,31 @@ void QWaylandBradientDecoration::processMouseTop(QWaylandInputDevice *inputDevic
#endif
startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_TOP_RIGHT,b);
} else {
- //top reszie bit
+ //top resize bit
#if QT_CONFIG(cursor)
waylandWindow()->setMouseCursor(inputDevice, Qt::SplitVCursor);
#endif
startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_TOP,b);
}
+ } else if (local.x() <= margins().left()) {
+ processMouseLeft(inputDevice, local, b, mods);
+ } else if (local.x() > window()->width() + margins().left()) {
+ processMouseRight(inputDevice, local, b, mods);
+ } else if (closeButtonRect().contains(local)) {
+ if (clickButton(b, Close))
+ QWindowSystemInterface::handleCloseEvent(window());
+ } else if (maximizeButtonRect().contains(local)) {
+ if (clickButton(b, Maximize))
+ window()->setWindowStates(window()->windowStates() ^ Qt::WindowMaximized);
+ } else if (minimizeButtonRect().contains(local)) {
+ if (clickButton(b, Minimize))
+ window()->setWindowState(Qt::WindowMinimized);
} else {
#if QT_CONFIG(cursor)
waylandWindow()->restoreMouseCursor(inputDevice);
#endif
startMove(inputDevice,b);
}
-
}
void QWaylandBradientDecoration::processMouseBottom(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp
index 14074625a..efb61dc9f 100644
--- a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp
+++ b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp
@@ -58,18 +58,21 @@ QWaylandIviShellIntegration::QWaylandIviShellIntegration()
{
}
-QWaylandIviShellIntegration::~QWaylandIviShellIntegration()
-{
- delete m_iviApplication;
- delete m_iviController;
-}
-
bool QWaylandIviShellIntegration::initialize(QWaylandDisplay *display)
{
- QWaylandShellIntegration::initialize(display);
- display->addRegistryListener(registryIvi, this);
+ for (QWaylandDisplay::RegistryGlobal global : display->globals()) {
+ if (global.interface == QLatin1String("ivi_application") && !m_iviApplication)
+ m_iviApplication.reset(new QtWayland::ivi_application(display->wl_registry(), global.id, global.version));
+ if (global.interface == QLatin1String("ivi_controller") && !m_iviController)
+ m_iviController.reset(new QtWayland::ivi_controller(display->wl_registry(), global.id, global.version));
+ }
+
+ if (!m_iviApplication) {
+ qCDebug(lcQpaWayland) << "Couldn't find global ivi_application for ivi-shell";
+ return false;
+ }
- return true;
+ return QWaylandShellIntegration::initialize(display);
}
/* get unique id
@@ -154,21 +157,6 @@ QWaylandShellSurface *QWaylandIviShellIntegration::createShellSurface(QWaylandWi
return iviSurface;
}
-void QWaylandIviShellIntegration::registryIvi(void *data,
- struct wl_registry *registry,
- uint32_t id,
- const QString &interface,
- uint32_t version)
-{
- QWaylandIviShellIntegration *shell = static_cast<QWaylandIviShellIntegration *>(data);
-
- if (interface == QStringLiteral("ivi_application"))
- shell->m_iviApplication = new QtWayland::ivi_application(registry, id, version);
-
- if (interface == QStringLiteral("ivi_controller"))
- shell->m_iviController = new QtWayland::ivi_controller(registry, id, version);
-}
-
}
QT_END_NAMESPACE
diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h
index 11a2ae99b..fc16d2f64 100644
--- a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h
+++ b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h
@@ -58,18 +58,16 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandIviShellIntegration : public QWaylandShell
{
public:
QWaylandIviShellIntegration();
- ~QWaylandIviShellIntegration() override;
+
bool initialize(QWaylandDisplay *display) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
private:
- static void registryIvi(void *data, struct wl_registry *registry,
- uint32_t id, const QString &interface, uint32_t version);
uint32_t getNextUniqueSurfaceId();
private:
- QtWayland::ivi_application *m_iviApplication = nullptr;
- QtWayland::ivi_controller *m_iviController = nullptr;
+ QScopedPointer<QtWayland::ivi_application> m_iviApplication;
+ QScopedPointer<QtWayland::ivi_controller> m_iviController;
uint32_t m_lastSurfaceId = 0;
uint32_t m_surfaceNumber = 0;
bool m_useEnvSurfaceId = false;
diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp
index ec529b124..10d308ba4 100644
--- a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp
+++ b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp
@@ -75,11 +75,9 @@ QWaylandIviSurface::~QWaylandIviSurface()
delete m_extendedWindow;
}
-void QWaylandIviSurface::setType(Qt::WindowType type, QWaylandWindow *transientParent)
+void QWaylandIviSurface::applyConfigure()
{
-
- Q_UNUSED(type)
- Q_UNUSED(transientParent)
+ m_window->resizeFromApplyConfigure(m_pendingSize);
}
void QWaylandIviSurface::createExtendedSurface(QWaylandWindow *window)
@@ -90,7 +88,8 @@ void QWaylandIviSurface::createExtendedSurface(QWaylandWindow *window)
void QWaylandIviSurface::ivi_surface_configure(int32_t width, int32_t height)
{
- this->m_window->configure(0, width, height);
+ m_pendingSize = {width, height};
+ m_window->applyConfigureWhenPossible();
}
void QWaylandIviSurface::ivi_controller_surface_visibility(int32_t visibility)
diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h
index ff943060b..f207f0584 100644
--- a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h
+++ b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h
@@ -62,7 +62,7 @@ public:
struct ::ivi_controller_surface *iviControllerSurface);
~QWaylandIviSurface() override;
- void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
+ void applyConfigure() override;
private:
void createExtendedSurface(QWaylandWindow *window);
@@ -71,6 +71,7 @@ private:
QWaylandWindow *m_window = nullptr;
QWaylandExtendedSurface *m_extendedWindow = nullptr;
+ QSize m_pendingSize = {0, 0};
};
}
diff --git a/src/plugins/shellintegration/shellintegration.pro b/src/plugins/shellintegration/shellintegration.pro
index 9867d2b40..48b6efa36 100644
--- a/src/plugins/shellintegration/shellintegration.pro
+++ b/src/plugins/shellintegration/shellintegration.pro
@@ -1,3 +1,9 @@
TEMPLATE = subdirs
-SUBDIRS += ivi-shell
+SUBDIRS += \
+ ivi-shell \
+ xdg-shell \
+ xdg-shell-v5 \
+ xdg-shell-v6 \
+ wl-shell \
+
diff --git a/src/plugins/shellintegration/wl-shell/main.cpp b/src/plugins/shellintegration/wl-shell/main.cpp
new file mode 100644
index 000000000..9b033b5f3
--- /dev/null
+++ b/src/plugins/shellintegration/wl-shell/main.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2017 ITAGE Corporation, author: <yusuke.binsaki@itage.co.jp>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandwlshellintegration_p.h"
+
+#include <QtWaylandClient/private/qwaylandshellintegrationplugin_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class QWaylandWlShellIntegrationPlugin : public QWaylandShellIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QWaylandShellIntegrationFactoryInterface_iid FILE "wl-shell.json")
+
+public:
+ QWaylandShellIntegration *create(const QString &key, const QStringList &paramList) override;
+};
+
+QWaylandShellIntegration *QWaylandWlShellIntegrationPlugin::create(const QString &key, const QStringList &paramList)
+{
+ Q_UNUSED(key);
+ Q_UNUSED(paramList);
+ return new QWaylandWlShellIntegration();
+}
+
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/client/qwaylandwlshellintegration.cpp b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp
index 81c46be29..008da3d8a 100644
--- a/src/client/qwaylandwlshellintegration.cpp
+++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp
@@ -38,43 +38,54 @@
****************************************************************************/
#include "qwaylandwlshellintegration_p.h"
+#include "qwaylandwlshellsurface_p.h"
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
-#include <QtWaylandClient/private/qwaylandwlshellsurface_p.h>
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-QWaylandWlShellIntegration *QWaylandWlShellIntegration::create(QWaylandDisplay *display)
+bool QWaylandWlShellIntegration::initialize(QWaylandDisplay *display)
{
- if (display->hasRegistryGlobal(QLatin1String("wl_shell")))
- return new QWaylandWlShellIntegration(display);
- return nullptr;
-}
+ qCWarning(lcQpaWayland) << "\"wl-shell\" is a deprecated shell extension, prefer using"
+ << "\"xdg-shell-v6\" or \"xdg-shell\" if supported by the compositor"
+ << "by setting the environment variable QT_WAYLAND_SHELL_INTEGRATION";
-QWaylandWlShellIntegration::QWaylandWlShellIntegration(QWaylandDisplay *display)
-{
Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) {
if (global.interface == QLatin1String("wl_shell")) {
m_wlShell = new QtWayland::wl_shell(display->wl_registry(), global.id, 1);
break;
}
}
-}
-bool QWaylandWlShellIntegration::initialize(QWaylandDisplay *display)
-{
- QWaylandShellIntegration::initialize(display);
- return m_wlShell != nullptr;
-};
+ if (!m_wlShell) {
+ qCDebug(lcQpaWayland) << "Couldn't find global wl_shell";
+ return false;
+ }
+
+ return QWaylandShellIntegration::initialize(display);
+}
QWaylandShellSurface *QWaylandWlShellIntegration::createShellSurface(QWaylandWindow *window)
{
return new QWaylandWlShellSurface(m_wlShell->get_shell_surface(window->object()), window);
}
+void *QWaylandWlShellIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
+{
+ QByteArray lowerCaseResource = resource.toLower();
+ if (lowerCaseResource == "wl_shell_surface") {
+ if (auto waylandWindow = static_cast<QWaylandWindow *>(window->handle())) {
+ if (auto shellSurface = qobject_cast<QWaylandWlShellSurface *>(waylandWindow->shellSurface())) {
+ return shellSurface->object();
+ }
+ }
+ }
+ return nullptr;
}
+} // namespace QtWaylandClient
+
QT_END_NAMESPACE
diff --git a/src/client/qwaylandwlshellintegration_p.h b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration_p.h
index 7a6b53524..80a7507d4 100644
--- a/src/client/qwaylandwlshellintegration_p.h
+++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration_p.h
@@ -63,13 +63,12 @@ namespace QtWaylandClient {
class Q_WAYLAND_CLIENT_EXPORT QWaylandWlShellIntegration : public QWaylandShellIntegration
{
public:
- static QWaylandWlShellIntegration *create(QWaylandDisplay* display);
+ QWaylandWlShellIntegration() {}
bool initialize(QWaylandDisplay *) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+ void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) override;
private:
- QWaylandWlShellIntegration(QWaylandDisplay* display);
-
QtWayland::wl_shell *m_wlShell = nullptr;
};
diff --git a/src/client/qwaylandwlshellsurface.cpp b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp
index 098eddcbc..d9bc83059 100644
--- a/src/client/qwaylandwlshellsurface.cpp
+++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp
@@ -39,12 +39,12 @@
#include "qwaylandwlshellsurface_p.h"
-#include "qwaylanddisplay_p.h"
-#include "qwaylandwindow_p.h"
-#include "qwaylandinputdevice_p.h"
-#include "qwaylandabstractdecoration_p.h"
-#include "qwaylandscreen_p.h"
-#include "qwaylandextendedsurface_p.h"
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
+#include <QtWaylandClient/private/qwaylandabstractdecoration_p.h>
+#include <QtWaylandClient/private/qwaylandscreen_p.h>
+#include <QtWaylandClient/private/qwaylandextendedsurface_p.h>
#include <QtCore/QDebug>
@@ -59,6 +59,15 @@ QWaylandWlShellSurface::QWaylandWlShellSurface(struct ::wl_shell_surface *shell_
{
if (window->display()->windowExtension())
m_extendedWindow = new QWaylandExtendedSurface(window);
+
+ Qt::WindowType type = window->window()->type();
+ auto *transientParent = window->transientParent();
+ if (type == Qt::Popup && transientParent && transientParent->object())
+ setPopup(transientParent, m_window->display()->lastInputDevice(), m_window->display()->lastInputSerial());
+ else if (transientParent && transientParent->object())
+ updateTransientParent(transientParent->window());
+ else
+ setTopLevel();
}
QWaylandWlShellSurface::~QWaylandWlShellSurface()
@@ -121,35 +130,70 @@ void QWaylandWlShellSurface::sendProperty(const QString &name, const QVariant &v
m_extendedWindow->updateGenericProperty(name, value);
}
-void QWaylandWlShellSurface::setMaximized()
+void QWaylandWlShellSurface::applyConfigure()
{
- m_maximized = true;
- m_size = m_window->window()->geometry().size();
- set_maximized(nullptr);
+ if ((m_pending.states & (Qt::WindowMaximized|Qt::WindowFullScreen))
+ && !(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen))) {
+ m_normalSize = m_window->window()->frameGeometry().size();
+ }
+
+ if (m_pending.states != m_applied.states)
+ m_window->handleWindowStatesChanged(m_pending.states);
+
+ if (!m_pending.size.isEmpty()) {
+ int x = 0;
+ int y = 0;
+ if (m_pending.edges & resize_left)
+ x = m_applied.size.width() - m_pending.size.width();
+ if (m_pending.edges & resize_top)
+ y = m_applied.size.height() - m_pending.size.height();
+ QPoint offset(x, y);
+ m_window->resizeFromApplyConfigure(m_pending.size, offset);
+ } else if (m_pending.size.isValid() && !m_normalSize.isEmpty()) {
+ m_window->resizeFromApplyConfigure(m_normalSize);
+ }
+
+ m_applied = m_pending;
}
-void QWaylandWlShellSurface::setFullscreen()
+bool QWaylandWlShellSurface::wantsDecorations() const
{
- m_fullscreen = true;
- m_size = m_window->window()->geometry().size();
- set_fullscreen(WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, nullptr);
+ return !(m_pending.states & Qt::WindowFullScreen);
}
-void QWaylandWlShellSurface::setNormal()
+void QWaylandWlShellSurface::requestWindowStates(Qt::WindowStates states)
{
- if (m_fullscreen || m_maximized) {
- m_fullscreen = m_maximized = false;
- setTopLevel();
- QMargins m = m_window->frameMargins();
- m_window->configure(0, m_size.width() + m.left() + m.right(), m_size.height() + m.top() + m.bottom());
+ // On wl-shell the client is in charge of states, so diff from the pending state
+ Qt::WindowStates changedStates = m_pending.states ^ states;
+ Qt::WindowStates addedStates = changedStates & states;
+
+ if (addedStates & Qt::WindowMinimized)
+ qCWarning(lcQpaWayland) << "Minimizing is not supported on wl-shell. Consider using xdg-shell instead.";
+
+ if (addedStates & Qt::WindowMaximized) {
+ set_maximized(nullptr);
+ m_window->applyConfigureWhenPossible();
}
-}
-void QWaylandWlShellSurface::setMinimized()
-{
- qCWarning(lcQpaWayland) << "Minimization is not supported on wl-shell. Consider using xdg-shell instead.";
+ if (addedStates & Qt::WindowFullScreen) {
+ set_fullscreen(WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, nullptr);
+ m_window->applyConfigureWhenPossible();
+ }
+
+ bool isNormal = ~states & (Qt::WindowMaximized | Qt::WindowFullScreen);
+ if (isNormal && (changedStates & (Qt::WindowMaximized | Qt::WindowFullScreen))) {
+ setTopLevel(); // set normal window
+ // There's usually no configure event after this, so just clear the rest of the pending
+ // configure here and queue the applyConfigure call
+ m_pending.size = {0, 0};
+ m_pending.edges = resize_none;
+ m_window->applyConfigureWhenPossible();
+ }
+
+ m_pending.states = states & ~Qt::WindowMinimized;
}
+
void QWaylandWlShellSurface::setTopLevel()
{
set_toplevel();
@@ -194,11 +238,11 @@ void QWaylandWlShellSurface::setPopup(QWaylandWindow *parent, QWaylandInputDevic
{
QWaylandWindow *parent_wayland_window = parent;
if (!parent_wayland_window) {
- qWarning("setPopup called without parent window");
+ qCWarning(lcQpaWayland) << "setPopup called without a parent window";
return;
}
if (!device) {
- qWarning("setPopup called without input device");
+ qCWarning(lcQpaWayland) << "setPopup called without an input device";
return;
}
@@ -215,26 +259,18 @@ void QWaylandWlShellSurface::setPopup(QWaylandWindow *parent, QWaylandInputDevic
transientPos.x(), transientPos.y(), 0);
}
-void QWaylandWlShellSurface::setType(Qt::WindowType type, QWaylandWindow *transientParent)
-{
- if (type == Qt::Popup && transientParent && transientParent->object())
- setPopup(transientParent, m_window->display()->lastInputDevice(), m_window->display()->lastInputSerial());
- else if (transientParent && transientParent->object())
- updateTransientParent(transientParent->window());
- else
- setTopLevel();
-}
-
void QWaylandWlShellSurface::shell_surface_ping(uint32_t serial)
{
pong(serial);
}
-void QWaylandWlShellSurface::shell_surface_configure(uint32_t edges,
- int32_t width,
- int32_t height)
+void QWaylandWlShellSurface::shell_surface_configure(uint32_t edges, int32_t width, int32_t height)
{
- m_window->configure(edges, width, height);
+ m_pending.size = QSize(width, height);
+ m_pending.edges = static_cast<enum resize>(edges);
+ if (m_pending.edges && !m_pending.size.isEmpty())
+ m_normalSize = m_pending.size;
+ m_window->applyConfigureWhenPossible();
}
void QWaylandWlShellSurface::shell_surface_popup_done()
diff --git a/src/client/qwaylandwlshellsurface_p.h b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h
index 497ec6043..57e06525a 100644
--- a/src/client/qwaylandwlshellsurface_p.h
+++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h
@@ -92,22 +92,26 @@ public:
void setWindowFlags(Qt::WindowFlags flags) override;
void sendProperty(const QString &name, const QVariant &value) override;
- void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
+ void applyConfigure() override;
+ bool wantsDecorations() const override;
-private:
- void setMaximized() override;
- void setFullscreen() override;
- void setNormal() override;
- void setMinimized() override;
+protected:
+ void requestWindowStates(Qt::WindowStates states) override;
+private:
void setTopLevel();
void updateTransientParent(QWindow *parent);
void setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, uint serial);
QWaylandWindow *m_window = nullptr;
- bool m_maximized = false;
- bool m_fullscreen = false;
- QSize m_size;
+ struct {
+ Qt::WindowStates states = Qt::WindowNoState;
+ QSize size;
+ enum resize edges = resize_none;
+ } m_applied, m_pending;
+ QSize m_normalSize;
+ // There's really no need to have pending and applied state on wl-shell, but we do it just to
+ // keep the different shell implementations more similar.
QWaylandExtendedSurface *m_extendedWindow = nullptr;
void shell_surface_ping(uint32_t serial) override;
diff --git a/src/plugins/shellintegration/wl-shell/wl-shell.json b/src/plugins/shellintegration/wl-shell/wl-shell.json
new file mode 100644
index 000000000..1859bb58a
--- /dev/null
+++ b/src/plugins/shellintegration/wl-shell/wl-shell.json
@@ -0,0 +1,3 @@
+{
+ "Keys":[ "wl-shell" ]
+}
diff --git a/src/plugins/shellintegration/wl-shell/wl-shell.pro b/src/plugins/shellintegration/wl-shell/wl-shell.pro
new file mode 100644
index 000000000..fbff63c71
--- /dev/null
+++ b/src/plugins/shellintegration/wl-shell/wl-shell.pro
@@ -0,0 +1,25 @@
+QT += gui-private waylandclient-private
+CONFIG += wayland-scanner
+
+QMAKE_USE += wayland-client
+qtConfig(xkbcommon-evdev): \
+ QMAKE_USE_PRIVATE += xkbcommon_evdev
+
+WAYLANDCLIENTSOURCES += \
+ ../../../3rdparty/protocol/wayland.xml
+
+HEADERS += \
+ qwaylandwlshellintegration_p.h \
+ qwaylandwlshellsurface_p.h \
+
+SOURCES += \
+ main.cpp \
+ qwaylandwlshellintegration.cpp \
+ qwaylandwlshellsurface.cpp \
+
+OTHER_FILES += \
+ wl-shell.json
+
+PLUGIN_TYPE = wayland-shell-integration
+PLUGIN_CLASS_NAME = QWaylandWlShellIntegrationPlugin
+load(qt_plugin)
diff --git a/src/plugins/shellintegration/xdg-shell-v5/main.cpp b/src/plugins/shellintegration/xdg-shell-v5/main.cpp
new file mode 100644
index 000000000..d365f682d
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/main.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2017 ITAGE Corporation, author: <yusuke.binsaki@itage.co.jp>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshellv5integration_p.h"
+
+#include <QtWaylandClient/private/qwaylandshellintegrationplugin_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class QWaylandXdgShellV5IntegrationPlugin : public QWaylandShellIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QWaylandShellIntegrationFactoryInterface_iid FILE "xdg-shell-v5.json")
+
+public:
+ QWaylandShellIntegration *create(const QString &key, const QStringList &paramList) override;
+};
+
+QWaylandShellIntegration *QWaylandXdgShellV5IntegrationPlugin::create(const QString &key, const QStringList &paramList)
+{
+ Q_UNUSED(key);
+ Q_UNUSED(paramList);
+ return new QWaylandXdgShellV5Integration();
+}
+
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/qwayland-xdg-shell-unstable-v5.cpp b/src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/qwayland-xdg-shell-unstable-v5.cpp
new file mode 100644
index 000000000..0115eb1da
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/qwayland-xdg-shell-unstable-v5.cpp
@@ -0,0 +1,398 @@
+// Hand-edited to resolve conflicts with xdg-shell stable
+/*
+ * Copyright © 2008-2013 Kristian Høgsberg
+ * Copyright © 2013 Rafael Antognolli
+ * Copyright © 2013 Jasper St. Pierre
+ * Copyright © 2010-2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+#include "qwayland-xdg-shell-unstable-v5_p.h"
+
+QT_BEGIN_NAMESPACE
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers")
+
+namespace QtWayland {
+ xdg_shell_v5::xdg_shell_v5(struct ::wl_registry *registry, int id, int version)
+ {
+ init(registry, id, version);
+ }
+
+ xdg_shell_v5::xdg_shell_v5(struct ::xdg_shell_v5 *obj)
+ : m_xdg_shell(obj)
+ {
+ init_listener();
+ }
+
+ xdg_shell_v5::xdg_shell_v5()
+ : m_xdg_shell(nullptr)
+ {
+ }
+
+ xdg_shell_v5::~xdg_shell_v5()
+ {
+ }
+
+ void xdg_shell_v5::init(struct ::wl_registry *registry, int id, int version)
+ {
+ m_xdg_shell = static_cast<struct ::xdg_shell_v5 *>(wl_registry_bind(registry, id, &xdg_shell_v5_interface, version));
+ init_listener();
+ }
+
+ void xdg_shell_v5::init(struct ::xdg_shell_v5 *obj)
+ {
+ m_xdg_shell = obj;
+ init_listener();
+ }
+
+ bool xdg_shell_v5::isInitialized() const
+ {
+ return m_xdg_shell != nullptr;
+ }
+
+ const struct wl_interface *xdg_shell_v5::interface()
+ {
+ return &::xdg_shell_v5_interface;
+ }
+
+ void xdg_shell_v5::destroy()
+ {
+ xdg_shell_destroy(
+ m_xdg_shell);
+ m_xdg_shell = nullptr;
+ }
+
+ void xdg_shell_v5::use_unstable_version(int32_t version)
+ {
+ xdg_shell_use_unstable_version(
+ m_xdg_shell,
+ version);
+ }
+
+ struct ::xdg_surface_v5 *xdg_shell_v5::get_xdg_surface(struct ::wl_surface *surface)
+ {
+ return xdg_shell_get_xdg_surface(
+ m_xdg_shell,
+ surface);
+ }
+
+ struct ::xdg_popup_v5 *xdg_shell_v5::get_xdg_popup(struct ::wl_surface *surface, struct ::wl_surface *parent, struct ::wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
+ {
+ return xdg_shell_get_xdg_popup(
+ m_xdg_shell,
+ surface,
+ parent,
+ seat,
+ serial,
+ x,
+ y);
+ }
+
+ void xdg_shell_v5::pong(uint32_t serial)
+ {
+ xdg_shell_pong(
+ m_xdg_shell,
+ serial);
+ }
+
+ void xdg_shell_v5::xdg_shell_ping(uint32_t )
+ {
+ }
+
+ void xdg_shell_v5::handle_ping(
+ void *data,
+ struct ::xdg_shell_v5 *object,
+ uint32_t serial)
+ {
+ Q_UNUSED(object);
+ static_cast<xdg_shell_v5 *>(data)->xdg_shell_ping(
+ serial);
+ }
+
+ const struct xdg_shell_listener xdg_shell_v5::m_xdg_shell_listener = {
+ xdg_shell_v5::handle_ping
+ };
+
+ void xdg_shell_v5::init_listener()
+ {
+ xdg_shell_add_listener(m_xdg_shell, &m_xdg_shell_listener, this);
+ }
+
+ xdg_surface_v5::xdg_surface_v5(struct ::wl_registry *registry, int id, int version)
+ {
+ init(registry, id, version);
+ }
+
+ xdg_surface_v5::xdg_surface_v5(struct ::xdg_surface_v5 *obj)
+ : m_xdg_surface(obj)
+ {
+ init_listener();
+ }
+
+ xdg_surface_v5::xdg_surface_v5()
+ : m_xdg_surface(nullptr)
+ {
+ }
+
+ xdg_surface_v5::~xdg_surface_v5()
+ {
+ }
+
+ void xdg_surface_v5::init(struct ::wl_registry *registry, int id, int version)
+ {
+ m_xdg_surface = static_cast<struct ::xdg_surface_v5 *>(wl_registry_bind(registry, id, &xdg_surface_v5_interface, version));
+ init_listener();
+ }
+
+ void xdg_surface_v5::init(struct ::xdg_surface_v5 *obj)
+ {
+ m_xdg_surface = obj;
+ init_listener();
+ }
+
+ bool xdg_surface_v5::isInitialized() const
+ {
+ return m_xdg_surface != nullptr;
+ }
+
+ const struct wl_interface *xdg_surface_v5::interface()
+ {
+ return &::xdg_surface_v5_interface;
+ }
+
+ void xdg_surface_v5::destroy()
+ {
+ xdg_surface_destroy(
+ m_xdg_surface);
+ m_xdg_surface = nullptr;
+ }
+
+ void xdg_surface_v5::set_parent(struct ::xdg_surface_v5 *parent)
+ {
+ xdg_surface_set_parent(
+ m_xdg_surface,
+ parent);
+ }
+
+ void xdg_surface_v5::set_title(const QString &title)
+ {
+ xdg_surface_set_title(
+ m_xdg_surface,
+ title.toUtf8().constData());
+ }
+
+ void xdg_surface_v5::set_app_id(const QString &app_id)
+ {
+ xdg_surface_set_app_id(
+ m_xdg_surface,
+ app_id.toUtf8().constData());
+ }
+
+ void xdg_surface_v5::show_window_menu(struct ::wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
+ {
+ xdg_surface_show_window_menu(
+ m_xdg_surface,
+ seat,
+ serial,
+ x,
+ y);
+ }
+
+ void xdg_surface_v5::move(struct ::wl_seat *seat, uint32_t serial)
+ {
+ xdg_surface_move(
+ m_xdg_surface,
+ seat,
+ serial);
+ }
+
+ void xdg_surface_v5::resize(struct ::wl_seat *seat, uint32_t serial, uint32_t edges)
+ {
+ xdg_surface_resize(
+ m_xdg_surface,
+ seat,
+ serial,
+ edges);
+ }
+
+ void xdg_surface_v5::ack_configure(uint32_t serial)
+ {
+ xdg_surface_ack_configure(
+ m_xdg_surface,
+ serial);
+ }
+
+ void xdg_surface_v5::set_window_geometry(int32_t x, int32_t y, int32_t width, int32_t height)
+ {
+ xdg_surface_set_window_geometry(
+ m_xdg_surface,
+ x,
+ y,
+ width,
+ height);
+ }
+
+ void xdg_surface_v5::set_maximized()
+ {
+ xdg_surface_set_maximized(
+ m_xdg_surface);
+ }
+
+ void xdg_surface_v5::unset_maximized()
+ {
+ xdg_surface_unset_maximized(
+ m_xdg_surface);
+ }
+
+ void xdg_surface_v5::set_fullscreen(struct ::wl_output *output)
+ {
+ xdg_surface_set_fullscreen(
+ m_xdg_surface,
+ output);
+ }
+
+ void xdg_surface_v5::unset_fullscreen()
+ {
+ xdg_surface_unset_fullscreen(
+ m_xdg_surface);
+ }
+
+ void xdg_surface_v5::set_minimized()
+ {
+ xdg_surface_set_minimized(
+ m_xdg_surface);
+ }
+
+ void xdg_surface_v5::xdg_surface_configure(int32_t , int32_t , wl_array *, uint32_t )
+ {
+ }
+
+ void xdg_surface_v5::handle_configure(
+ void *data,
+ struct ::xdg_surface_v5 *object,
+ int32_t width,
+ int32_t height,
+ wl_array *states,
+ uint32_t serial)
+ {
+ Q_UNUSED(object);
+ static_cast<xdg_surface_v5 *>(data)->xdg_surface_configure(
+ width,
+ height,
+ states,
+ serial);
+ }
+
+ void xdg_surface_v5::xdg_surface_close()
+ {
+ }
+
+ void xdg_surface_v5::handle_close(
+ void *data,
+ struct ::xdg_surface_v5 *object)
+ {
+ Q_UNUSED(object);
+ static_cast<xdg_surface_v5 *>(data)->xdg_surface_close();
+ }
+
+ const struct xdg_surface_listener xdg_surface_v5::m_xdg_surface_listener = {
+ xdg_surface_v5::handle_configure,
+ xdg_surface_v5::handle_close
+ };
+
+ void xdg_surface_v5::init_listener()
+ {
+ xdg_surface_add_listener(m_xdg_surface, &m_xdg_surface_listener, this);
+ }
+
+ xdg_popup_v5::xdg_popup_v5(struct ::wl_registry *registry, int id, int version)
+ {
+ init(registry, id, version);
+ }
+
+ xdg_popup_v5::xdg_popup_v5(struct ::xdg_popup_v5 *obj)
+ : m_xdg_popup(obj)
+ {
+ init_listener();
+ }
+
+ xdg_popup_v5::xdg_popup_v5()
+ : m_xdg_popup(nullptr)
+ {
+ }
+
+ xdg_popup_v5::~xdg_popup_v5()
+ {
+ }
+
+ void xdg_popup_v5::init(struct ::wl_registry *registry, int id, int version)
+ {
+ m_xdg_popup = static_cast<struct ::xdg_popup_v5 *>(wl_registry_bind(registry, id, &xdg_popup_v5_interface, version));
+ init_listener();
+ }
+
+ void xdg_popup_v5::init(struct ::xdg_popup_v5 *obj)
+ {
+ m_xdg_popup = obj;
+ init_listener();
+ }
+
+ bool xdg_popup_v5::isInitialized() const
+ {
+ return m_xdg_popup != nullptr;
+ }
+
+ const struct wl_interface *xdg_popup_v5::interface()
+ {
+ return &::xdg_popup_v5_interface;
+ }
+
+ void xdg_popup_v5::destroy()
+ {
+ xdg_popup_destroy(
+ m_xdg_popup);
+ m_xdg_popup = nullptr;
+ }
+
+ void xdg_popup_v5::xdg_popup_popup_done()
+ {
+ }
+
+ void xdg_popup_v5::handle_popup_done(
+ void *data,
+ struct ::xdg_popup_v5 *object)
+ {
+ Q_UNUSED(object);
+ static_cast<xdg_popup_v5 *>(data)->xdg_popup_popup_done();
+ }
+
+ const struct xdg_popup_listener xdg_popup_v5::m_xdg_popup_listener = {
+ xdg_popup_v5::handle_popup_done
+ };
+
+ void xdg_popup_v5::init_listener()
+ {
+ xdg_popup_add_listener(m_xdg_popup, &m_xdg_popup_listener, this);
+ }
+}
+
+QT_WARNING_POP
+QT_END_NAMESPACE
diff --git a/src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/qwayland-xdg-shell-unstable-v5_p.h b/src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/qwayland-xdg-shell-unstable-v5_p.h
new file mode 100644
index 000000000..3d8a6c13d
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/qwayland-xdg-shell-unstable-v5_p.h
@@ -0,0 +1,198 @@
+// Hand-edited to resolve conflicts with xdg-shell stable
+/*
+ * Copyright © 2008-2013 Kristian Høgsberg
+ * Copyright © 2013 Rafael Antognolli
+ * Copyright © 2013 Jasper St. Pierre
+ * Copyright © 2010-2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+#ifndef QT_WAYLAND_XDG_SHELL_UNSTABLE_V5
+#define QT_WAYLAND_XDG_SHELL_UNSTABLE_V5
+
+#include "wayland-xdg-shell-unstable-v5-client-protocol_p.h"
+#include <QByteArray>
+#include <QString>
+
+QT_BEGIN_NAMESPACE
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers")
+
+namespace QtWayland {
+ class xdg_shell_v5
+ {
+ public:
+ xdg_shell_v5(struct ::wl_registry *registry, int id, int version);
+ xdg_shell_v5(struct ::xdg_shell_v5 *object);
+ xdg_shell_v5();
+
+ virtual ~xdg_shell_v5();
+
+ void init(struct ::wl_registry *registry, int id, int version);
+ void init(struct ::xdg_shell_v5 *object);
+
+ struct ::xdg_shell_v5 *object() { return m_xdg_shell; }
+ const struct ::xdg_shell_v5 *object() const { return m_xdg_shell; }
+
+ bool isInitialized() const;
+
+ static const struct ::wl_interface *interface();
+
+ enum version {
+ version_current = 5 // Always the latest version
+ };
+
+ enum error {
+ error_role = 0, // given wl_surface has another role
+ error_defunct_surfaces = 1, // xdg_shell was destroyed before children
+ error_not_the_topmost_popup = 2, // the client tried to map or destroy a non-topmost popup
+ error_invalid_popup_parent = 3 // the client specified an invalid popup parent surface
+ };
+
+ void destroy();
+ void use_unstable_version(int32_t version);
+ struct ::xdg_surface_v5 *get_xdg_surface(struct ::wl_surface *surface);
+ struct ::xdg_popup_v5 *get_xdg_popup(struct ::wl_surface *surface, struct ::wl_surface *parent, struct ::wl_seat *seat, uint32_t serial, int32_t x, int32_t y);
+ void pong(uint32_t serial);
+
+ protected:
+ virtual void xdg_shell_ping(uint32_t serial);
+
+ private:
+ void init_listener();
+ static const struct xdg_shell_listener m_xdg_shell_listener;
+ static void handle_ping(
+ void *data,
+ struct ::xdg_shell_v5 *object,
+ uint32_t serial);
+ struct ::xdg_shell_v5 *m_xdg_shell;
+ };
+
+ class xdg_surface_v5
+ {
+ public:
+ xdg_surface_v5(struct ::wl_registry *registry, int id, int version);
+ xdg_surface_v5(struct ::xdg_surface_v5 *object);
+ xdg_surface_v5();
+
+ virtual ~xdg_surface_v5();
+
+ void init(struct ::wl_registry *registry, int id, int version);
+ void init(struct ::xdg_surface_v5 *object);
+
+ struct ::xdg_surface_v5 *object() { return m_xdg_surface; }
+ const struct ::xdg_surface_v5 *object() const { return m_xdg_surface; }
+
+ bool isInitialized() const;
+
+ static const struct ::wl_interface *interface();
+
+ enum resize_edge {
+ resize_edge_none = 0,
+ resize_edge_top = 1,
+ resize_edge_bottom = 2,
+ resize_edge_left = 4,
+ resize_edge_top_left = 5,
+ resize_edge_bottom_left = 6,
+ resize_edge_right = 8,
+ resize_edge_top_right = 9,
+ resize_edge_bottom_right = 10
+ };
+
+ enum state {
+ state_maximized = 1, // the surface is maximized
+ state_fullscreen = 2, // the surface is fullscreen
+ state_resizing = 3,
+ state_activated = 4
+ };
+
+ void destroy();
+ void set_parent(struct ::xdg_surface_v5 *parent);
+ void set_title(const QString &title);
+ void set_app_id(const QString &app_id);
+ void show_window_menu(struct ::wl_seat *seat, uint32_t serial, int32_t x, int32_t y);
+ void move(struct ::wl_seat *seat, uint32_t serial);
+ void resize(struct ::wl_seat *seat, uint32_t serial, uint32_t edges);
+ void ack_configure(uint32_t serial);
+ void set_window_geometry(int32_t x, int32_t y, int32_t width, int32_t height);
+ void set_maximized();
+ void unset_maximized();
+ void set_fullscreen(struct ::wl_output *output);
+ void unset_fullscreen();
+ void set_minimized();
+
+ protected:
+ virtual void xdg_surface_configure(int32_t width, int32_t height, wl_array *states, uint32_t serial);
+ virtual void xdg_surface_close();
+
+ private:
+ void init_listener();
+ static const struct xdg_surface_listener m_xdg_surface_listener;
+ static void handle_configure(
+ void *data,
+ struct ::xdg_surface_v5 *object,
+ int32_t width,
+ int32_t height,
+ wl_array *states,
+ uint32_t serial);
+ static void handle_close(
+ void *data,
+ struct ::xdg_surface_v5 *object);
+ struct ::xdg_surface_v5 *m_xdg_surface;
+ };
+
+ class xdg_popup_v5
+ {
+ public:
+ xdg_popup_v5(struct ::wl_registry *registry, int id, int version);
+ xdg_popup_v5(struct ::xdg_popup_v5 *object);
+ xdg_popup_v5();
+
+ virtual ~xdg_popup_v5();
+
+ void init(struct ::wl_registry *registry, int id, int version);
+ void init(struct ::xdg_popup_v5 *object);
+
+ struct ::xdg_popup_v5 *object() { return m_xdg_popup; }
+ const struct ::xdg_popup_v5 *object() const { return m_xdg_popup; }
+
+ bool isInitialized() const;
+
+ static const struct ::wl_interface *interface();
+
+ void destroy();
+
+ protected:
+ virtual void xdg_popup_popup_done();
+
+ private:
+ void init_listener();
+ static const struct xdg_popup_listener m_xdg_popup_listener;
+ static void handle_popup_done(
+ void *data,
+ struct ::xdg_popup_v5 *object);
+ struct ::xdg_popup_v5 *m_xdg_popup;
+ };
+}
+
+QT_WARNING_POP
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-client-protocol_p.h b/src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-client-protocol_p.h
new file mode 100644
index 000000000..62b6a7858
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-client-protocol_p.h
@@ -0,0 +1,1112 @@
+/* Generated by wayland-scanner 1.13.0 */
+// Hand-edited to resolve conflicts with xdg-shell stable
+
+#ifndef XDG_SHELL_UNSTABLE_V5_CLIENT_PROTOCOL_H
+#define XDG_SHELL_UNSTABLE_V5_CLIENT_PROTOCOL_H
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-client.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @page page_xdg_shell_unstable_v5 The xdg_shell_unstable_v5 protocol
+ * @section page_ifaces_xdg_shell_unstable_v5 Interfaces
+ * - @subpage page_iface_xdg_shell_v5 - create desktop-style surfaces
+ * - @subpage page_iface_xdg_surface_v5 - A desktop window
+ * - @subpage page_iface_xdg_popup_v5 - short-lived, popup surfaces for menus
+ * @section page_copyright_xdg_shell_unstable_v5 Copyright
+ * <pre>
+ *
+ * Copyright © 2008-2013 Kristian Høgsberg
+ * Copyright © 2013 Rafael Antognolli
+ * Copyright © 2013 Jasper St. Pierre
+ * Copyright © 2010-2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ * </pre>
+ */
+struct wl_output;
+struct wl_seat;
+struct wl_surface;
+struct xdg_popup_v5;
+struct xdg_shell_v5;
+struct xdg_surface_v5;
+
+/**
+ * @page page_iface_xdg_shell_v5 xdg_shell
+ * @section page_iface_xdg_shell_desc Description
+ *
+ * xdg_shell_v5 allows clients to turn a wl_surface into a "real window"
+ * which can be dragged, resized, stacked, and moved around by the
+ * user. Everything about this interface is suited towards traditional
+ * desktop environments.
+ * @section page_iface_xdg_shell_api API
+ * See @ref iface_xdg_shell.
+ */
+/**
+ * @defgroup iface_xdg_shell_v5 The xdg_shell_v5 interface
+ *
+ * xdg_shell_v5 allows clients to turn a wl_surface into a "real window"
+ * which can be dragged, resized, stacked, and moved around by the
+ * user. Everything about this interface is suited towards traditional
+ * desktop environments.
+ */
+extern const struct wl_interface xdg_shell_v5_interface;
+/**
+ * @page page_iface_xdg_surface_v5 xdg_surface
+ * @section page_iface_xdg_surface_desc Description
+ *
+ * An interface that may be implemented by a wl_surface, for
+ * implementations that provide a desktop-style user interface.
+ *
+ * It provides requests to treat surfaces like windows, allowing to set
+ * properties like maximized, fullscreen, minimized, and to move and resize
+ * them, and associate metadata like title and app id.
+ *
+ * The client must call wl_surface.commit on the corresponding wl_surface
+ * for the xdg_surface_v5 state to take effect. Prior to committing the new
+ * state, it can set up initial configuration, such as maximizing or setting
+ * a window geometry.
+ *
+ * Even without attaching a buffer the compositor must respond to initial
+ * committed configuration, for instance sending a configure event with
+ * expected window geometry if the client maximized its surface during
+ * initialization.
+ *
+ * For a surface to be mapped by the compositor the client must have
+ * committed both an xdg_surface_v5 state and a buffer.
+ * @section page_iface_xdg_surface_api API
+ * See @ref iface_xdg_surface.
+ */
+/**
+ * @defgroup iface_xdg_surface_v5 The xdg_surface_v5 interface
+ *
+ * An interface that may be implemented by a wl_surface, for
+ * implementations that provide a desktop-style user interface.
+ *
+ * It provides requests to treat surfaces like windows, allowing to set
+ * properties like maximized, fullscreen, minimized, and to move and resize
+ * them, and associate metadata like title and app id.
+ *
+ * The client must call wl_surface.commit on the corresponding wl_surface
+ * for the xdg_surface_v5 state to take effect. Prior to committing the new
+ * state, it can set up initial configuration, such as maximizing or setting
+ * a window geometry.
+ *
+ * Even without attaching a buffer the compositor must respond to initial
+ * committed configuration, for instance sending a configure event with
+ * expected window geometry if the client maximized its surface during
+ * initialization.
+ *
+ * For a surface to be mapped by the compositor the client must have
+ * committed both an xdg_surface_v5 state and a buffer.
+ */
+extern const struct wl_interface xdg_surface_v5_interface;
+/**
+ * @page page_iface_xdg_popup_v5 xdg_popup
+ * @section page_iface_xdg_popup_desc Description
+ *
+ * A popup surface is a short-lived, temporary surface that can be
+ * used to implement menus. It takes an explicit grab on the surface
+ * that will be dismissed when the user dismisses the popup. This can
+ * be done by the user clicking outside the surface, using the keyboard,
+ * or even locking the screen through closing the lid or a timeout.
+ *
+ * When the popup is dismissed, a popup_done event will be sent out,
+ * and at the same time the surface will be unmapped. The xdg_popup
+ * object is now inert and cannot be reactivated, so clients should
+ * destroy it. Explicitly destroying the xdg_popup_v5 object will also
+ * dismiss the popup and unmap the surface.
+ *
+ * Clients will receive events for all their surfaces during this
+ * grab (which is an "owner-events" grab in X11 parlance). This is
+ * done so that users can navigate through submenus and other
+ * "nested" popup windows without having to dismiss the topmost
+ * popup.
+ *
+ * Clients that want to dismiss the popup when another surface of
+ * their own is clicked should dismiss the popup using the destroy
+ * request.
+ *
+ * The parent surface must have either an xdg_surface_v5 or xdg_popup
+ * role.
+ *
+ * Specifying an xdg_popup_v5 for the parent means that the popups are
+ * nested, with this popup now being the topmost popup. Nested
+ * popups must be destroyed in the reverse order they were created
+ * in, e.g. the only popup you are allowed to destroy at all times
+ * is the topmost one.
+ *
+ * If there is an existing popup when creating a new popup, the
+ * parent must be the current topmost popup.
+ *
+ * A parent surface must be mapped before the new popup is mapped.
+ *
+ * When compositors choose to dismiss a popup, they will likely
+ * dismiss every nested popup as well. When a compositor dismisses
+ * popups, it will follow the same dismissing order as required
+ * from the client.
+ *
+ * The x and y arguments passed when creating the popup object specify
+ * where the top left of the popup should be placed, relative to the
+ * local surface coordinates of the parent surface. See
+ * xdg_shell.get_xdg_popup.
+ *
+ * The client must call wl_surface.commit on the corresponding wl_surface
+ * for the xdg_popup_v5 state to take effect.
+ *
+ * For a surface to be mapped by the compositor the client must have
+ * committed both the xdg_popup_v5 state and a buffer.
+ * @section page_iface_xdg_popup_api API
+ * See @ref iface_xdg_popup.
+ */
+/**
+ * @defgroup iface_xdg_popup_v5 The xdg_popup_v5 interface
+ *
+ * A popup surface is a short-lived, temporary surface that can be
+ * used to implement menus. It takes an explicit grab on the surface
+ * that will be dismissed when the user dismisses the popup. This can
+ * be done by the user clicking outside the surface, using the keyboard,
+ * or even locking the screen through closing the lid or a timeout.
+ *
+ * When the popup is dismissed, a popup_done event will be sent out,
+ * and at the same time the surface will be unmapped. The xdg_popup
+ * object is now inert and cannot be reactivated, so clients should
+ * destroy it. Explicitly destroying the xdg_popup_v5 object will also
+ * dismiss the popup and unmap the surface.
+ *
+ * Clients will receive events for all their surfaces during this
+ * grab (which is an "owner-events" grab in X11 parlance). This is
+ * done so that users can navigate through submenus and other
+ * "nested" popup windows without having to dismiss the topmost
+ * popup.
+ *
+ * Clients that want to dismiss the popup when another surface of
+ * their own is clicked should dismiss the popup using the destroy
+ * request.
+ *
+ * The parent surface must have either an xdg_surface_v5 or xdg_popup
+ * role.
+ *
+ * Specifying an xdg_popup_v5 for the parent means that the popups are
+ * nested, with this popup now being the topmost popup. Nested
+ * popups must be destroyed in the reverse order they were created
+ * in, e.g. the only popup you are allowed to destroy at all times
+ * is the topmost one.
+ *
+ * If there is an existing popup when creating a new popup, the
+ * parent must be the current topmost popup.
+ *
+ * A parent surface must be mapped before the new popup is mapped.
+ *
+ * When compositors choose to dismiss a popup, they will likely
+ * dismiss every nested popup as well. When a compositor dismisses
+ * popups, it will follow the same dismissing order as required
+ * from the client.
+ *
+ * The x and y arguments passed when creating the popup object specify
+ * where the top left of the popup should be placed, relative to the
+ * local surface coordinates of the parent surface. See
+ * xdg_shell.get_xdg_popup.
+ *
+ * The client must call wl_surface.commit on the corresponding wl_surface
+ * for the xdg_popup_v5 state to take effect.
+ *
+ * For a surface to be mapped by the compositor the client must have
+ * committed both the xdg_popup_v5 state and a buffer.
+ */
+extern const struct wl_interface xdg_popup_v5_interface;
+
+#ifndef XDG_SHELL_VERSION_ENUM
+#define XDG_SHELL_VERSION_ENUM
+/**
+ * @ingroup iface_xdg_shell
+ * latest protocol version
+ *
+ * The 'current' member of this enum gives the version of the
+ * protocol. Implementations can compare this to the version
+ * they implement using static_assert to ensure the protocol and
+ * implementation versions match.
+ */
+enum xdg_shell_version {
+ /**
+ * Always the latest version
+ */
+ XDG_SHELL_VERSION_CURRENT = 5,
+};
+#endif /* XDG_SHELL_VERSION_ENUM */
+
+#ifndef XDG_SHELL_ERROR_ENUM
+#define XDG_SHELL_ERROR_ENUM
+enum xdg_shell_error {
+ /**
+ * given wl_surface has another role
+ */
+ XDG_SHELL_ERROR_ROLE = 0,
+ /**
+ * xdg_shell_v5 was destroyed before children
+ */
+ XDG_SHELL_ERROR_DEFUNCT_SURFACES = 1,
+ /**
+ * the client tried to map or destroy a non-topmost popup
+ */
+ XDG_SHELL_ERROR_NOT_THE_TOPMOST_POPUP = 2,
+ /**
+ * the client specified an invalid popup parent surface
+ */
+ XDG_SHELL_ERROR_INVALID_POPUP_PARENT = 3,
+};
+#endif /* XDG_SHELL_ERROR_ENUM */
+
+/**
+ * @ingroup iface_xdg_shell
+ * @struct xdg_shell_listener
+ */
+struct xdg_shell_listener {
+ /**
+ * check if the client is alive
+ *
+ * The ping event asks the client if it's still alive. Pass the
+ * serial specified in the event back to the compositor by sending
+ * a "pong" request back with the specified serial.
+ *
+ * Compositors can use this to determine if the client is still
+ * alive. It's unspecified what will happen if the client doesn't
+ * respond to the ping request, or in what timeframe. Clients
+ * should try to respond in a reasonable amount of time.
+ *
+ * A compositor is free to ping in any way it wants, but a client
+ * must always respond to any xdg_shell_v5 object it created.
+ * @param serial pass this to the pong request
+ */
+ void (*ping)(void *data,
+ struct xdg_shell_v5 *xdg_shell_v5,
+ uint32_t serial);
+};
+
+/**
+ * @ingroup iface_xdg_shell
+ */
+static inline int
+xdg_shell_add_listener(struct xdg_shell_v5 *xdg_shell,
+ const struct xdg_shell_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) xdg_shell,
+ (void (**)(void)) listener, data);
+}
+
+#define XDG_SHELL_DESTROY 0
+#define XDG_SHELL_USE_UNSTABLE_VERSION 1
+#define XDG_SHELL_GET_XDG_SURFACE 2
+#define XDG_SHELL_GET_XDG_POPUP 3
+#define XDG_SHELL_PONG 4
+
+/**
+ * @ingroup iface_xdg_shell
+ */
+#define XDG_SHELL_PING_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_xdg_shell
+ */
+#define XDG_SHELL_DESTROY_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_shell
+ */
+#define XDG_SHELL_USE_UNSTABLE_VERSION_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_shell
+ */
+#define XDG_SHELL_GET_XDG_SURFACE_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_shell
+ */
+#define XDG_SHELL_GET_XDG_POPUP_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_shell
+ */
+#define XDG_SHELL_PONG_SINCE_VERSION 1
+
+/** @ingroup iface_xdg_shell_v5 */
+static inline void
+xdg_shell_set_user_data(struct xdg_shell_v5 *xdg_shell, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) xdg_shell, user_data);
+}
+
+/** @ingroup iface_xdg_shell_v5 */
+static inline void *
+xdg_shell_get_user_data(struct xdg_shell_v5 *xdg_shell)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) xdg_shell);
+}
+
+static inline uint32_t
+xdg_shell_get_version(struct xdg_shell_v5 *xdg_shell)
+{
+ return wl_proxy_get_version((struct wl_proxy *) xdg_shell);
+}
+
+/**
+ * @ingroup iface_xdg_shell
+ *
+ * Destroy this xdg_shell_v5 object.
+ *
+ * Destroying a bound xdg_shell_v5 object while there are surfaces
+ * still alive created by this xdg_shell_v5 object instance is illegal
+ * and will result in a protocol error.
+ */
+static inline void
+xdg_shell_destroy(struct xdg_shell_v5 *xdg_shell)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_shell,
+ XDG_SHELL_DESTROY);
+
+ wl_proxy_destroy((struct wl_proxy *) xdg_shell);
+}
+
+/**
+ * @ingroup iface_xdg_shell
+ *
+ * Negotiate the unstable version of the interface. This
+ * mechanism is in place to ensure client and server agree on the
+ * unstable versions of the protocol that they speak or exit
+ * cleanly if they don't agree. This request will go away once
+ * the xdg-shell protocol is stable.
+ */
+static inline void
+xdg_shell_use_unstable_version(struct xdg_shell_v5 *xdg_shell, int32_t version)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_shell,
+ XDG_SHELL_USE_UNSTABLE_VERSION, version);
+}
+
+/**
+ * @ingroup iface_xdg_shell
+ *
+ * This creates an xdg_surface_v5 for the given surface and gives it the
+ * xdg_surface_v5 role. A wl_surface can only be given an xdg_surface_v5 role
+ * once. If get_xdg_surface_v5 is called with a wl_surface that already has
+ * an active xdg_surface_v5 associated with it, or if it had any other role,
+ * an error is raised.
+ *
+ * See the documentation of xdg_surface_v5 for more details about what an
+ * xdg_surface_v5 is and how it is used.
+ */
+static inline struct xdg_surface_v5 *
+xdg_shell_get_xdg_surface(struct xdg_shell_v5 *xdg_shell, struct wl_surface *surface)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_marshal_constructor((struct wl_proxy *) xdg_shell,
+ XDG_SHELL_GET_XDG_SURFACE, &xdg_surface_v5_interface, NULL, surface);
+
+ return (struct xdg_surface_v5 *) id;
+}
+
+/**
+ * @ingroup iface_xdg_shell
+ *
+ * This creates an xdg_popup_v5 for the given surface and gives it the
+ * xdg_popup_v5 role. A wl_surface can only be given an xdg_popup_v5 role
+ * once. If get_xdg_popup_v5 is called with a wl_surface that already has
+ * an active xdg_popup_v5 associated with it, or if it had any other role,
+ * an error is raised.
+ *
+ * This request must be used in response to some sort of user action
+ * like a button press, key press, or touch down event.
+ *
+ * See the documentation of xdg_popup_v5 for more details about what an
+ * xdg_popup_v5 is and how it is used.
+ */
+static inline struct xdg_popup_v5 *
+xdg_shell_get_xdg_popup(struct xdg_shell_v5 *xdg_shell, struct wl_surface *surface, struct wl_surface *parent, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_marshal_constructor((struct wl_proxy *) xdg_shell,
+ XDG_SHELL_GET_XDG_POPUP, &xdg_popup_v5_interface, NULL, surface, parent, seat, serial, x, y);
+
+ return (struct xdg_popup_v5 *) id;
+}
+
+/**
+ * @ingroup iface_xdg_shell
+ *
+ * A client must respond to a ping event with a pong request or
+ * the client may be deemed unresponsive.
+ */
+static inline void
+xdg_shell_pong(struct xdg_shell_v5 *xdg_shell, uint32_t serial)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_shell,
+ XDG_SHELL_PONG, serial);
+}
+
+#ifndef XDG_SURFACE_RESIZE_EDGE_ENUM
+#define XDG_SURFACE_RESIZE_EDGE_ENUM
+/**
+ * @ingroup iface_xdg_surface
+ * edge values for resizing
+ *
+ * These values are used to indicate which edge of a surface
+ * is being dragged in a resize operation.
+ */
+enum xdg_surface_resize_edge {
+ XDG_SURFACE_RESIZE_EDGE_NONE = 0,
+ XDG_SURFACE_RESIZE_EDGE_TOP = 1,
+ XDG_SURFACE_RESIZE_EDGE_BOTTOM = 2,
+ XDG_SURFACE_RESIZE_EDGE_LEFT = 4,
+ XDG_SURFACE_RESIZE_EDGE_TOP_LEFT = 5,
+ XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT = 6,
+ XDG_SURFACE_RESIZE_EDGE_RIGHT = 8,
+ XDG_SURFACE_RESIZE_EDGE_TOP_RIGHT = 9,
+ XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT = 10,
+};
+#endif /* XDG_SURFACE_RESIZE_EDGE_ENUM */
+
+#ifndef XDG_SURFACE_STATE_ENUM
+#define XDG_SURFACE_STATE_ENUM
+/**
+ * @ingroup iface_xdg_surface
+ * types of state on the surface
+ *
+ * The different state values used on the surface. This is designed for
+ * state values like maximized, fullscreen. It is paired with the
+ * configure event to ensure that both the client and the compositor
+ * setting the state can be synchronized.
+ *
+ * States set in this way are double-buffered. They will get applied on
+ * the next commit.
+ *
+ * Desktop environments may extend this enum by taking up a range of
+ * values and documenting the range they chose in this description.
+ * They are not required to document the values for the range that they
+ * chose. Ideally, any good extensions from a desktop environment should
+ * make its way into standardization into this enum.
+ *
+ * The current reserved ranges are:
+ *
+ * 0x0000 - 0x0FFF: xdg-shell core values, documented below.
+ * 0x1000 - 0x1FFF: GNOME
+ */
+enum xdg_surface_state {
+ /**
+ * the surface is maximized
+ */
+ XDG_SURFACE_STATE_MAXIMIZED = 1,
+ /**
+ * the surface is fullscreen
+ */
+ XDG_SURFACE_STATE_FULLSCREEN = 2,
+ XDG_SURFACE_STATE_RESIZING = 3,
+ XDG_SURFACE_STATE_ACTIVATED = 4,
+};
+#endif /* XDG_SURFACE_STATE_ENUM */
+
+/**
+ * @ingroup iface_xdg_surface
+ * @struct xdg_surface_listener
+ */
+struct xdg_surface_listener {
+ /**
+ * suggest a surface change
+ *
+ * The configure event asks the client to resize its surface or
+ * to change its state.
+ *
+ * The width and height arguments specify a hint to the window
+ * about how its surface should be resized in window geometry
+ * coordinates. See set_window_geometry.
+ *
+ * If the width or height arguments are zero, it means the client
+ * should decide its own window dimension. This may happen when the
+ * compositor need to configure the state of the surface but
+ * doesn't have any information about any previous or expected
+ * dimension.
+ *
+ * The states listed in the event specify how the width/height
+ * arguments should be interpreted, and possibly how it should be
+ * drawn.
+ *
+ * Clients should arrange their surface for the new size and
+ * states, and then send a ack_configure request with the serial
+ * sent in this configure event at some point before committing the
+ * new surface.
+ *
+ * If the client receives multiple configure events before it can
+ * respond to one, it is free to discard all but the last event it
+ * received.
+ */
+ void (*configure)(void *data,
+ struct xdg_surface_v5 *xdg_surface_v5,
+ int32_t width,
+ int32_t height,
+ struct wl_array *states,
+ uint32_t serial);
+ /**
+ * surface wants to be closed
+ *
+ * The close event is sent by the compositor when the user wants
+ * the surface to be closed. This should be equivalent to the user
+ * clicking the close button in client-side decorations, if your
+ * application has any...
+ *
+ * This is only a request that the user intends to close your
+ * window. The client may choose to ignore this request, or show a
+ * dialog to ask the user to save their data...
+ */
+ void (*close)(void *data,
+ struct xdg_surface_v5 *xdg_surface_v5);
+};
+
+/**
+ * @ingroup iface_xdg_surface
+ */
+static inline int
+xdg_surface_add_listener(struct xdg_surface_v5 *xdg_surface,
+ const struct xdg_surface_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) xdg_surface,
+ (void (**)(void)) listener, data);
+}
+
+#define XDG_SURFACE_DESTROY 0
+#define XDG_SURFACE_SET_PARENT 1
+#define XDG_SURFACE_SET_TITLE 2
+#define XDG_SURFACE_SET_APP_ID 3
+#define XDG_SURFACE_SHOW_WINDOW_MENU 4
+#define XDG_SURFACE_MOVE 5
+#define XDG_SURFACE_RESIZE 6
+#define XDG_SURFACE_ACK_CONFIGURE 7
+#define XDG_SURFACE_SET_WINDOW_GEOMETRY 8
+#define XDG_SURFACE_SET_MAXIMIZED 9
+#define XDG_SURFACE_UNSET_MAXIMIZED 10
+#define XDG_SURFACE_SET_FULLSCREEN 11
+#define XDG_SURFACE_UNSET_FULLSCREEN 12
+#define XDG_SURFACE_SET_MINIMIZED 13
+
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_CONFIGURE_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_CLOSE_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_DESTROY_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SET_PARENT_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SET_TITLE_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SET_APP_ID_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SHOW_WINDOW_MENU_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_MOVE_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_RESIZE_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_ACK_CONFIGURE_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SET_WINDOW_GEOMETRY_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SET_MAXIMIZED_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_UNSET_MAXIMIZED_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SET_FULLSCREEN_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_UNSET_FULLSCREEN_SINCE_VERSION 1
+/**
+ * @ingroup iface_xdg_surface
+ */
+#define XDG_SURFACE_SET_MINIMIZED_SINCE_VERSION 1
+
+/** @ingroup iface_xdg_surface_v5 */
+static inline void
+xdg_surface_set_user_data(struct xdg_surface_v5 *xdg_surface, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) xdg_surface, user_data);
+}
+
+/** @ingroup iface_xdg_surface_v5 */
+static inline void *
+xdg_surface_get_user_data(struct xdg_surface_v5 *xdg_surface)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) xdg_surface);
+}
+
+static inline uint32_t
+xdg_surface_get_version(struct xdg_surface_v5 *xdg_surface)
+{
+ return wl_proxy_get_version((struct wl_proxy *) xdg_surface);
+}
+
+/**
+ * @ingroup iface_xdg_surface
+ *
+ * Unmap and destroy the window. The window will be effectively
+ * hidden from the user's point of view, and all state like
+ * maximization, fullscreen, and so on, will be lost.
+ */
+static inline void
+xdg_surface_destroy(struct xdg_surface_v5 *xdg_surface)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_DESTROY);
+
+ wl_proxy_destroy((struct wl_proxy *) xdg_surface);
+}
+
+/**
+ * @ingroup iface_xdg_surface
+ *
+ * Set the "parent" of this surface. This window should be stacked
+ * above a parent. The parent surface must be mapped as long as this
+ * surface is mapped.
+ *
+ * Parent windows should be set on dialogs, toolboxes, or other
+ * "auxiliary" surfaces, so that the parent is raised when the dialog
+ * is raised.
+ */
+static inline void
+xdg_surface_set_parent(struct xdg_surface_v5 *xdg_surface, struct xdg_surface_v5 *parent)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_SET_PARENT, parent);
+}
+
+/**
+ * @ingroup iface_xdg_surface
+ *
+ * Set a short title for the surface.
+ *
+ * This string may be used to identify the surface in a task bar,
+ * window list, or other user interface elements provided by the
+ * compositor.
+ *
+ * The string must be encoded in UTF-8.
+ */
+static inline void
+xdg_surface_set_title(struct xdg_surface_v5 *xdg_surface, const char *title)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_SET_TITLE, title);
+}
+
+/**
+ * @ingroup iface_xdg_surface
+ *
+ * Set an application identifier for the surface.
+ *
+ * The app ID identifies the general class of applications to which
+ * the surface belongs. The compositor can use this to group multiple
+ * surfaces together, or to determine how to launch a new application.
+ *
+ * For D-Bus activatable applications, the app ID is used as the D-Bus
+ * service name.
+ *
+ * The compositor shell will try to group application surfaces together
+ * by their app ID. As a best practice, it is suggested to select app
+ * ID's that match the basename of the application's .desktop file.
+ * For example, "org.freedesktop.FooViewer" where the .desktop file is
+ * "org.freedesktop.FooViewer.desktop".
+ *
+ * See the desktop-entry specification [0] for more details on
+ * application identifiers and how they relate to well-known D-Bus
+ * names and .desktop files.
+ *
+ * [0] http://standards.freedesktop.org/desktop-entry-spec/
+ */
+static inline void
+xdg_surface_set_app_id(struct xdg_surface_v5 *xdg_surface, const char *app_id)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_SET_APP_ID, app_id);
+}
+
+/**
+ * @ingroup iface_xdg_surface
+ *
+ * Clients implementing client-side decorations might want to show
+ * a context menu when right-clicking on the decorations, giving the
+ * user a menu that they can use to maximize or minimize the window.
+ *
+ * This request asks the compositor to pop up such a window menu at
+ * the given position, relative to the local surface coordinates of
+ * the parent surface. There are no guarantees as to what menu items
+ * the window menu contains.
+ *
+ * This request must be used in response to some sort of user action
+ * like a button press, key press, or touch down event.
+ */
+static inline void
+xdg_surface_show_window_menu(struct xdg_surface_v5 *xdg_surface, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_SHOW_WINDOW_MENU, seat, serial, x, y);
+}
+
+/**
+ * @ingroup iface_xdg_surface
+ *
+ * Start an interactive, user-driven move of the surface.
+ *
+ * This request must be used in response to some sort of user action
+ * like a button press, key press, or touch down event. The passed
+ * serial is used to determine the type of interactive move (touch,
+ * pointer, etc).
+ *
+ * The server may ignore move requests depending on the state of
+ * the surface (e.g. fullscreen or maximized), or if the passed serial
+ * is no longer valid.
+ *
+ * If triggered, the surface will lose the focus of the device
+ * (wl_pointer, wl_touch, etc) used for the move. It is up to the
+ * compositor to visually indicate that the move is taking place, such as
+ * updating a pointer cursor, during the move. There is no guarantee
+ * that the device focus will return when the move is completed.
+ */
+static inline void
+xdg_surface_move(struct xdg_surface_v5 *xdg_surface, struct wl_seat *seat, uint32_t serial)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_MOVE, seat, serial);
+}
+
+/**
+ * @ingroup iface_xdg_surface
+ *
+ * Start a user-driven, interactive resize of the surface.
+ *
+ * This request must be used in response to some sort of user action
+ * like a button press, key press, or touch down event. The passed
+ * serial is used to determine the type of interactive resize (touch,
+ * pointer, etc).
+ *
+ * The server may ignore resize requests depending on the state of
+ * the surface (e.g. fullscreen or maximized).
+ *
+ * If triggered, the client will receive configure events with the
+ * "resize" state enum value and the expected sizes. See the "resize"
+ * enum value for more details about what is required. The client
+ * must also acknowledge configure events using "ack_configure". After
+ * the resize is completed, the client will receive another "configure"
+ * event without the resize state.
+ *
+ * If triggered, the surface also will lose the focus of the device
+ * (wl_pointer, wl_touch, etc) used for the resize. It is up to the
+ * compositor to visually indicate that the resize is taking place,
+ * such as updating a pointer cursor, during the resize. There is no
+ * guarantee that the device focus will return when the resize is
+ * completed.
+ *
+ * The edges parameter specifies how the surface should be resized,
+ * and is one of the values of the resize_edge enum. The compositor
+ * may use this information to update the surface position for
+ * example when dragging the top left corner. The compositor may also
+ * use this information to adapt its behavior, e.g. choose an
+ * appropriate cursor image.
+ */
+static inline void
+xdg_surface_resize(struct xdg_surface_v5 *xdg_surface, struct wl_seat *seat, uint32_t serial, uint32_t edges)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_RESIZE, seat, serial, edges);
+}
+
+/**
+ * @ingroup iface_xdg_surface
+ *
+ * When a configure event is received, if a client commits the
+ * surface in response to the configure event, then the client
+ * must make a ack_configure request before the commit request,
+ * passing along the serial of the configure event.
+ *
+ * For instance, the compositor might use this information to move
+ * a surface to the top left only when the client has drawn itself
+ * for the maximized or fullscreen state.
+ *
+ * If the client receives multiple configure events before it
+ * can respond to one, it only has to ack the last configure event.
+ */
+static inline void
+xdg_surface_ack_configure(struct xdg_surface_v5 *xdg_surface, uint32_t serial)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_ACK_CONFIGURE, serial);
+}
+
+/**
+ * @ingroup iface_xdg_surface
+ *
+ * The window geometry of a window is its "visible bounds" from the
+ * user's perspective. Client-side decorations often have invisible
+ * portions like drop-shadows which should be ignored for the
+ * purposes of aligning, placing and constraining windows.
+ *
+ * The window geometry is double buffered, and will be applied at the
+ * time wl_surface.commit of the corresponding wl_surface is called.
+ *
+ * Once the window geometry of the surface is set once, it is not
+ * possible to unset it, and it will remain the same until
+ * set_window_geometry is called again, even if a new subsurface or
+ * buffer is attached.
+ *
+ * If never set, the value is the full bounds of the surface,
+ * including any subsurfaces. This updates dynamically on every
+ * commit. This unset mode is meant for extremely simple clients.
+ *
+ * If responding to a configure event, the window geometry in here
+ * must respect the sizing negotiations specified by the states in
+ * the configure event.
+ *
+ * The arguments are given in the surface local coordinate space of
+ * the wl_surface associated with this xdg_surface.
+ *
+ * The width and height must be greater than zero.
+ */
+static inline void
+xdg_surface_set_window_geometry(struct xdg_surface_v5 *xdg_surface, int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_SET_WINDOW_GEOMETRY, x, y, width, height);
+}
+
+/**
+ * @ingroup iface_xdg_surface
+ *
+ * Maximize the surface.
+ *
+ * After requesting that the surface should be maximized, the compositor
+ * will respond by emitting a configure event with the "maximized" state
+ * and the required window geometry. The client should then update its
+ * content, drawing it in a maximized state, i.e. without shadow or other
+ * decoration outside of the window geometry. The client must also
+ * acknowledge the configure when committing the new content (see
+ * ack_configure).
+ *
+ * It is up to the compositor to decide how and where to maximize the
+ * surface, for example which output and what region of the screen should
+ * be used.
+ *
+ * If the surface was already maximized, the compositor will still emit
+ * a configure event with the "maximized" state.
+ */
+static inline void
+xdg_surface_set_maximized(struct xdg_surface_v5 *xdg_surface)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_SET_MAXIMIZED);
+}
+
+/**
+ * @ingroup iface_xdg_surface
+ *
+ * Unmaximize the surface.
+ *
+ * After requesting that the surface should be unmaximized, the compositor
+ * will respond by emitting a configure event without the "maximized"
+ * state. If available, the compositor will include the window geometry
+ * dimensions the window had prior to being maximized in the configure
+ * request. The client must then update its content, drawing it in a
+ * regular state, i.e. potentially with shadow, etc. The client must also
+ * acknowledge the configure when committing the new content (see
+ * ack_configure).
+ *
+ * It is up to the compositor to position the surface after it was
+ * unmaximized; usually the position the surface had before maximizing, if
+ * applicable.
+ *
+ * If the surface was already not maximized, the compositor will still
+ * emit a configure event without the "maximized" state.
+ */
+static inline void
+xdg_surface_unset_maximized(struct xdg_surface_v5 *xdg_surface)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_UNSET_MAXIMIZED);
+}
+
+/**
+ * @ingroup iface_xdg_surface
+ *
+ * Make the surface fullscreen.
+ *
+ * You can specify an output that you would prefer to be fullscreen.
+ * If this value is NULL, it's up to the compositor to choose which
+ * display will be used to map this surface.
+ *
+ * If the surface doesn't cover the whole output, the compositor will
+ * position the surface in the center of the output and compensate with
+ * black borders filling the rest of the output.
+ */
+static inline void
+xdg_surface_set_fullscreen(struct xdg_surface_v5 *xdg_surface, struct wl_output *output)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_SET_FULLSCREEN, output);
+}
+
+/**
+ * @ingroup iface_xdg_surface
+ */
+static inline void
+xdg_surface_unset_fullscreen(struct xdg_surface_v5 *xdg_surface)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_UNSET_FULLSCREEN);
+}
+
+/**
+ * @ingroup iface_xdg_surface
+ *
+ * Request that the compositor minimize your surface. There is no
+ * way to know if the surface is currently minimized, nor is there
+ * any way to unset minimization on this surface.
+ *
+ * If you are looking to throttle redrawing when minimized, please
+ * instead use the wl_surface.frame event for this, as this will
+ * also work with live previews on windows in Alt-Tab, Expose or
+ * similar compositor features.
+ */
+static inline void
+xdg_surface_set_minimized(struct xdg_surface_v5 *xdg_surface)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_SET_MINIMIZED);
+}
+
+/**
+ * @ingroup iface_xdg_popup
+ * @struct xdg_popup_listener
+ */
+struct xdg_popup_listener {
+ /**
+ * popup interaction is done
+ *
+ * The popup_done event is sent out when a popup is dismissed by
+ * the compositor. The client should destroy the xdg_popup_v5 object
+ * at this point.
+ */
+ void (*popup_done)(void *data,
+ struct xdg_popup_v5 *xdg_popup_v5);
+};
+
+/**
+ * @ingroup iface_xdg_popup
+ */
+static inline int
+xdg_popup_add_listener(struct xdg_popup_v5 *xdg_popup,
+ const struct xdg_popup_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) xdg_popup,
+ (void (**)(void)) listener, data);
+}
+
+#define XDG_POPUP_DESTROY 0
+
+/**
+ * @ingroup iface_xdg_popup
+ */
+#define XDG_POPUP_POPUP_DONE_SINCE_VERSION 1
+
+/**
+ * @ingroup iface_xdg_popup
+ */
+#define XDG_POPUP_DESTROY_SINCE_VERSION 1
+
+/** @ingroup iface_xdg_popup_v5 */
+static inline void
+xdg_popup_set_user_data(struct xdg_popup_v5 *xdg_popup, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) xdg_popup, user_data);
+}
+
+/** @ingroup iface_xdg_popup_v5 */
+static inline void *
+xdg_popup_get_user_data(struct xdg_popup_v5 *xdg_popup)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) xdg_popup);
+}
+
+static inline uint32_t
+xdg_popup_get_version(struct xdg_popup_v5 *xdg_popup)
+{
+ return wl_proxy_get_version((struct wl_proxy *) xdg_popup);
+}
+
+/**
+ * @ingroup iface_xdg_popup
+ *
+ * This destroys the popup. Explicitly destroying the xdg_popup
+ * object will also dismiss the popup, and unmap the surface.
+ *
+ * If this xdg_popup_v5 is not the "topmost" popup, a protocol error
+ * will be sent.
+ */
+static inline void
+xdg_popup_destroy(struct xdg_popup_v5 *xdg_popup)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_popup,
+ XDG_POPUP_DESTROY);
+
+ wl_proxy_destroy((struct wl_proxy *) xdg_popup);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c b/src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c
new file mode 100644
index 000000000..50a42437c
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/pregenerated/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c
@@ -0,0 +1,126 @@
+/* Generated by wayland-scanner 1.13.0 */
+// Hand-edited to resolve conflicts with xdg-shell stable
+
+/*
+ * Copyright © 2008-2013 Kristian Høgsberg
+ * Copyright © 2013 Rafael Antognolli
+ * Copyright © 2013 Jasper St. Pierre
+ * Copyright © 2010-2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+#include "wayland-util.h"
+
+extern const struct wl_interface wl_output_interface;
+extern const struct wl_interface wl_seat_interface;
+extern const struct wl_interface wl_surface_interface;
+extern const struct wl_interface xdg_popup_v5_interface;
+extern const struct wl_interface xdg_surface_v5_interface;
+
+static const struct wl_interface *types[] = {
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &xdg_surface_v5_interface,
+ &wl_surface_interface,
+ &xdg_popup_v5_interface,
+ &wl_surface_interface,
+ &wl_surface_interface,
+ &wl_seat_interface,
+ NULL,
+ NULL,
+ NULL,
+ &xdg_surface_v5_interface,
+ &wl_seat_interface,
+ NULL,
+ NULL,
+ NULL,
+ &wl_seat_interface,
+ NULL,
+ &wl_seat_interface,
+ NULL,
+ NULL,
+ &wl_output_interface,
+};
+
+static const struct wl_message xdg_shell_requests[] = {
+ { "destroy", "", types + 0 },
+ { "use_unstable_version", "i", types + 0 },
+ { "get_xdg_surface", "no", types + 4 },
+ { "get_xdg_popup", "nooouii", types + 6 },
+ { "pong", "u", types + 0 },
+};
+
+static const struct wl_message xdg_shell_events[] = {
+ { "ping", "u", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface xdg_shell_v5_interface = {
+ "xdg_shell", 1,
+ 5, xdg_shell_requests,
+ 1, xdg_shell_events,
+};
+
+static const struct wl_message xdg_surface_requests[] = {
+ { "destroy", "", types + 0 },
+ { "set_parent", "?o", types + 13 },
+ { "set_title", "s", types + 0 },
+ { "set_app_id", "s", types + 0 },
+ { "show_window_menu", "ouii", types + 14 },
+ { "move", "ou", types + 18 },
+ { "resize", "ouu", types + 20 },
+ { "ack_configure", "u", types + 0 },
+ { "set_window_geometry", "iiii", types + 0 },
+ { "set_maximized", "", types + 0 },
+ { "unset_maximized", "", types + 0 },
+ { "set_fullscreen", "?o", types + 23 },
+ { "unset_fullscreen", "", types + 0 },
+ { "set_minimized", "", types + 0 },
+};
+
+static const struct wl_message xdg_surface_events[] = {
+ { "configure", "iiau", types + 0 },
+ { "close", "", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface xdg_surface_v5_interface = {
+ "xdg_surface", 1,
+ 14, xdg_surface_requests,
+ 2, xdg_surface_events,
+};
+
+static const struct wl_message xdg_popup_requests[] = {
+ { "destroy", "", types + 0 },
+};
+
+static const struct wl_message xdg_popup_events[] = {
+ { "popup_done", "", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface xdg_popup_v5_interface = {
+ "xdg_popup", 1,
+ 1, xdg_popup_requests,
+ 1, xdg_popup_events,
+};
+
diff --git a/src/plugins/shellintegration/xdg-shell-v5/pregenerated/xdg-shell-v5.pri b/src/plugins/shellintegration/xdg-shell-v5/pregenerated/xdg-shell-v5.pri
new file mode 100644
index 000000000..2990fd0f6
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/pregenerated/xdg-shell-v5.pri
@@ -0,0 +1,12 @@
+# Putting pregenerated files in a 3rdparty directory to avoid
+# qtqa's license checking failing.
+
+HEADERS += \
+ $$PWD/3rdparty/qwayland-xdg-shell-unstable-v5_p.h \
+ $$PWD/3rdparty/wayland-xdg-shell-unstable-v5-client-protocol_p.h
+
+SOURCES += \
+ $$PWD/3rdparty/qwayland-xdg-shell-unstable-v5.cpp \
+ $$PWD/3rdparty/wayland-xdg-shell-unstable-v5-protocol.c
+
+INCLUDEPATH += $$PWD/3rdparty
diff --git a/src/client/qwaylandxdgpopup.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
index 46a12a828..85d25e3c0 100644
--- a/src/client/qwaylandxdgpopup.cpp
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
@@ -37,38 +37,32 @@
**
****************************************************************************/
-#include "qwaylandxdgpopup_p.h"
+#include "qwaylandxdgpopupv5_p.h"
-#include "qwaylandwindow_p.h"
-#include "qwaylanddisplay_p.h"
-#include "qwaylandextendedsurface_p.h"
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandextendedsurface_p.h>
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-QWaylandXdgPopup::QWaylandXdgPopup(struct ::xdg_popup *popup, QWaylandWindow *window)
+QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
: QWaylandShellSurface(window)
- , QtWayland::xdg_popup(popup)
+ , QtWayland::xdg_popup_v5(popup)
, m_window(window)
{
if (window->display()->windowExtension())
m_extendedWindow = new QWaylandExtendedSurface(window);
}
-QWaylandXdgPopup::~QWaylandXdgPopup()
+QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
{
xdg_popup_destroy(object());
delete m_extendedWindow;
}
-void QWaylandXdgPopup::setType(Qt::WindowType type, QWaylandWindow *transientParent)
-{
- Q_UNUSED(type);
- Q_UNUSED(transientParent);
-}
-
-void QWaylandXdgPopup::xdg_popup_popup_done()
+void QWaylandXdgPopupV5::xdg_popup_popup_done()
{
m_window->window()->close();
}
diff --git a/src/client/qwaylandxdgpopup_p.h b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
index b027c05dc..ff8e5639f 100644
--- a/src/client/qwaylandxdgpopup_p.h
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QWAYLANDXDGPOPUP_P_H
-#define QWAYLANDXDGPOPUP_P_H
+#ifndef QWAYLANDXDGPOPUPV5_P_H
+#define QWAYLANDXDGPOPUPV5_P_H
//
// W A R N I N G
@@ -51,10 +51,11 @@
// We mean it.
//
+#include "qwayland-xdg-shell-unstable-v5_p.h"
+
#include <wayland-client.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
-#include <QtWaylandClient/private/qwayland-xdg-shell.h>
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
QT_BEGIN_NAMESPACE
@@ -66,15 +67,13 @@ namespace QtWaylandClient {
class QWaylandWindow;
class QWaylandExtendedSurface;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopup : public QWaylandShellSurface
- , public QtWayland::xdg_popup
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ , public QtWayland::xdg_popup_v5
{
Q_OBJECT
public:
- QWaylandXdgPopup(struct ::xdg_popup *popup, QWaylandWindow *window);
- ~QWaylandXdgPopup() override;
-
- void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
+ QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
+ ~QWaylandXdgPopupV5() override;
protected:
void xdg_popup_popup_done() override;
@@ -88,4 +87,4 @@ QT_END_NAMESPACE
}
-#endif // QWAYLANDXDGPOPUP_P_H
+#endif // QWAYLANDXDGPOPUPV5_P_H
diff --git a/src/client/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
index 9a34e72dd..4cbafbd71 100644
--- a/src/client/qwaylandxdgshell.cpp
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
@@ -37,43 +37,38 @@
**
****************************************************************************/
-#include "qwaylandxdgshell_p.h"
-
-#include "qwaylanddisplay_p.h"
-#include "qwaylandwindow_p.h"
-#include "qwaylandinputdevice_p.h"
-#include "qwaylandscreen_p.h"
-#include "qwaylandxdgpopup_p.h"
-#include "qwaylandxdgsurface_p.h"
+#include "qwaylandxdgshellv5_p.h"
+#include "qwaylandxdgpopupv5_p.h"
+#include "qwaylandxdgsurfacev5_p.h"
#include <QtCore/QDebug>
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
+#include <QtWaylandClient/private/qwaylandscreen_p.h>
+
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-QWaylandXdgShell::QWaylandXdgShell(struct ::xdg_shell *shell)
- : QtWayland::xdg_shell(shell)
-{
-}
-
-QWaylandXdgShell::QWaylandXdgShell(struct ::wl_registry *registry, uint32_t id)
- : QtWayland::xdg_shell(registry, id, 1)
+QWaylandXdgShellV5::QWaylandXdgShellV5(struct ::wl_registry *registry, uint32_t id)
+ : QtWayland::xdg_shell_v5(registry, id, 1)
{
- use_unstable_version(QtWayland::xdg_shell::version_current);
+ use_unstable_version(QtWayland::xdg_shell_v5::version_current);
}
-QWaylandXdgShell::~QWaylandXdgShell()
+QWaylandXdgShellV5::~QWaylandXdgShellV5()
{
xdg_shell_destroy(object());
}
-QWaylandXdgSurface *QWaylandXdgShell::createXdgSurface(QWaylandWindow *window)
+QWaylandXdgSurfaceV5 *QWaylandXdgShellV5::createXdgSurface(QWaylandWindow *window)
{
- return new QWaylandXdgSurface(this, window);
+ return new QWaylandXdgSurfaceV5(this, window);
}
-QWaylandXdgPopup *QWaylandXdgShell::createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice)
+QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice)
{
QWaylandWindow *parentWindow = m_popups.empty() ? window->transientParent() : m_popups.last();
::wl_surface *parentSurface = parentWindow->object();
@@ -86,9 +81,9 @@ QWaylandXdgPopup *QWaylandXdgShell::createXdgPopup(QWaylandWindow *window, QWayl
int x = position.x() + parentWindow->frameMargins().left();
int y = position.y() + parentWindow->frameMargins().top();
- auto popup = new QWaylandXdgPopup(get_xdg_popup(window->object(), parentSurface, seat, m_popupSerial, x, y), window);
+ auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->object(), parentSurface, seat, m_popupSerial, x, y), window);
m_popups.append(window);
- QObject::connect(popup, &QWaylandXdgPopup::destroyed, [this, window](){
+ QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
m_popups.removeOne(window);
if (m_popups.empty())
m_popupSerial = 0;
@@ -96,7 +91,7 @@ QWaylandXdgPopup *QWaylandXdgShell::createXdgPopup(QWaylandWindow *window, QWayl
return popup;
}
-void QWaylandXdgShell::xdg_shell_ping(uint32_t serial)
+void QWaylandXdgShellV5::xdg_shell_ping(uint32_t serial)
{
pong(serial);
}
diff --git a/src/client/qwaylandxdgshell_p.h b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5_p.h
index 761f25218..67e5d32a7 100644
--- a/src/client/qwaylandxdgshell_p.h
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QWAYLANDXDGSHELL_H
-#define QWAYLANDXDGSHELL_H
+#ifndef QWAYLANDXDGSHELLV5_H
+#define QWAYLANDXDGSHELLV5_H
//
// W A R N I N G
@@ -51,12 +51,13 @@
// We mean it.
//
+#include "qwayland-xdg-shell-unstable-v5_p.h"
+
#include <QtCore/QSize>
#include <QtCore/QVector>
#include <wayland-client.h>
-#include <QtWaylandClient/private/qwayland-xdg-shell.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
@@ -68,18 +69,17 @@ namespace QtWaylandClient {
class QWaylandWindow;
class QWaylandInputDevice;
-class QWaylandXdgSurface;
-class QWaylandXdgPopup;
+class QWaylandXdgSurfaceV5;
+class QWaylandXdgPopupV5;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShell : public QtWayland::xdg_shell
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellV5 : public QtWayland::xdg_shell_v5
{
public:
- QWaylandXdgShell(struct ::xdg_shell *shell);
- QWaylandXdgShell(struct ::wl_registry *registry, uint32_t id);
- ~QWaylandXdgShell() override;
+ QWaylandXdgShellV5(struct ::wl_registry *registry, uint32_t id);
+ ~QWaylandXdgShellV5() override;
- QWaylandXdgSurface *createXdgSurface(QWaylandWindow *window);
- QWaylandXdgPopup *createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice);
+ QWaylandXdgSurfaceV5 *createXdgSurface(QWaylandWindow *window);
+ QWaylandXdgPopupV5 *createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice);
private:
void xdg_shell_ping(uint32_t serial) override;
@@ -92,4 +92,4 @@ QT_END_NAMESPACE
}
-#endif // QWAYLANDXDGSHELL_H
+#endif // QWAYLANDXDGSHELLV5_H
diff --git a/src/client/qwaylandxdgshellintegration.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
index ee72c2d52..d032002b1 100644
--- a/src/client/qwaylandxdgshellintegration.cpp
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
@@ -37,42 +37,40 @@
**
****************************************************************************/
-#include "qwaylandxdgshellintegration_p.h"
+#include "qwaylandxdgshellv5integration_p.h"
+#include "qwaylandxdgsurfacev5_p.h"
+#include "qwaylandxdgpopupv5_p.h"
+#include "qwaylandxdgshellv5_p.h"
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
-#include <QtWaylandClient/private/qwaylandxdgsurface_p.h>
-#include <QtWaylandClient/private/qwaylandxdgpopup_p.h>
-#include <QtWaylandClient/private/qwaylandxdgshell_p.h>
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-QWaylandXdgShellIntegration *QWaylandXdgShellIntegration::create(QWaylandDisplay *display)
+bool QWaylandXdgShellV5Integration::initialize(QWaylandDisplay *display)
{
- if (display->hasRegistryGlobal(QLatin1String("xdg_shell")))
- return new QWaylandXdgShellIntegration(display);
- return nullptr;
-}
+ qCWarning(lcQpaWayland) << "\"xdg-shell-v5\" is a deprecated shell extension, prefer using"
+ << "\"xdg-shell-v6\" or \"xdg-shell\" if supported by the compositor"
+ << "by setting the environment variable QT_WAYLAND_SHELL_INTEGRATION";
-QWaylandXdgShellIntegration::QWaylandXdgShellIntegration(QWaylandDisplay *display)
-{
Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) {
if (global.interface == QLatin1String("xdg_shell")) {
- m_xdgShell = new QWaylandXdgShell(display->wl_registry(), global.id);
+ m_xdgShell.reset(new QWaylandXdgShellV5(display->wl_registry(), global.id));
break;
}
}
-}
-bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display)
-{
- QWaylandShellIntegration::initialize(display);
- return m_xdgShell != nullptr;
+ if (!m_xdgShell) {
+ qWarning() << "Couldn't find global xdg_shell for xdg-shell unstable v5";
+ return false;
+ }
+
+ return QWaylandShellIntegration::initialize(display);
}
-QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window)
+QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWaylandWindow *window)
{
QWaylandInputDevice *inputDevice = window->display()->lastInputDevice();
if (window->window()->type() == Qt::WindowType::Popup && inputDevice)
@@ -81,10 +79,10 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
return m_xdgShell->createXdgSurface(window);
}
-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
- if (newFocus && qobject_cast<QWaylandXdgPopup *>(newFocus->shellSurface()))
+void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+ if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
m_display->handleWindowActivated(newFocus);
- if (oldFocus && qobject_cast<QWaylandXdgPopup *>(oldFocus->shellSurface()))
+ if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
m_display->handleWindowDeactivated(oldFocus);
}
diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
new file mode 100644
index 000000000..ce6bdb9ee
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXDGSHELLV5INTEGRATION_P_H
+#define QWAYLANDXDGSHELLV5INTEGRATION_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qwaylandxdgshellv5_p.h"
+
+#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class QWaylandXdgShellV5;
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellV5Integration : public QWaylandShellIntegration
+{
+public:
+ QWaylandXdgShellV5Integration() {}
+ bool initialize(QWaylandDisplay *display) override;
+ QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+ void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+
+private:
+ QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXDGSHELLV5INTEGRATION_P_H
diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp
new file mode 100644
index 000000000..61a865cb2
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp
@@ -0,0 +1,237 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgsurfacev5_p.h"
+#include "qwaylandxdgshellv5_p.h"
+
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
+#include <QtWaylandClient/private/qwaylandabstractdecoration_p.h>
+#include <QtWaylandClient/private/qwaylandscreen_p.h>
+#include <QtWaylandClient/private/qwaylandextendedsurface_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+QWaylandXdgSurfaceV5::QWaylandXdgSurfaceV5(QWaylandXdgShellV5 *shell, QWaylandWindow *window)
+ : QWaylandShellSurface(window)
+ , QtWayland::xdg_surface_v5(shell->get_xdg_surface(window->object()))
+ , m_window(window)
+ , m_shell(shell)
+{
+ if (window->display()->windowExtension())
+ m_extendedWindow = new QWaylandExtendedSurface(window);
+
+ updateTransientParent(window->transientParent());
+}
+
+QWaylandXdgSurfaceV5::~QWaylandXdgSurfaceV5()
+{
+ if (m_acked.states & Qt::WindowActive)
+ window()->display()->handleWindowDeactivated(m_window);
+
+ xdg_surface_destroy(object());
+ delete m_extendedWindow;
+}
+
+void QWaylandXdgSurfaceV5::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
+{
+ // May need some conversion if types get incompatibles, ATM they're identical
+ enum resize_edge const * const arg = reinterpret_cast<enum resize_edge const *>(&edges);
+ resize(inputDevice, *arg);
+}
+
+void QWaylandXdgSurfaceV5::resize(QWaylandInputDevice *inputDevice, enum resize_edge edges)
+{
+ resize(inputDevice->wl_seat(),
+ inputDevice->serial(),
+ edges);
+}
+
+bool QWaylandXdgSurfaceV5::move(QWaylandInputDevice *inputDevice)
+{
+ move(inputDevice->wl_seat(),
+ inputDevice->serial());
+ return true;
+}
+
+void QWaylandXdgSurfaceV5::updateTransientParent(QWaylandWindow *parent)
+{
+ if (!parent)
+ return;
+ auto parentXdgSurface = qobject_cast<QWaylandXdgSurfaceV5 *>(parent->shellSurface());
+ Q_ASSERT(parentXdgSurface);
+ set_parent(parentXdgSurface->object());
+}
+
+void QWaylandXdgSurfaceV5::setTitle(const QString & title)
+{
+ return QtWayland::xdg_surface_v5::set_title(title);
+}
+
+void QWaylandXdgSurfaceV5::setAppId(const QString & appId)
+{
+ return QtWayland::xdg_surface_v5::set_app_id(appId);
+}
+
+void QWaylandXdgSurfaceV5::raise()
+{
+ if (m_extendedWindow)
+ m_extendedWindow->raise();
+}
+
+void QWaylandXdgSurfaceV5::lower()
+{
+ if (m_extendedWindow)
+ m_extendedWindow->lower();
+}
+
+void QWaylandXdgSurfaceV5::setContentOrientationMask(Qt::ScreenOrientations orientation)
+{
+ if (m_extendedWindow)
+ m_extendedWindow->setContentOrientationMask(orientation);
+}
+
+void QWaylandXdgSurfaceV5::setWindowFlags(Qt::WindowFlags flags)
+{
+ if (m_extendedWindow)
+ m_extendedWindow->setWindowFlags(flags);
+}
+
+void QWaylandXdgSurfaceV5::sendProperty(const QString &name, const QVariant &value)
+{
+ if (m_extendedWindow)
+ m_extendedWindow->updateGenericProperty(name, value);
+}
+
+void QWaylandXdgSurfaceV5::applyConfigure()
+{
+ if (m_pending.isResizing)
+ m_normalSize = m_pending.size;
+ else if (!(m_acked.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+ m_normalSize = m_window->window()->frameGeometry().size();
+
+ if ((m_pending.states & Qt::WindowActive) && !(m_acked.states & Qt::WindowActive))
+ m_window->display()->handleWindowActivated(m_window);
+
+ if (!(m_pending.states & Qt::WindowActive) && (m_acked.states & Qt::WindowActive))
+ m_window->display()->handleWindowDeactivated(m_window);
+
+ // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+ Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+
+ m_window->handleWindowStatesChanged(statesWithoutActive);
+ if (!m_pending.size.isEmpty())
+ m_window->resizeFromApplyConfigure(m_pending.size);
+ else if (!m_normalSize.isEmpty())
+ m_window->resizeFromApplyConfigure(m_normalSize);
+ ack_configure(m_pending.serial);
+ m_acked = m_pending;
+}
+
+void QWaylandXdgSurfaceV5::requestWindowStates(Qt::WindowStates states)
+{
+ Qt::WindowStates changedStates = m_acked.states ^ states;
+
+ if (changedStates & Qt::WindowMaximized) {
+ if (states & Qt::WindowMaximized)
+ set_maximized();
+ else
+ unset_maximized();
+ }
+
+ if (changedStates & Qt::WindowFullScreen) {
+ if (states & Qt::WindowFullScreen)
+ set_fullscreen(nullptr);
+ else
+ unset_fullscreen();
+ }
+
+ // Minimized state is not reported by the protocol, so always send it
+ if (states & Qt::WindowMinimized) {
+ set_minimized();
+ window()->handleWindowStatesChanged(states & ~Qt::WindowMinimized);
+ }
+}
+
+bool QWaylandXdgSurfaceV5::wantsDecorations() const
+{
+ return !(m_pending.states & Qt::WindowFullScreen);
+}
+
+void QWaylandXdgSurfaceV5::xdg_surface_configure(int32_t width, int32_t height, struct wl_array *states,uint32_t serial)
+{
+ uint32_t *xdgStates = reinterpret_cast<uint32_t*>(states->data);
+ size_t numStates = states->size / sizeof(uint32_t);
+ m_pending.serial = serial;
+ m_pending.size = QSize(width, height);
+ m_pending.isResizing = false;
+ m_pending.states = Qt::WindowNoState;
+ for (size_t i = 0; i < numStates; i++) {
+ switch (xdgStates[i]) {
+ case XDG_SURFACE_STATE_MAXIMIZED:
+ m_pending.states |= Qt::WindowMaximized;
+ break;
+ case XDG_SURFACE_STATE_FULLSCREEN:
+ m_pending.states |= Qt::WindowFullScreen;
+ break;
+ case XDG_SURFACE_STATE_RESIZING:
+ m_pending.isResizing = true;
+ break;
+ case XDG_SURFACE_STATE_ACTIVATED:
+ m_pending.states |= Qt::WindowActive;
+ break;
+ default:
+ break;
+ }
+ }
+ m_window->applyConfigureWhenPossible();
+}
+
+void QWaylandXdgSurfaceV5::xdg_surface_close()
+{
+ m_window->window()->close();
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/client/qwaylandxdgsurface_p.h b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h
index b8dd93f47..b938047ec 100644
--- a/src/client/qwaylandxdgsurface_p.h
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QWAYLANDXDGSURFACE_H
-#define QWAYLANDXDGSURFACE_H
+#ifndef QWAYLANDXDGSURFACEV5_P_H
+#define QWAYLANDXDGSURFACEV5_P_H
//
// W A R N I N G
@@ -51,15 +51,16 @@
// We mean it.
//
+#include "qwayland-xdg-shell-unstable-v5_p.h"
+
+#include <QtWaylandClient/qtwaylandclientglobal.h>
+#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
+
#include <QtCore/QSize>
#include <QtCore/QMargins>
#include <wayland-client.h>
-#include <QtWaylandClient/qtwaylandclientglobal.h>
-#include <QtWaylandClient/private/qwayland-xdg-shell.h>
-#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
-
QT_BEGIN_NAMESPACE
class QWindow;
@@ -69,22 +70,22 @@ namespace QtWaylandClient {
class QWaylandWindow;
class QWaylandInputDevice;
class QWaylandExtendedSurface;
-class QWaylandXdgShell;
+class QWaylandXdgShellV5;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgSurface : public QWaylandShellSurface
- , public QtWayland::xdg_surface
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgSurfaceV5 : public QWaylandShellSurface
+ , public QtWayland::xdg_surface_v5
{
Q_OBJECT
public:
- QWaylandXdgSurface(QWaylandXdgShell *shell, QWaylandWindow *window);
- ~QWaylandXdgSurface() override;
+ QWaylandXdgSurfaceV5(QWaylandXdgShellV5 *shell, QWaylandWindow *window);
+ ~QWaylandXdgSurfaceV5() override;
- using QtWayland::xdg_surface::resize;
+ using QtWayland::xdg_surface_v5::resize;
void resize(QWaylandInputDevice *inputDevice, enum resize_edge edges);
void resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges) override;
- using QtWayland::xdg_surface::move;
+ using QtWayland::xdg_surface_v5::move;
bool move(QWaylandInputDevice *inputDevice) override;
void setTitle(const QString &title) override;
@@ -96,26 +97,22 @@ public:
void setWindowFlags(Qt::WindowFlags flags) override;
void sendProperty(const QString &name, const QVariant &value) override;
- bool isFullscreen() const { return m_fullscreen; }
- bool isMaximized() const { return m_maximized; }
-
- void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
+ void applyConfigure() override;
+ void requestWindowStates(Qt::WindowStates states) override;
+ bool wantsDecorations() const override;
private:
- void setMaximized() override;
- void setFullscreen() override;
- void setNormal() override;
- void setMinimized() override;
-
void updateTransientParent(QWaylandWindow *parent);
private:
QWaylandWindow *m_window = nullptr;
- QWaylandXdgShell* m_shell = nullptr;
- bool m_maximized = false;
- bool m_minimized = false;
- bool m_fullscreen = false;
- bool m_active = false;
+ QWaylandXdgShellV5* m_shell = nullptr;
+ struct {
+ Qt::WindowStates states = Qt::WindowNoState;
+ bool isResizing = false;
+ QSize size = {0, 0};
+ uint serial = 0;
+ } m_acked, m_pending;
QSize m_normalSize;
QMargins m_margins;
QWaylandExtendedSurface *m_extendedWindow = nullptr;
@@ -133,4 +130,4 @@ QT_END_NAMESPACE
}
-#endif // QWAYLANDXDGSURFACE_H
+#endif // QWAYLANDXDGSURFACEV5_P_H
diff --git a/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.json b/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.json
new file mode 100644
index 000000000..ba1ed4489
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.json
@@ -0,0 +1,3 @@
+{
+ "Keys":[ "xdg-shell-v5" ]
+}
diff --git a/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.pro b/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.pro
new file mode 100644
index 000000000..bf9edba78
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.pro
@@ -0,0 +1,29 @@
+QT += gui-private waylandclient-private
+CONFIG += wayland-scanner
+
+QMAKE_USE += wayland-client
+
+qtConfig(xkbcommon-evdev): \
+ QMAKE_USE += xkbcommon_evdev
+
+HEADERS += \
+ qwaylandxdgpopupv5_p.h \
+ qwaylandxdgshellv5_p.h \
+ qwaylandxdgshellv5integration_p.h \
+ qwaylandxdgsurfacev5_p.h \
+
+SOURCES += \
+ main.cpp \
+ qwaylandxdgpopupv5.cpp \
+ qwaylandxdgshellv5.cpp \
+ qwaylandxdgshellv5integration.cpp \
+ qwaylandxdgsurfacev5.cpp \
+
+include (pregenerated/xdg-shell-v5.pri)
+
+OTHER_FILES += \
+ xdg-shell-v5.json
+
+PLUGIN_TYPE = wayland-shell-integration
+PLUGIN_CLASS_NAME = QWaylandXdgShellV5IntegrationPlugin
+load(qt_plugin)
diff --git a/src/plugins/shellintegration/xdg-shell-v6/main.cpp b/src/plugins/shellintegration/xdg-shell-v6/main.cpp
new file mode 100644
index 000000000..8cd302f32
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v6/main.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshellv6integration_p.h"
+
+#include <QtWaylandClient/private/qwaylandshellintegrationplugin_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class QWaylandXdgShellV6IntegrationPlugin : public QWaylandShellIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QWaylandShellIntegrationFactoryInterface_iid FILE "xdg-shell-v6.json")
+
+public:
+ QWaylandShellIntegration *create(const QString &key, const QStringList &paramList) override;
+};
+
+QWaylandShellIntegration *QWaylandXdgShellV6IntegrationPlugin::create(const QString &key, const QStringList &paramList)
+{
+ Q_UNUSED(key);
+ Q_UNUSED(paramList);
+ return new QWaylandXdgShellV6Integration();
+}
+
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/client/qwaylandxdgshellv6.cpp b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
index 2c910d116..1dc43b371 100644
--- a/src/client/qwaylandxdgshellv6.cpp
+++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
@@ -40,13 +40,11 @@
#include "qwaylandxdgshellv6_p.h"
-#include "qwaylanddisplay_p.h"
-#include "qwaylandwindow_p.h"
-#include "qwaylandinputdevice_p.h"
-#include "qwaylandscreen_p.h"
-#include "qwaylandabstractdecoration_p.h"
-
-#include <QtCore/QDebug>
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
+#include <QtWaylandClient/private/qwaylandscreen_p.h>
+#include <QtWaylandClient/private/qwaylandabstractdecoration_p.h>
QT_BEGIN_NAMESPACE
@@ -56,32 +54,69 @@ QWaylandXdgSurfaceV6::Toplevel::Toplevel(QWaylandXdgSurfaceV6 *xdgSurface)
: QtWayland::zxdg_toplevel_v6(xdgSurface->get_toplevel())
, m_xdgSurface(xdgSurface)
{
+ requestWindowStates(xdgSurface->window()->window()->windowStates());
}
QWaylandXdgSurfaceV6::Toplevel::~Toplevel()
{
+ if (m_applied.states & Qt::WindowActive) {
+ QWaylandWindow *window = m_xdgSurface->window();
+ window->display()->handleWindowDeactivated(window);
+ }
if (isInitialized())
destroy();
}
void QWaylandXdgSurfaceV6::Toplevel::applyConfigure()
{
- //TODO: resize, activate etc
- m_xdgSurface->m_window->configure(0, m_configureState.width, m_configureState.height);
+ if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+ m_normalSize = m_xdgSurface->m_window->window()->frameGeometry().size();
+
+ if (m_pending.size.isEmpty() && !m_normalSize.isEmpty())
+ m_pending.size = m_normalSize;
+
+ if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
+ m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+
+ if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
+ m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+
+ // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+ Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+
+ m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
+ m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+ QSize windowGeometrySize = m_xdgSurface->m_window->window()->frameGeometry().size();
+ m_xdgSurface->set_window_geometry(0, 0, windowGeometrySize.width(), windowGeometrySize.height());
+ m_applied = m_pending;
}
void QWaylandXdgSurfaceV6::Toplevel::zxdg_toplevel_v6_configure(int32_t width, int32_t height, wl_array *states)
{
- m_configureState.width = width;
- m_configureState.height = height;
+ m_pending.size = QSize(width, height);
- uint32_t *state = reinterpret_cast<uint32_t *>(states->data);
+ auto *xdgStates = static_cast<uint32_t *>(states->data);
size_t numStates = states->size / sizeof(uint32_t);
- m_configureState.states.reserve(numStates);
- m_configureState.states.clear();
- for (size_t i = 0; i < numStates; i++)
- m_configureState.states << state[i];
+ m_pending.states = Qt::WindowNoState;
+
+ for (size_t i = 0; i < numStates; i++) {
+ switch (xdgStates[i]) {
+ case ZXDG_TOPLEVEL_V6_STATE_ACTIVATED:
+ m_pending.states |= Qt::WindowActive;
+ break;
+ case ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED:
+ m_pending.states |= Qt::WindowMaximized;
+ break;
+ case ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN:
+ m_pending.states |= Qt::WindowFullScreen;
+ break;
+ default:
+ break;
+ }
+ }
+ qCDebug(lcQpaWayland) << "Received zxdg_toplevel_v6.configure with" << m_pending.size
+ << "and" << m_pending.states;
}
void QWaylandXdgSurfaceV6::Toplevel::zxdg_toplevel_v6_close()
@@ -89,6 +124,32 @@ void QWaylandXdgSurfaceV6::Toplevel::zxdg_toplevel_v6_close()
m_xdgSurface->m_window->window()->close();
}
+void QWaylandXdgSurfaceV6::Toplevel::requestWindowStates(Qt::WindowStates states)
+{
+ // Re-send what's different from the applied state
+ Qt::WindowStates changedStates = m_applied.states ^ states;
+
+ if (changedStates & Qt::WindowMaximized) {
+ if (states & Qt::WindowMaximized)
+ set_maximized();
+ else
+ unset_maximized();
+ }
+
+ if (changedStates & Qt::WindowFullScreen) {
+ if (states & Qt::WindowFullScreen)
+ set_fullscreen(nullptr);
+ else
+ unset_fullscreen();
+ }
+
+ // Minimized state is not reported by the protocol, so always send it
+ if (states & Qt::WindowMinimized) {
+ set_minimized();
+ m_xdgSurface->window()->handleWindowStatesChanged(states & ~Qt::WindowMinimized);
+ }
+}
+
QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdgSurfaceV6 *parent,
QtWayland::zxdg_positioner_v6 *positioner)
: zxdg_popup_v6(xdgSurface->get_popup(parent->object(), positioner->object()))
@@ -109,11 +170,6 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
}
}
-void QWaylandXdgSurfaceV6::Popup::applyConfigure()
-{
-
-}
-
void QWaylandXdgSurfaceV6::Popup::grab(QWaylandInputDevice *seat, uint serial)
{
m_xdgSurface->m_shell->m_topmostPopup = this;
@@ -132,6 +188,20 @@ QWaylandXdgSurfaceV6::QWaylandXdgSurfaceV6(QWaylandXdgShellV6 *shell, ::zxdg_sur
, m_shell(shell)
, m_window(window)
{
+ QWaylandDisplay *display = window->display();
+ Qt::WindowType type = window->window()->type();
+ auto *transientParent = window->transientParent();
+
+ if ((type == Qt::Popup || type == Qt::ToolTip) && transientParent && display->lastInputDevice()) {
+ setPopup(transientParent, display->lastInputDevice(), display->lastInputSerial(), type == Qt::Popup);
+ } else {
+ setToplevel();
+ if (transientParent) {
+ auto parentXdgSurface = static_cast<QWaylandXdgSurfaceV6 *>(transientParent->shellSurface());
+ if (parentXdgSurface)
+ m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+ }
+ }
}
QWaylandXdgSurfaceV6::~QWaylandXdgSurfaceV6()
@@ -155,7 +225,7 @@ void QWaylandXdgSurfaceV6::resize(QWaylandInputDevice *inputDevice, zxdg_topleve
void QWaylandXdgSurfaceV6::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
{
- auto xdgEdges = reinterpret_cast<enum zxdg_toplevel_v6_resize_edge const * const>(&edges);
+ auto xdgEdges = reinterpret_cast<enum zxdg_toplevel_v6_resize_edge const *>(&edges);
resize(inputDevice, *xdgEdges);
}
@@ -181,21 +251,6 @@ void QWaylandXdgSurfaceV6::setAppId(const QString &appId)
m_toplevel->set_app_id(appId);
}
-void QWaylandXdgSurfaceV6::setType(Qt::WindowType type, QWaylandWindow *transientParent)
-{
- QWaylandDisplay *display = m_window->display();
- if ((type == Qt::Popup || type == Qt::ToolTip) && transientParent && display->lastInputDevice()) {
- setPopup(transientParent, display->lastInputDevice(), display->lastInputSerial(), type == Qt::Popup);
- } else {
- setToplevel();
- if (transientParent) {
- auto parentXdgSurface = static_cast<QWaylandXdgSurfaceV6 *>(transientParent->shellSurface());
- if (parentXdgSurface)
- m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
- }
- }
-}
-
bool QWaylandXdgSurfaceV6::handleExpose(const QRegion &region)
{
if (!m_configured && !region.isEmpty()) {
@@ -205,6 +260,32 @@ bool QWaylandXdgSurfaceV6::handleExpose(const QRegion &region)
return false;
}
+void QWaylandXdgSurfaceV6::applyConfigure()
+{
+ Q_ASSERT(m_pendingConfigureSerial != 0);
+
+ if (m_toplevel)
+ m_toplevel->applyConfigure();
+
+ m_configured = true;
+ ack_configure(m_pendingConfigureSerial);
+
+ m_pendingConfigureSerial = 0;
+}
+
+bool QWaylandXdgSurfaceV6::wantsDecorations() const
+{
+ return m_toplevel && !(m_toplevel->m_pending.states & Qt::WindowFullScreen);
+}
+
+void QWaylandXdgSurfaceV6::requestWindowStates(Qt::WindowStates states)
+{
+ if (m_toplevel)
+ m_toplevel->requestWindowStates(states);
+ else
+ qCWarning(lcQpaWayland) << "Non-toplevel surfaces can't request window states";
+}
+
void QWaylandXdgSurfaceV6::setToplevel()
{
Q_ASSERT(!m_toplevel && !m_popup);
@@ -245,21 +326,14 @@ void QWaylandXdgSurfaceV6::setPopup(QWaylandWindow *parent, QWaylandInputDevice
void QWaylandXdgSurfaceV6::zxdg_surface_v6_configure(uint32_t serial)
{
- m_configured = true;
- if (m_toplevel)
- m_toplevel->applyConfigure();
- else if (m_popup)
- m_popup->applyConfigure();
-
+ m_window->applyConfigureWhenPossible();
+ m_pendingConfigureSerial = serial;
if (!m_exposeRegion.isEmpty()) {
QWindowSystemInterface::handleExposeEvent(m_window->window(), m_exposeRegion);
m_exposeRegion = QRegion();
}
- ack_configure(serial);
}
-
-
QWaylandXdgShellV6::QWaylandXdgShellV6(struct ::wl_registry *registry, uint32_t id, uint32_t availableVersion)
: QtWayland::zxdg_shell_v6(registry, id, qMin(availableVersion, 1u))
{
diff --git a/src/client/qwaylandxdgshellv6_p.h b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h
index e6434c02f..38b711f88 100644
--- a/src/client/qwaylandxdgshellv6_p.h
+++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h
@@ -52,15 +52,16 @@
// We mean it.
//
+#include "qwayland-xdg-shell-unstable-v6.h"
+
+#include <QtWaylandClient/qtwaylandclientglobal.h>
+#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
+
#include <QtCore/QSize>
#include <QtGui/QRegion>
#include <wayland-client.h>
-#include <QtWaylandClient/private/qwayland-xdg-shell-unstable-v6.h>
-#include <QtWaylandClient/qtwaylandclientglobal.h>
-#include "qwaylandshellsurface_p.h"
-
QT_BEGIN_NAMESPACE
class QWindow;
@@ -73,6 +74,7 @@ class QWaylandXdgShellV6;
class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgSurfaceV6 : public QWaylandShellSurface, public QtWayland::zxdg_surface_v6
{
+ Q_OBJECT
public:
QWaylandXdgSurfaceV6(QWaylandXdgShellV6 *shell, ::zxdg_surface_v6 *surface, QWaylandWindow *window);
~QWaylandXdgSurfaceV6() override;
@@ -83,10 +85,14 @@ public:
void setTitle(const QString &title) override;
void setAppId(const QString &appId) override;
- void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
+ bool isExposed() const override { return m_configured; }
bool handleExpose(const QRegion &) override;
+ bool handlesActiveState() const { return m_toplevel; }
+ void applyConfigure() override;
+ bool wantsDecorations() const override;
protected:
+ void requestWindowStates(Qt::WindowStates states) override;
void zxdg_surface_v6_configure(uint32_t serial) override;
private:
@@ -101,10 +107,12 @@ private:
void zxdg_toplevel_v6_configure(int32_t width, int32_t height, wl_array *states) override;
void zxdg_toplevel_v6_close() override;
+ void requestWindowStates(Qt::WindowStates states);
struct {
- int32_t width, height;
- QVarLengthArray<uint32_t> states;
- } m_configureState;
+ QSize size = {0, 0};
+ Qt::WindowStates states = Qt::WindowNoState;
+ } m_pending, m_applied;
+ QSize m_normalSize;
QWaylandXdgSurfaceV6 *m_xdgSurface = nullptr;
};
@@ -114,7 +122,6 @@ private:
Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdgSurfaceV6 *parent, QtWayland::zxdg_positioner_v6 *positioner);
~Popup() override;
- void applyConfigure();
void grab(QWaylandInputDevice *seat, uint serial);
void zxdg_popup_v6_popup_done() override;
@@ -132,6 +139,7 @@ private:
Popup *m_popup = nullptr;
bool m_configured = false;
QRegion m_exposeRegion;
+ uint m_pendingConfigureSerial = 0;
friend class QWaylandXdgShellV6;
};
diff --git a/src/client/qwaylandxdgshellv6integration.cpp b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
index cb82354b6..031643165 100644
--- a/src/client/qwaylandxdgshellv6integration.cpp
+++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
@@ -41,36 +41,26 @@
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
-#include <QtWaylandClient/private/qwaylandxdgsurface_p.h>
-#include <QtWaylandClient/private/qwaylandxdgpopup_p.h>
-#include <QtWaylandClient/private/qwaylandxdgshell_p.h>
-#include <QtWaylandClient/private/qwaylandxdgshellv6_p.h>
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-QWaylandXdgShellV6Integration::QWaylandXdgShellV6Integration(QWaylandDisplay *display)
+bool QWaylandXdgShellV6Integration::initialize(QWaylandDisplay *display)
{
for (QWaylandDisplay::RegistryGlobal global : display->globals()) {
if (global.interface == QLatin1String("zxdg_shell_v6")) {
- m_xdgShell = new QWaylandXdgShellV6(display->wl_registry(), global.id, global.version);
+ m_xdgShell.reset(new QWaylandXdgShellV6(display->wl_registry(), global.id, global.version));
break;
}
}
-}
-QWaylandXdgShellV6Integration *QWaylandXdgShellV6Integration::create(QWaylandDisplay *display)
-{
- if (display->hasRegistryGlobal(QLatin1String("zxdg_shell_v6")))
- return new QWaylandXdgShellV6Integration(display);
- return nullptr;
-}
+ if (!m_xdgShell) {
+ qCDebug(lcQpaWayland) << "Couldn't find global zxdg_shell_v6 for xdg-shell unstable v6";
+ return false;
+ }
-bool QWaylandXdgShellV6Integration::initialize(QWaylandDisplay *display)
-{
- QWaylandShellIntegration::initialize(display);
- return m_xdgShell != nullptr;
+ return QWaylandShellIntegration::initialize(display);
}
QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWaylandWindow *window)
@@ -78,6 +68,20 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
return m_xdgShell->getXdgSurface(window);
}
+void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+{
+ if (newFocus) {
+ auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+ if (xdgSurface && !xdgSurface->handlesActiveState())
+ m_display->handleWindowActivated(newFocus);
+ }
+ if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+ auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+ if (xdgSurface && !xdgSurface->handlesActiveState())
+ m_display->handleWindowDeactivated(oldFocus);
+ }
+}
+
}
QT_END_NAMESPACE
diff --git a/src/client/qwaylandxdgshellv6integration_p.h b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
index bdfd19723..261f8cbb4 100644
--- a/src/client/qwaylandxdgshellv6integration_p.h
+++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <wayland-client.h>
+#include "qwaylandxdgshellv6_p.h"
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
@@ -59,19 +59,16 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-class QWaylandXdgShellV6;
-
class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellV6Integration : public QWaylandShellIntegration
{
public:
- static QWaylandXdgShellV6Integration *create(QWaylandDisplay* display);
+ QWaylandXdgShellV6Integration() {}
bool initialize(QWaylandDisplay *display) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+ void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
private:
- QWaylandXdgShellV6Integration(QWaylandDisplay *display);
-
- QWaylandXdgShellV6 *m_xdgShell = nullptr;
+ QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
};
}
diff --git a/src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.json b/src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.json
new file mode 100644
index 000000000..b1b8db31b
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.json
@@ -0,0 +1,3 @@
+{
+ "Keys":[ "xdg-shell-v6" ]
+}
diff --git a/src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.pro b/src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.pro
new file mode 100644
index 000000000..5d5046f60
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.pro
@@ -0,0 +1,25 @@
+QT += gui-private waylandclient-private
+CONFIG += wayland-scanner
+
+QMAKE_USE += wayland-client
+qtConfig(xkbcommon-evdev): \
+ QMAKE_USE_PRIVATE += xkbcommon_evdev
+
+WAYLANDCLIENTSOURCES += \
+ ../../../3rdparty/protocol/xdg-shell-unstable-v6.xml
+
+HEADERS += \
+ qwaylandxdgshellv6_p.h \
+ qwaylandxdgshellv6integration_p.h \
+
+SOURCES += \
+ main.cpp \
+ qwaylandxdgshellv6.cpp \
+ qwaylandxdgshellv6integration.cpp \
+
+OTHER_FILES += \
+ xdg-shell-v6.json
+
+PLUGIN_TYPE = wayland-shell-integration
+PLUGIN_CLASS_NAME = QWaylandXdgShellV6IntegrationPlugin
+load(qt_plugin)
diff --git a/src/plugins/shellintegration/xdg-shell/main.cpp b/src/plugins/shellintegration/xdg-shell/main.cpp
new file mode 100644
index 000000000..a9ea4bc1e
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/main.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshellintegration_p.h"
+
+#include <QtWaylandClient/private/qwaylandshellintegrationplugin_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class QWaylandXdgShellIntegrationPlugin : public QWaylandShellIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QWaylandShellIntegrationFactoryInterface_iid FILE "xdg-shell.json")
+
+public:
+ QWaylandShellIntegration *create(const QString &key, const QStringList &paramList) override;
+};
+
+QWaylandShellIntegration *QWaylandXdgShellIntegrationPlugin::create(const QString &key, const QStringList &paramList)
+{
+ Q_UNUSED(key);
+ Q_UNUSED(paramList);
+ return new QWaylandXdgShellIntegration();
+}
+
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1.cpp
new file mode 100644
index 000000000..345ff32ad
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgdecorationv1_p.h"
+#include "qwaylandxdgshell_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+QWaylandXdgDecorationManagerV1::QWaylandXdgDecorationManagerV1(wl_registry *registry, uint32_t id, uint32_t availableVersion)
+ : QtWayland::zxdg_decoration_manager_v1(registry, id, qMin(availableVersion, 1u))
+{
+}
+
+QWaylandXdgDecorationManagerV1::~QWaylandXdgDecorationManagerV1()
+{
+ Q_ASSERT(isInitialized());
+ destroy();
+}
+
+QWaylandXdgToplevelDecorationV1 *QWaylandXdgDecorationManagerV1::createToplevelDecoration(::xdg_toplevel *toplevel)
+{
+ Q_ASSERT(toplevel);
+ return new QWaylandXdgToplevelDecorationV1(get_toplevel_decoration(toplevel));
+}
+
+QWaylandXdgToplevelDecorationV1::QWaylandXdgToplevelDecorationV1(::zxdg_toplevel_decoration_v1 *decoration)
+ : QtWayland::zxdg_toplevel_decoration_v1(decoration)
+{
+}
+
+QWaylandXdgToplevelDecorationV1::~QWaylandXdgToplevelDecorationV1()
+{
+ Q_ASSERT(isInitialized());
+ destroy();
+}
+
+void QWaylandXdgToplevelDecorationV1::requestMode(QtWayland::zxdg_toplevel_decoration_v1::mode mode)
+{
+ // According to the spec the client is responsible for not requesting a mode repeatedly.
+ if (m_modeSet && m_requested == mode)
+ return;
+
+ set_mode(mode);
+ m_requested = mode;
+ m_modeSet = true;
+}
+
+void QWaylandXdgToplevelDecorationV1::unsetMode()
+{
+ unset_mode();
+ m_modeSet = false;
+ m_requested = mode_client_side;
+}
+
+QWaylandXdgToplevelDecorationV1::mode QWaylandXdgToplevelDecorationV1::pending() const
+{
+ return m_pending;
+}
+
+void QtWaylandClient::QWaylandXdgToplevelDecorationV1::zxdg_toplevel_decoration_v1_configure(uint32_t mode)
+{
+ m_pending = zxdg_toplevel_decoration_v1::mode(mode);
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h
new file mode 100644
index 000000000..d6d8ce94e
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXDGDECORATIONV1_P_H
+#define QWAYLANDXDGDECORATIONV1_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qwayland-xdg-decoration-unstable-v1.h"
+
+#include <QtWaylandClient/qtwaylandclientglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWindow;
+
+namespace QtWaylandClient {
+
+class QWaylandXdgToplevel;
+class QWaylandXdgToplevelDecorationV1;
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgDecorationManagerV1 : public QtWayland::zxdg_decoration_manager_v1
+{
+public:
+ QWaylandXdgDecorationManagerV1(struct ::wl_registry *registry, uint32_t id, uint32_t availableVersion);
+ ~QWaylandXdgDecorationManagerV1() override;
+ QWaylandXdgToplevelDecorationV1 *createToplevelDecoration(::xdg_toplevel *toplevel);
+};
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgToplevelDecorationV1 : public QtWayland::zxdg_toplevel_decoration_v1
+{
+public:
+ QWaylandXdgToplevelDecorationV1(::zxdg_toplevel_decoration_v1 *decoration);
+ ~QWaylandXdgToplevelDecorationV1() override;
+ void requestMode(mode mode);
+ void unsetMode();
+ mode pending() const;
+
+protected:
+ void zxdg_toplevel_decoration_v1_configure(uint32_t mode) override;
+
+private:
+ mode m_pending = mode_client_side;
+ mode m_requested = mode_client_side;
+ bool m_modeSet = false;
+};
+
+QT_END_NAMESPACE
+
+}
+
+#endif // QWAYLANDXDGDECORATIONV1_P_H
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
new file mode 100644
index 000000000..8b3d07481
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
@@ -0,0 +1,404 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2017 Eurogiciel, author: <philippe.coval@eurogiciel.fr>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshell_p.h"
+
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
+#include <QtWaylandClient/private/qwaylandscreen_p.h>
+#include <QtWaylandClient/private/qwaylandabstractdecoration_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ : QtWayland::xdg_toplevel(xdgSurface->get_toplevel())
+ , m_xdgSurface(xdgSurface)
+{
+ if (auto *decorationManager = m_xdgSurface->m_shell->decorationManager())
+ m_decoration = decorationManager->createToplevelDecoration(object());
+
+ QWindow *window = xdgSurface->window()->window();
+ requestWindowStates(window->windowStates());
+ requestWindowFlags(window->flags());
+}
+
+QWaylandXdgSurface::Toplevel::~Toplevel()
+{
+ if (m_applied.states & Qt::WindowActive) {
+ QWaylandWindow *window = m_xdgSurface->window();
+ window->display()->handleWindowDeactivated(window);
+ }
+
+ // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+ delete m_decoration;
+ m_decoration = nullptr;
+
+ if (isInitialized())
+ destroy();
+}
+
+void QWaylandXdgSurface::Toplevel::applyConfigure()
+{
+ if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+ m_normalSize = m_xdgSurface->m_window->window()->frameGeometry().size();
+
+ if (m_pending.size.isEmpty() && !m_normalSize.isEmpty())
+ m_pending.size = m_normalSize;
+
+ if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
+ m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+
+ if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
+ m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+
+ // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+ Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+
+ m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
+ m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+ QSize windowGeometrySize = m_xdgSurface->m_window->window()->frameGeometry().size();
+ m_xdgSurface->set_window_geometry(0, 0, windowGeometrySize.width(), windowGeometrySize.height());
+ m_applied = m_pending;
+}
+
+bool QWaylandXdgSurface::Toplevel::wantsDecorations()
+{
+ if (m_decoration && m_decoration->pending() == QWaylandXdgToplevelDecorationV1::mode_server_side)
+ return false;
+
+ return !(m_pending.states & Qt::WindowFullScreen);
+}
+
+void QWaylandXdgSurface::Toplevel::xdg_toplevel_configure(int32_t width, int32_t height, wl_array *states)
+{
+ m_pending.size = QSize(width, height);
+
+ auto *xdgStates = static_cast<uint32_t *>(states->data);
+ size_t numStates = states->size / sizeof(uint32_t);
+
+ m_pending.states = Qt::WindowNoState;
+
+ for (size_t i = 0; i < numStates; i++) {
+ switch (xdgStates[i]) {
+ case XDG_TOPLEVEL_STATE_ACTIVATED:
+ m_pending.states |= Qt::WindowActive;
+ break;
+ case XDG_TOPLEVEL_STATE_MAXIMIZED:
+ m_pending.states |= Qt::WindowMaximized;
+ break;
+ case XDG_TOPLEVEL_STATE_FULLSCREEN:
+ m_pending.states |= Qt::WindowFullScreen;
+ break;
+ default:
+ break;
+ }
+ }
+ qCDebug(lcQpaWayland) << "Received xdg_toplevel.configure with" << m_pending.size
+ << "and" << m_pending.states;
+}
+
+void QWaylandXdgSurface::Toplevel::xdg_toplevel_close()
+{
+ m_xdgSurface->m_window->window()->close();
+}
+
+void QWaylandXdgSurface::Toplevel::requestWindowFlags(Qt::WindowFlags flags)
+{
+ if (m_decoration) {
+ if (flags & Qt::FramelessWindowHint)
+ m_decoration->requestMode(QWaylandXdgToplevelDecorationV1::mode_client_side);
+ else
+ m_decoration->unsetMode();
+ }
+}
+
+void QWaylandXdgSurface::Toplevel::requestWindowStates(Qt::WindowStates states)
+{
+ // Re-send what's different from the applied state
+ Qt::WindowStates changedStates = m_applied.states ^ states;
+
+ if (changedStates & Qt::WindowMaximized) {
+ if (states & Qt::WindowMaximized)
+ set_maximized();
+ else
+ unset_maximized();
+ }
+
+ if (changedStates & Qt::WindowFullScreen) {
+ if (states & Qt::WindowFullScreen)
+ set_fullscreen(nullptr);
+ else
+ unset_fullscreen();
+ }
+
+ // Minimized state is not reported by the protocol, so always send it
+ if (states & Qt::WindowMinimized) {
+ set_minimized();
+ m_xdgSurface->window()->handleWindowStatesChanged(states & ~Qt::WindowMinimized);
+ }
+}
+
+QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
+ QtWayland::xdg_positioner *positioner)
+ : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+ , m_xdgSurface(xdgSurface)
+ , m_parent(parent)
+{
+}
+
+QWaylandXdgSurface::Popup::~Popup()
+{
+ if (isInitialized())
+ destroy();
+
+ if (m_grabbing) {
+ auto *shell = m_xdgSurface->m_shell;
+ Q_ASSERT(shell->m_topmostPopup == this);
+ shell->m_topmostPopup = m_parent->m_popup;
+ }
+}
+
+void QWaylandXdgSurface::Popup::grab(QWaylandInputDevice *seat, uint serial)
+{
+ m_xdgSurface->m_shell->m_topmostPopup = this;
+ xdg_popup::grab(seat->wl_seat(), serial);
+ m_grabbing = true;
+}
+
+void QWaylandXdgSurface::Popup::xdg_popup_popup_done()
+{
+ m_xdgSurface->m_window->window()->close();
+}
+
+QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *surface, QWaylandWindow *window)
+ : QWaylandShellSurface(window)
+ , xdg_surface(surface)
+ , m_shell(shell)
+ , m_window(window)
+{
+ QWaylandDisplay *display = window->display();
+ Qt::WindowType type = window->window()->type();
+ auto *transientParent = window->transientParent();
+
+ if ((type == Qt::Popup || type == Qt::ToolTip) && transientParent && display->lastInputDevice()) {
+ setPopup(transientParent, display->lastInputDevice(), display->lastInputSerial(), type == Qt::Popup);
+ } else {
+ setToplevel();
+ if (transientParent) {
+ auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(transientParent->shellSurface());
+ if (parentXdgSurface)
+ m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+ }
+ }
+}
+
+QWaylandXdgSurface::~QWaylandXdgSurface()
+{
+ if (m_toplevel) {
+ delete m_toplevel;
+ m_toplevel = nullptr;
+ }
+ if (m_popup) {
+ delete m_popup;
+ m_popup = nullptr;
+ }
+ destroy();
+}
+
+void QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, xdg_toplevel_resize_edge edges)
+{
+ Q_ASSERT(m_toplevel && m_toplevel->isInitialized());
+ m_toplevel->resize(inputDevice->wl_seat(), inputDevice->serial(), edges);
+}
+
+void QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
+{
+ auto xdgEdges = reinterpret_cast<enum xdg_toplevel_resize_edge const *>(&edges);
+ resize(inputDevice, *xdgEdges);
+}
+
+
+bool QWaylandXdgSurface::move(QWaylandInputDevice *inputDevice)
+{
+ if (m_toplevel && m_toplevel->isInitialized()) {
+ m_toplevel->move(inputDevice->wl_seat(), inputDevice->serial());
+ return true;
+ }
+ return false;
+}
+
+void QWaylandXdgSurface::setTitle(const QString &title)
+{
+ if (m_toplevel)
+ m_toplevel->set_title(title);
+}
+
+void QWaylandXdgSurface::setAppId(const QString &appId)
+{
+ if (m_toplevel)
+ m_toplevel->set_app_id(appId);
+}
+
+void QWaylandXdgSurface::setWindowFlags(Qt::WindowFlags flags)
+{
+ if (m_toplevel)
+ m_toplevel->requestWindowFlags(flags);
+}
+
+bool QWaylandXdgSurface::handleExpose(const QRegion &region)
+{
+ if (!m_configured && !region.isEmpty()) {
+ m_exposeRegion = region;
+ return true;
+ }
+ return false;
+}
+
+void QWaylandXdgSurface::applyConfigure()
+{
+ Q_ASSERT(m_pendingConfigureSerial != 0);
+
+ if (m_toplevel)
+ m_toplevel->applyConfigure();
+
+ m_configured = true;
+ ack_configure(m_pendingConfigureSerial);
+
+ m_pendingConfigureSerial = 0;
+}
+
+bool QWaylandXdgSurface::wantsDecorations() const
+{
+ return m_toplevel && m_toplevel->wantsDecorations();
+}
+
+void QWaylandXdgSurface::requestWindowStates(Qt::WindowStates states)
+{
+ if (m_toplevel)
+ m_toplevel->requestWindowStates(states);
+ else
+ qCWarning(lcQpaWayland) << "Non-toplevel surfaces can't request window states";
+}
+
+void QWaylandXdgSurface::setToplevel()
+{
+ Q_ASSERT(!m_toplevel && !m_popup);
+ m_toplevel = new Toplevel(this);
+}
+
+void QWaylandXdgSurface::setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, int serial, bool grab)
+{
+ Q_ASSERT(!m_toplevel && !m_popup);
+
+ auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+
+ auto *top = m_shell->m_topmostPopup;
+ if (grab && top && top->m_xdgSurface != parentXdgSurface) {
+ qCWarning(lcQpaWayland) << "setPopup called for a surface that was not the topmost popup, positions might be off.";
+ parentXdgSurface = top->m_xdgSurface;
+ parent = top->m_xdgSurface->m_window;
+ }
+
+ auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+ // set_popup expects a position relative to the parent
+ QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+ transientPos -= parent->geometry().topLeft();
+ if (parent->decoration()) {
+ transientPos.setX(transientPos.x() + parent->decoration()->margins().left());
+ transientPos.setY(transientPos.y() + parent->decoration()->margins().top());
+ }
+ positioner->set_anchor_rect(transientPos.x(), transientPos.y(), 1, 1);
+ positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+ positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+ positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+ m_popup = new Popup(this, parentXdgSurface, positioner);
+ positioner->destroy();
+ delete positioner;
+ if (grab)
+ m_popup->grab(device, serial);
+}
+
+void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+{
+ m_window->applyConfigureWhenPossible();
+ m_pendingConfigureSerial = serial;
+ if (!m_exposeRegion.isEmpty()) {
+ QWindowSystemInterface::handleExposeEvent(m_window->window(), m_exposeRegion);
+ m_exposeRegion = QRegion();
+ }
+}
+
+QWaylandXdgShell::QWaylandXdgShell(QWaylandDisplay *display, uint32_t id, uint32_t availableVersion)
+ : QtWayland::xdg_wm_base(display->wl_registry(), id, qMin(availableVersion, 1u))
+ , m_display(display)
+{
+ display->addRegistryListener(&QWaylandXdgShell::handleRegistryGlobal, this);
+}
+
+QWaylandXdgShell::~QWaylandXdgShell()
+{
+ m_display->removeListener(&QWaylandXdgShell::handleRegistryGlobal, this);
+ destroy();
+}
+
+QWaylandXdgSurface *QWaylandXdgShell::getXdgSurface(QWaylandWindow *window)
+{
+ return new QWaylandXdgSurface(this, get_xdg_surface(window->object()), window);
+}
+
+void QWaylandXdgShell::xdg_wm_base_ping(uint32_t serial)
+{
+ pong(serial);
+}
+
+void QWaylandXdgShell::handleRegistryGlobal(void *data, wl_registry *registry, uint id,
+ const QString &interface, uint version)
+{
+ QWaylandXdgShell *xdgShell = static_cast<QWaylandXdgShell *>(data);
+ if (interface == QLatin1String(QWaylandXdgDecorationManagerV1::interface()->name))
+ xdgShell->m_xdgDecorationManager.reset(new QWaylandXdgDecorationManagerV1(registry, id, version));
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
new file mode 100644
index 000000000..45d7d4b0e
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
@@ -0,0 +1,181 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2017 Eurogiciel, author: <philippe.coval@eurogiciel.fr>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXDGSHELL_H
+#define QWAYLANDXDGSHELL_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qwayland-xdg-shell.h"
+
+#include "qwaylandxdgdecorationv1_p.h"
+
+#include <QtWaylandClient/qtwaylandclientglobal.h>
+#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
+
+#include <QtCore/QSize>
+#include <QtGui/QRegion>
+
+#include <wayland-client.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWindow;
+
+namespace QtWaylandClient {
+
+class QWaylandDisplay;
+class QWaylandWindow;
+class QWaylandInputDevice;
+class QWaylandXdgShell;
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgSurface : public QWaylandShellSurface, public QtWayland::xdg_surface
+{
+ Q_OBJECT
+public:
+ QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *surface, QWaylandWindow *window);
+ ~QWaylandXdgSurface() override;
+
+ void resize(QWaylandInputDevice *inputDevice, enum xdg_toplevel_resize_edge edges);
+ void resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges) override;
+ bool move(QWaylandInputDevice *inputDevice) override;
+ void setTitle(const QString &title) override;
+ void setAppId(const QString &appId) override;
+ void setWindowFlags(Qt::WindowFlags flags) override;
+
+ bool isExposed() const override { return m_configured; }
+ bool handleExpose(const QRegion &) override;
+ bool handlesActiveState() const { return m_toplevel; }
+ void applyConfigure() override;
+ bool wantsDecorations() const override;
+
+protected:
+ void requestWindowStates(Qt::WindowStates states) override;
+ void xdg_surface_configure(uint32_t serial) override;
+
+private:
+ class Toplevel: public QtWayland::xdg_toplevel
+ {
+ public:
+ Toplevel(QWaylandXdgSurface *xdgSurface);
+ ~Toplevel() override;
+
+ void applyConfigure();
+ bool wantsDecorations();
+
+ void xdg_toplevel_configure(int32_t width, int32_t height, wl_array *states) override;
+ void xdg_toplevel_close() override;
+
+ void requestWindowFlags(Qt::WindowFlags flags);
+ void requestWindowStates(Qt::WindowStates states);
+ struct {
+ QSize size = {0, 0};
+ Qt::WindowStates states = Qt::WindowNoState;
+ } m_pending, m_applied;
+ QSize m_normalSize;
+
+ QWaylandXdgSurface *m_xdgSurface = nullptr;
+ QWaylandXdgToplevelDecorationV1 *m_decoration = nullptr;
+ };
+
+ class Popup : public QtWayland::xdg_popup {
+ public:
+ Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
+ ~Popup() override;
+
+ void grab(QWaylandInputDevice *seat, uint serial);
+ void xdg_popup_popup_done() override;
+
+ QWaylandXdgSurface *m_xdgSurface = nullptr;
+ QWaylandXdgSurface *m_parent = nullptr;
+ bool m_grabbing = false;
+ };
+
+ void setToplevel();
+ void setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, int serial, bool grab);
+
+ QWaylandXdgShell *m_shell = nullptr;
+ QWaylandWindow *m_window = nullptr;
+ Toplevel *m_toplevel = nullptr;
+ Popup *m_popup = nullptr;
+ bool m_configured = false;
+ QRegion m_exposeRegion;
+ uint m_pendingConfigureSerial = 0;
+
+ friend class QWaylandXdgShell;
+};
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShell : public QtWayland::xdg_wm_base
+{
+public:
+ QWaylandXdgShell(QWaylandDisplay *display, uint32_t id, uint32_t availableVersion);
+ ~QWaylandXdgShell() override;
+
+ QWaylandXdgDecorationManagerV1 *decorationManager() { return m_xdgDecorationManager.data(); }
+ QWaylandXdgSurface *getXdgSurface(QWaylandWindow *window);
+
+protected:
+ void xdg_wm_base_ping(uint32_t serial) override;
+
+private:
+ static void handleRegistryGlobal(void *data, ::wl_registry *registry, uint id,
+ const QString &interface, uint version);
+
+ QWaylandDisplay *m_display = nullptr;
+ QScopedPointer<QWaylandXdgDecorationManagerV1> m_xdgDecorationManager;
+ QWaylandXdgSurface::Popup *m_topmostPopup = nullptr;
+
+ friend class QWaylandXdgSurface;
+};
+
+QT_END_NAMESPACE
+
+}
+
+#endif // QWAYLANDXDGSHELL_H
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
new file mode 100644
index 000000000..8769d9716
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshellintegration_p.h"
+#include "qwaylandxdgdecorationv1_p.h"
+
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display)
+{
+ for (QWaylandDisplay::RegistryGlobal global : display->globals()) {
+ if (global.interface == QLatin1String("xdg_wm_base")) {
+ m_xdgShell.reset(new QWaylandXdgShell(display, global.id, global.version));
+ break;
+ }
+ }
+
+ if (!m_xdgShell) {
+ qCDebug(lcQpaWayland) << "Couldn't find global xdg_wm_base for xdg-shell stable";
+ return false;
+ }
+
+ return QWaylandShellIntegration::initialize(display);
+}
+
+QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window)
+{
+ return m_xdgShell->getXdgSurface(window);
+}
+
+void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+{
+ if (newFocus) {
+ auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+ if (xdgSurface && !xdgSurface->handlesActiveState())
+ m_display->handleWindowActivated(newFocus);
+ }
+ if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+ auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+ if (xdgSurface && !xdgSurface->handlesActiveState())
+ m_display->handleWindowDeactivated(oldFocus);
+ }
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/client/qwaylandxdgshellintegration_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
index ed307a5de..b6caa6c95 100644
--- a/src/client/qwaylandxdgshellintegration_p.h
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <wayland-client.h>
+#include "qwaylandxdgshell_p.h"
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
@@ -59,20 +59,16 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-class QWaylandXdgShell;
-
class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellIntegration : public QWaylandShellIntegration
{
public:
- static QWaylandXdgShellIntegration *create(QWaylandDisplay* display);
+ QWaylandXdgShellIntegration() {}
bool initialize(QWaylandDisplay *display) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
private:
- QWaylandXdgShellIntegration(QWaylandDisplay *display);
-
- QWaylandXdgShell *m_xdgShell = nullptr;
+ QScopedPointer<QWaylandXdgShell> m_xdgShell;
};
}
diff --git a/src/plugins/shellintegration/xdg-shell/xdg-shell.json b/src/plugins/shellintegration/xdg-shell/xdg-shell.json
new file mode 100644
index 000000000..2de86b8d0
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/xdg-shell.json
@@ -0,0 +1,3 @@
+{
+ "Keys":[ "xdg-shell" ]
+}
diff --git a/src/plugins/shellintegration/xdg-shell/xdg-shell.pro b/src/plugins/shellintegration/xdg-shell/xdg-shell.pro
new file mode 100644
index 000000000..2b1191af0
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/xdg-shell.pro
@@ -0,0 +1,28 @@
+QT += gui-private waylandclient-private
+CONFIG += wayland-scanner
+
+QMAKE_USE += wayland-client
+qtConfig(xkbcommon-evdev): \
+ QMAKE_USE_PRIVATE += xkbcommon_evdev
+
+WAYLANDCLIENTSOURCES += \
+ ../../../3rdparty/protocol/xdg-decoration-unstable-v1.xml \
+ ../../../3rdparty/protocol/xdg-shell.xml
+
+HEADERS += \
+ qwaylandxdgdecorationv1_p.h \
+ qwaylandxdgshell_p.h \
+ qwaylandxdgshellintegration_p.h \
+
+SOURCES += \
+ main.cpp \
+ qwaylandxdgdecorationv1.cpp \
+ qwaylandxdgshell.cpp \
+ qwaylandxdgshellintegration.cpp \
+
+OTHER_FILES += \
+ xdg-shell.json
+
+PLUGIN_TYPE = wayland-shell-integration
+PLUGIN_CLASS_NAME = QWaylandXdgShellIntegrationPlugin
+load(qt_plugin)
diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp
index 1b884a424..c08c00f4f 100644
--- a/src/qtwaylandscanner/qtwaylandscanner.cpp
+++ b/src/qtwaylandscanner/qtwaylandscanner.cpp
@@ -41,92 +41,152 @@
#include <QFile>
#include <QXmlStreamReader>
-enum Option {
- ClientHeader,
- ServerHeader,
- ClientCode,
- ServerCode
-} option;
-
-bool isServerSide()
+class Scanner
{
- return option == ServerHeader || option == ServerCode;
+public:
+ explicit Scanner() {}
+ ~Scanner() { delete m_xml; }
+
+ bool parseArguments(int argc, char **argv);
+ void printUsage();
+ bool process();
+ void printErrors();
+
+private:
+ struct WaylandEnumEntry {
+ QByteArray name;
+ QByteArray value;
+ QByteArray summary;
+ };
+
+ struct WaylandEnum {
+ QByteArray name;
+
+ QList<WaylandEnumEntry> entries;
+ };
+
+ struct WaylandArgument {
+ QByteArray name;
+ QByteArray type;
+ QByteArray interface;
+ QByteArray summary;
+ bool allowNull;
+ };
+
+ struct WaylandEvent {
+ bool request;
+ QByteArray name;
+ QByteArray type;
+ QList<WaylandArgument> arguments;
+ };
+
+ struct WaylandInterface {
+ QByteArray name;
+ int version;
+
+ QList<WaylandEnum> enums;
+ QList<WaylandEvent> events;
+ QList<WaylandEvent> requests;
+ };
+
+ bool isServerSide();
+ bool parseOption(const char *str);
+
+ QByteArray byteArrayValue(const QXmlStreamReader &xml, const char *name);
+ int intValue(const QXmlStreamReader &xml, const char *name, int defaultValue = 0);
+ bool boolValue(const QXmlStreamReader &xml, const char *name);
+ WaylandEvent readEvent(QXmlStreamReader &xml, bool request);
+ Scanner::WaylandEnum readEnum(QXmlStreamReader &xml);
+ Scanner::WaylandInterface readInterface(QXmlStreamReader &xml);
+ QByteArray waylandToCType(const QByteArray &waylandType, const QByteArray &interface);
+ QByteArray waylandToQtType(const QByteArray &waylandType, const QByteArray &interface, bool cStyleArray);
+ const Scanner::WaylandArgument *newIdArgument(const QList<WaylandArgument> &arguments);
+
+ void printEvent(const WaylandEvent &e, bool omitNames = false, bool withResource = false);
+ void printEventHandlerSignature(const WaylandEvent &e, const char *interfaceName, bool deepIndent = true);
+ void printEnums(const QList<WaylandEnum> &enums);
+
+ QByteArray stripInterfaceName(const QByteArray &name);
+ bool ignoreInterface(const QByteArray &name);
+
+ enum Option {
+ ClientHeader,
+ ServerHeader,
+ ClientCode,
+ ServerCode
+ } m_option;
+
+ QByteArray m_protocolName;
+ QByteArray m_protocolFilePath;
+ QByteArray m_scannerName;
+ QByteArray m_headerPath;
+ QByteArray m_prefix;
+ QXmlStreamReader *m_xml = nullptr;
+};
+
+bool Scanner::parseArguments(int argc, char **argv)
+{
+ QByteArray m_scannerName = argv[0];
+
+ if (argc <= 2 || !parseOption(argv[1]))
+ return false;
+
+ m_protocolFilePath = QByteArray(argv[2]);
+
+ if (argc >= 4)
+ m_headerPath = QByteArray(argv[3]);
+ if (argc == 5)
+ m_prefix = QByteArray(argv[4]);
+
+ return true;
}
-QByteArray protocolName;
+void Scanner::printUsage()
+{
+ fprintf(stderr, "Usage: %s [client-header|server-header|client-code|server-code] specfile [header-path] [prefix]\n", m_scannerName.constData());
+}
-bool parseOption(const char *str, Option *option)
+bool Scanner::isServerSide()
+{
+ return m_option == ServerHeader || m_option == ServerCode;
+}
+
+bool Scanner::parseOption(const char *str)
{
if (str == QLatin1String("client-header"))
- *option = ClientHeader;
+ m_option = ClientHeader;
else if (str == QLatin1String("server-header"))
- *option = ServerHeader;
+ m_option = ServerHeader;
else if (str == QLatin1String("client-code"))
- *option = ClientCode;
+ m_option = ClientCode;
else if (str == QLatin1String("server-code"))
- *option = ServerCode;
+ m_option = ServerCode;
else
return false;
return true;
}
-struct WaylandEnumEntry {
- QByteArray name;
- QByteArray value;
- QByteArray summary;
-};
-
-struct WaylandEnum {
- QByteArray name;
-
- QList<WaylandEnumEntry> entries;
-};
-
-struct WaylandArgument {
- QByteArray name;
- QByteArray type;
- QByteArray interface;
- QByteArray summary;
- bool allowNull;
-};
-
-struct WaylandEvent {
- bool request;
- QByteArray name;
- QByteArray type;
- QList<WaylandArgument> arguments;
-};
-
-struct WaylandInterface {
- QByteArray name;
- int version;
-
- QList<WaylandEnum> enums;
- QList<WaylandEvent> events;
- QList<WaylandEvent> requests;
-};
-
-QByteArray byteArrayValue(const QXmlStreamReader &xml, const char *name)
+QByteArray Scanner::byteArrayValue(const QXmlStreamReader &xml, const char *name)
{
if (xml.attributes().hasAttribute(name))
return xml.attributes().value(name).toUtf8();
return QByteArray();
}
-int intValue(const QXmlStreamReader &xml, const char *name, int defaultValue = 0)
+int Scanner::intValue(const QXmlStreamReader &xml, const char *name, int defaultValue)
{
bool ok;
int result = byteArrayValue(xml, name).toInt(&ok);
return ok ? result : defaultValue;
}
-bool boolValue(const QXmlStreamReader &xml, const char *name)
+bool Scanner::boolValue(const QXmlStreamReader &xml, const char *name)
{
return byteArrayValue(xml, name) == "true";
}
-WaylandEvent readEvent(QXmlStreamReader &xml, bool request)
+Scanner::WaylandEvent Scanner::readEvent(QXmlStreamReader &xml, bool request)
{
WaylandEvent event;
event.request = request;
@@ -148,7 +208,7 @@ WaylandEvent readEvent(QXmlStreamReader &xml, bool request)
return event;
}
-WaylandEnum readEnum(QXmlStreamReader &xml)
+Scanner::WaylandEnum Scanner::readEnum(QXmlStreamReader &xml)
{
WaylandEnum result;
result.name = byteArrayValue(xml, "name");
@@ -168,7 +228,7 @@ WaylandEnum readEnum(QXmlStreamReader &xml)
return result;
}
-WaylandInterface readInterface(QXmlStreamReader &xml)
+Scanner::WaylandInterface Scanner::readInterface(QXmlStreamReader &xml)
{
WaylandInterface interface;
interface.name = byteArrayValue(xml, "name");
@@ -188,7 +248,7 @@ WaylandInterface readInterface(QXmlStreamReader &xml)
return interface;
}
-QByteArray waylandToCType(const QByteArray &waylandType, const QByteArray &interface)
+QByteArray Scanner::waylandToCType(const QByteArray &waylandType, const QByteArray &interface)
{
if (waylandType == "string")
return "const char *";
@@ -212,7 +272,7 @@ QByteArray waylandToCType(const QByteArray &waylandType, const QByteArray &inter
return waylandType;
}
-QByteArray waylandToQtType(const QByteArray &waylandType, const QByteArray &interface, bool cStyleArray)
+QByteArray Scanner::waylandToQtType(const QByteArray &waylandType, const QByteArray &interface, bool cStyleArray)
{
if (waylandType == "string")
return "const QString &";
@@ -222,7 +282,7 @@ QByteArray waylandToQtType(const QByteArray &waylandType, const QByteArray &inte
return waylandToCType(waylandType, interface);
}
-const WaylandArgument *newIdArgument(const QList<WaylandArgument> &arguments)
+const Scanner::WaylandArgument *Scanner::newIdArgument(const QList<WaylandArgument> &arguments)
{
for (int i = 0; i < arguments.size(); ++i) {
if (arguments.at(i).type == "new_id")
@@ -231,7 +291,7 @@ const WaylandArgument *newIdArgument(const QList<WaylandArgument> &arguments)
return nullptr;
}
-void printEvent(const WaylandEvent &e, bool omitNames = false, bool withResource = false)
+void Scanner::printEvent(const WaylandEvent &e, bool omitNames, bool withResource)
{
printf("%s(", e.name.constData());
bool needsComma = false;
@@ -274,7 +334,7 @@ void printEvent(const WaylandEvent &e, bool omitNames = false, bool withResource
printf(")");
}
-void printEventHandlerSignature(const WaylandEvent &e, const char *interfaceName, bool deepIndent = true)
+void Scanner::printEventHandlerSignature(const WaylandEvent &e, const char *interfaceName, bool deepIndent)
{
const char *indent = deepIndent ? " " : "";
printf("handle_%s(\n", e.name.constData());
@@ -299,7 +359,7 @@ void printEventHandlerSignature(const WaylandEvent &e, const char *interfaceName
printf(")");
}
-void printEnums(const QList<WaylandEnum> &enums)
+void Scanner::printEnums(const QList<WaylandEnum> &enums)
{
for (int i = 0; i < enums.size(); ++i) {
printf("\n");
@@ -318,66 +378,73 @@ void printEnums(const QList<WaylandEnum> &enums)
}
}
-QByteArray stripInterfaceName(const QByteArray &name, const QByteArray &prefix)
+QByteArray Scanner::stripInterfaceName(const QByteArray &name)
{
- if (!prefix.isEmpty() && name.startsWith(prefix))
- return name.mid(prefix.size());
+ if (!m_prefix.isEmpty() && name.startsWith(m_prefix))
+ return name.mid(m_prefix.size());
if (name.startsWith("qt_") || name.startsWith("wl_"))
return name.mid(3);
return name;
}
-bool ignoreInterface(const QByteArray &name)
+bool Scanner::ignoreInterface(const QByteArray &name)
{
return name == "wl_display"
|| (isServerSide() && name == "wl_registry");
}
-void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArray &prefix)
+bool Scanner::process()
{
- if (!xml.readNextStartElement())
- return;
+ QFile file(m_protocolFilePath);
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ fprintf(stderr, "Unable to open file %s\n", m_protocolFilePath.constData());
+ return false;
+ }
- if (xml.name() != "protocol") {
- xml.raiseError(QStringLiteral("The file is not a wayland protocol file."));
- return;
+ m_xml = new QXmlStreamReader(&file);
+ if (!m_xml->readNextStartElement())
+ return false;
+
+ if (m_xml->name() != "protocol") {
+ m_xml->raiseError(QStringLiteral("The file is not a wayland protocol file."));
+ return false;
}
- protocolName = byteArrayValue(xml, "name");
+ m_protocolName = byteArrayValue(*m_xml, "name");
- if (protocolName.isEmpty()) {
- xml.raiseError(QStringLiteral("Missing protocol name."));
- return;
+ if (m_protocolName.isEmpty()) {
+ m_xml->raiseError(QStringLiteral("Missing protocol name."));
+ return false;
}
//We should convert - to _ so that the preprocessor wont generate code which will lead to unexpected behavior
//However, the wayland-scanner doesn't do so we will do the same for now
- //QByteArray preProcessorProtocolName = QByteArray(protocolName).replace('-', '_').toUpper();
- QByteArray preProcessorProtocolName = QByteArray(protocolName).toUpper();
+ //QByteArray preProcessorProtocolName = QByteArray(m_protocolName).replace('-', '_').toUpper();
+ QByteArray preProcessorProtocolName = QByteArray(m_protocolName).toUpper();
QList<WaylandInterface> interfaces;
- while (xml.readNextStartElement()) {
- if (xml.name() == "interface")
- interfaces << readInterface(xml);
+ while (m_xml->readNextStartElement()) {
+ if (m_xml->name() == "interface")
+ interfaces << readInterface(*m_xml);
else
- xml.skipCurrentElement();
+ m_xml->skipCurrentElement();
}
- if (xml.hasError())
- return;
+ if (m_xml->hasError())
+ return false;
- if (option == ServerHeader) {
+ if (m_option == ServerHeader) {
QByteArray inclusionGuard = QByteArray("QT_WAYLAND_SERVER_") + preProcessorProtocolName.constData();
printf("#ifndef %s\n", inclusionGuard.constData());
printf("#define %s\n", inclusionGuard.constData());
printf("\n");
printf("#include \"wayland-server.h\"\n");
- if (headerPath.isEmpty())
- printf("#include \"wayland-%s-server-protocol.h\"\n", QByteArray(protocolName).replace('_', '-').constData());
+ if (m_headerPath.isEmpty())
+ printf("#include \"wayland-%s-server-protocol.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
else
- printf("#include <%s/wayland-%s-server-protocol.h>\n", headerPath.constData(), QByteArray(protocolName).replace('_', '-').constData());
+ printf("#include <%s/wayland-%s-server-protocol.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
printf("#include <QByteArray>\n");
printf("#include <QMultiMap>\n");
printf("#include <QString>\n");
@@ -396,7 +463,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf("QT_WARNING_DISABLE_GCC(\"-Wmissing-field-initializers\")\n");
printf("QT_WARNING_DISABLE_CLANG(\"-Wmissing-field-initializers\")\n");
QByteArray serverExport;
- if (headerPath.size()) {
+ if (m_headerPath.size()) {
serverExport = QByteArray("Q_WAYLAND_SERVER_") + preProcessorProtocolName + "_EXPORT";
printf("\n");
printf("#if !defined(%s)\n", serverExport.constData());
@@ -418,7 +485,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
const char *interfaceName = interface.name.constData();
- QByteArray stripped = stripInterfaceName(interface.name, prefix);
+ QByteArray stripped = stripInterfaceName(interface.name);
const char *interfaceNameStripped = stripped.constData();
printf(" class %s %s\n {\n", serverExport.constData(), interfaceName);
@@ -547,11 +614,11 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf("#endif\n");
}
- if (option == ServerCode) {
- if (headerPath.isEmpty())
- printf("#include \"qwayland-server-%s.h\"\n", QByteArray(protocolName).replace('_', '-').constData());
+ if (m_option == ServerCode) {
+ if (m_headerPath.isEmpty())
+ printf("#include \"qwayland-server-%s.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
else
- printf("#include <%s/qwayland-server-%s.h>\n", headerPath.constData(), QByteArray(protocolName).replace('_', '-').constData());
+ printf("#include <%s/qwayland-server-%s.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
printf("\n");
printf("QT_BEGIN_NAMESPACE\n");
printf("QT_WARNING_PUSH\n");
@@ -573,7 +640,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
const char *interfaceName = interface.name.constData();
- QByteArray stripped = stripInterfaceName(interface.name, prefix);
+ QByteArray stripped = stripInterfaceName(interface.name);
const char *interfaceNameStripped = stripped.constData();
printf(" %s::%s(struct ::wl_client *client, int id, int version)\n", interfaceName, interfaceName);
@@ -739,6 +806,8 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf(" %s::Resource *%s::Resource::fromResource(struct ::wl_resource *resource)\n", interfaceName, interfaceName);
printf(" {\n");
+ printf(" if (Q_UNLIKELY(!resource))\n");
+ printf(" return nullptr;\n");
printf(" if (wl_resource_instance_of(resource, &::%s_interface, %s))\n", interfaceName, interfaceMember.constData());
printf(" return static_cast<Resource *>(resource->data);\n");
printf(" return nullptr;\n");
@@ -860,15 +929,15 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf("QT_END_NAMESPACE\n");
}
- if (option == ClientHeader) {
+ if (m_option == ClientHeader) {
QByteArray inclusionGuard = QByteArray("QT_WAYLAND_") + preProcessorProtocolName.constData();
printf("#ifndef %s\n", inclusionGuard.constData());
printf("#define %s\n", inclusionGuard.constData());
printf("\n");
- if (headerPath.isEmpty())
- printf("#include \"wayland-%s-client-protocol.h\"\n", QByteArray(protocolName).replace('_', '-').constData());
+ if (m_headerPath.isEmpty())
+ printf("#include \"wayland-%s-client-protocol.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
else
- printf("#include <%s/wayland-%s-client-protocol.h>\n", headerPath.constData(), QByteArray(protocolName).replace('_', '-').constData());
+ printf("#include <%s/wayland-%s-client-protocol.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
printf("#include <QByteArray>\n");
printf("#include <QString>\n");
printf("\n");
@@ -878,7 +947,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
QByteArray clientExport;
- if (headerPath.size()) {
+ if (m_headerPath.size()) {
clientExport = QByteArray("Q_WAYLAND_CLIENT_") + preProcessorProtocolName + "_EXPORT";
printf("\n");
printf("#if !defined(%s)\n", clientExport.constData());
@@ -899,7 +968,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
const char *interfaceName = interface.name.constData();
- QByteArray stripped = stripInterfaceName(interface.name, prefix);
+ QByteArray stripped = stripInterfaceName(interface.name);
const char *interfaceNameStripped = stripped.constData();
printf(" class %s %s\n {\n", clientExport.constData(), interfaceName);
@@ -978,11 +1047,11 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf("#endif\n");
}
- if (option == ClientCode) {
- if (headerPath.isEmpty())
- printf("#include \"qwayland-%s.h\"\n", QByteArray(protocolName).replace('_', '-').constData());
+ if (m_option == ClientCode) {
+ if (m_headerPath.isEmpty())
+ printf("#include \"qwayland-%s.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
else
- printf("#include <%s/qwayland-%s.h>\n", headerPath.constData(), QByteArray(protocolName).replace('_', '-').constData());
+ printf("#include <%s/qwayland-%s.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
printf("\n");
printf("QT_BEGIN_NAMESPACE\n");
printf("QT_WARNING_PUSH\n");
@@ -997,7 +1066,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
const char *interfaceName = interface.name.constData();
- QByteArray stripped = stripInterfaceName(interface.name, prefix);
+ QByteArray stripped = stripInterfaceName(interface.name);
const char *interfaceNameStripped = stripped.constData();
bool hasEvents = !interface.events.isEmpty();
@@ -1172,34 +1241,30 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf("QT_WARNING_POP\n");
printf("QT_END_NAMESPACE\n");
}
+
+ return true;
}
-int main(int argc, char **argv)
+void Scanner::printErrors()
{
- if (argc <= 2 || !parseOption(argv[1], &option)) {
- fprintf(stderr, "Usage: %s [client-header|server-header|client-code|server-code] specfile [header-path] [prefix]\n", argv[0]);
- return 1;
- }
+ if (m_xml->hasError())
+ fprintf(stderr, "XML error: %s\nLine %lld, column %lld\n", m_xml->errorString().toLocal8Bit().constData(), m_xml->lineNumber(), m_xml->columnNumber());
+}
+int main(int argc, char **argv)
+{
QCoreApplication app(argc, argv);
+ Scanner scanner;
- QByteArray headerPath;
- if (argc >= 4)
- headerPath = QByteArray(argv[3]);
- QByteArray prefix;
- if (argc == 5)
- prefix = QByteArray(argv[4]);
- QFile file(argv[2]);
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- fprintf(stderr, "Unable to open file %s\n", argv[2]);
- return 1;
+ if (!scanner.parseArguments(argc, argv)) {
+ scanner.printUsage();
+ return EXIT_FAILURE;
}
- QXmlStreamReader xml(&file);
- process(xml, headerPath, prefix);
-
- if (xml.hasError()) {
- fprintf(stderr, "XML error: %s\nLine %lld, column %lld\n", xml.errorString().toLocal8Bit().constData(), xml.lineNumber(), xml.columnNumber());
- return 1;
+ if (!scanner.process()) {
+ scanner.printErrors();
+ return EXIT_FAILURE;
}
+
+ return EXIT_SUCCESS;
}