client: Implement xdg_system_bell_v1

This hooks up QGuiApplication::beep to the new wayland protocol

[ChangeLog][Third-Party Code] New protocol synced from wayland-protocols

Change-Id: I188eeb68fce406a0938011eb844bf9fbdabf5904
Reviewed-by: David Redondo <qt@david-redondo.de>
This commit is contained in:
David Edmundson 2023-07-06 12:39:52 +01:00
parent 41d4948606
commit 193b7f011f
7 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,18 @@
[
{
"Id": "wayland-xdg-system-bell-protocol",
"Name": "Wayland XDG System Bell Protocol",
"QDocModule": "qtwaylandcompositor",
"QtUsage": "Used in the Qt Wayland Compositor, and the Qt Wayland platform plugin.",
"Files": "xdg-system-bell-v1.xml",
"Description": "The XDG-System-Bell protocol provides a mechanism for apps to provide visual notification feedback through the compositor.",
"Homepage": "https://gitlab.freedesktop.org/wayland/wayland-protocols/",
"Version": "1.18",
"DownloadLocation": "https://gitlab.freedesktop.org/wayland/wayland-protocols/tree/1.38/",
"LicenseId": "MIT",
"License": "MIT License",
"LicenseFile": "../MIT_LICENSE.txt",
"Copyright": "Copyright © 2016, 2023 Red Hat\n"
}
]

View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="xdg_system_bell_v1">
<copyright>
Copyright © 2016, 2023 Red Hat
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_system_bell_v1" version="1">
<description summary="system bell">
This global interface enables clients to ring the system bell.
Warning! The protocol described in this file is currently in the testing
phase. Backward compatible changes may be added together with the
corresponding interface version bump. Backward incompatible changes can
only be done by creating a new major version of the extension.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the system bell object">
Notify that the object will no longer be used.
</description>
</request>
<request name="ring">
<description summary="ring the system bell">
This requests rings the system bell on behalf of a client. How ringing
the bell is implemented is up to the compositor. It may be an audible
sound, a visual feedback of some kind, or any other thing including
nothing.
The passed surface should correspond to a toplevel like surface role,
or be null, meaning the client doesn't have a particular toplevel it
wants to associate the bell ringing with. See the xdg-shell protocol
extension for a toplevel like surface role.
</description>
<arg name="surface" type="object" interface="wl_surface"
allow-null="true" summary="associated surface"/>
</request>
</interface>
</protocol>

View File

@ -107,6 +107,7 @@ qt6_generate_wayland_protocol_client_sources(WaylandClient
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/fractional-scale/fractional-scale-v1.xml
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/viewporter/viewporter.xml
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/xdg-shell/xdg-shell.xml
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/xdg-system-bell/xdg-system-bell-v1.xml
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/xdg-toplevel-drag/xdg-toplevel-drag-v1.xml
${CMAKE_CURRENT_SOURCE_DIR}/../extensions/qt-key-unstable-v1.xml
${CMAKE_CURRENT_SOURCE_DIR}/../extensions/qt-text-input-method-unstable-v1.xml

View File

@ -50,6 +50,7 @@
#include <QtWaylandClient/private/qwayland-fractional-scale-v1.h>
#include <QtWaylandClient/private/qwayland-viewporter.h>
#include <QtWaylandClient/private/qwayland-cursor-shape-v1.h>
#include <QtWaylandClient/private/qwayland-xdg-system-bell-v1.h>
#include <QtWaylandClient/private/qwayland-xdg-toplevel-drag-v1.h>
#include <QtCore/private/qcore_unix_p.h>
@ -779,6 +780,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
} else if (interface == QLatin1String(QtWayland::qt_windowmanager::interface()->name)) {
mGlobals.windowManagerIntegration.reset(
new QWaylandWindowManagerIntegration(this, id, version));
} else if (interface == QLatin1String(QtWayland::xdg_system_bell_v1::interface()->name)) {
mGlobals.systemBell.reset(new WithDestructor<QtWayland::xdg_system_bell_v1, xdg_system_bell_v1_destroy>(registry, id, 1));
}
mRegistryGlobals.append(RegistryGlobal(id, interface, version, registry));

View File

@ -55,6 +55,7 @@ namespace QtWayland {
class wp_cursor_shape_manager_v1;
class wp_fractional_scale_manager_v1;
class wp_viewporter;
class xdg_system_bell_v1;
class xdg_toplevel_drag_manager_v1;
}
@ -206,6 +207,10 @@ public:
{
return mGlobals.xdgToplevelDragManager.get();
}
QtWayland::xdg_system_bell_v1 *systemBell() const
{
return mGlobals.systemBell.get();
}
struct RegistryGlobal {
@ -337,6 +342,7 @@ private:
std::unique_ptr<QtWayland::wp_viewporter> viewporter;
std::unique_ptr<QtWayland::wp_fractional_scale_manager_v1> fractionalScaleManager;
std::unique_ptr<QtWayland::wp_cursor_shape_manager_v1> cursorShapeManager;
std::unique_ptr<QtWayland::xdg_system_bell_v1> systemBell;
std::unique_ptr<QtWayland::xdg_toplevel_drag_manager_v1> xdgToplevelDragManager;
std::unique_ptr<QWaylandWindowManagerIntegration> windowManagerIntegration;
} mGlobals;

View File

@ -57,6 +57,8 @@
#include "qwaylandinputdeviceintegrationfactory_p.h"
#include "qwaylandwindow_p.h"
#include <QtWaylandClient/private/qwayland-xdg-system-bell-v1.h>
#if QT_CONFIG(accessibility_atspi_bridge)
#include <QtGui/private/qspiaccessiblebridge_p.h>
#endif
@ -529,6 +531,14 @@ void QWaylandIntegration::setApplicationBadge(qint64 number)
{
mPlatformServices->setApplicationBadge(number);
}
void QWaylandIntegration::beep() const
{
if (auto bell = mDisplay->systemBell()) {
bell->ring(nullptr);
}
}
}
QT_END_NAMESPACE

View File

@ -90,6 +90,7 @@ public:
#endif
void setApplicationBadge(qint64 number) override;
void beep() const override;
virtual QWaylandInputDevice *createInputDevice(QWaylandDisplay *display, int version, uint32_t id) const;
virtual QWaylandScreen *createPlatformScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id) const;