wayland: Add support for system bell protocol

This integrates with the system bell the same way as the equivalent
request in gtk-shell does.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3675>
This commit is contained in:
Jonas Ådahl 2024-03-28 09:45:55 +01:00 committed by Marge Bot
parent 59f40fe16c
commit 95e395c212
7 changed files with 135 additions and 2 deletions

View File

@ -101,7 +101,7 @@ variables:
- .skip-git-clone
variables:
FDO_DISTRIBUTION_VERSION: 41
BASE_TAG: '2024-09-20.2'
BASE_TAG: '2024-10-15.0'
MUTTER_USER: 'meta-user'
FDO_DISTRIBUTION_PACKAGES:
clang
@ -150,6 +150,10 @@ variables:
https://gitlab.gnome.org/GNOME/gi-docgen.git \
main
./.gitlab-ci/install-meson-project.sh \
https://gitlab.freedesktop.org/wayland/wayland-protocols.git \
1.38
./.gitlab-ci/install-common-dependencies.sh
rpm -e --nodeps gnome-bluetooth-libs-devel \

View File

@ -47,7 +47,7 @@ gudev_req = '>= 238'
# wayland version requirements
wayland_server_req = '>= 1.23'
wayland_protocols_req = '>= 1.36'
wayland_protocols_req = '>= 1.38'
# native backend version requirements
libinput_req = '>= 1.26.0'

View File

@ -671,6 +671,8 @@ if have_wayland
'wayland/meta-wayland-subsurface.h',
'wayland/meta-wayland-surface.c',
'wayland/meta-wayland-surface-private.h',
'wayland/meta-wayland-system-bell.c',
'wayland/meta-wayland-system-bell.h',
'wayland/meta-wayland-tablet.c',
'wayland/meta-wayland-tablet-cursor-surface.c',
'wayland/meta-wayland-tablet-cursor-surface.h',
@ -1102,6 +1104,7 @@ if have_wayland
['primary-selection', 'unstable', 'v1', ],
['relative-pointer', 'unstable', 'v1', ],
['single-pixel-buffer', 'staging', 'v1', ],
['xdg-system-bell', 'staging', 'v1', ],
['tablet', 'unstable', 'v2', ],
['text-input', 'unstable', 'v3', ],
['viewporter', 'stable', ],

View File

@ -0,0 +1,100 @@
/*
* Copyright (C) 2024 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include "wayland/meta-wayland-system-bell.h"
#include "core/bell.h"
#include "wayland/meta-wayland-surface-private.h"
#include "wayland/meta-wayland-versions.h"
#include "wayland/meta-wayland.h"
#include "xdg-system-bell-v1-server-protocol.h"
static void
system_bell_destroy (struct wl_client *client,
struct wl_resource *resource)
{
wl_resource_destroy (resource);
}
static MetaWindow *
find_window_from_resource (struct wl_resource *surface_resource)
{
MetaWaylandSurface *surface;
surface = wl_resource_get_user_data (surface_resource);
if (!surface)
return NULL;
return meta_wayland_surface_get_window (surface);
}
static void
system_bell_ring (struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *surface_resource)
{
MetaWaylandCompositor *compositor =
META_WAYLAND_COMPOSITOR (wl_resource_get_user_data (resource));
MetaContext *context = meta_wayland_compositor_get_context (compositor);
MetaDisplay *display = meta_context_get_display (context);
if (surface_resource)
meta_bell_notify (display, find_window_from_resource (surface_resource));
else
meta_bell_notify (display, NULL);
}
static const struct xdg_system_bell_v1_interface system_bell_implementation =
{
system_bell_destroy,
system_bell_ring,
};
static void
system_bell_bind (struct wl_client *client,
void *user_data,
uint32_t version,
uint32_t id)
{
MetaWaylandCompositor *compositor = user_data;
struct wl_resource *resource;
resource = wl_resource_create (client,
&xdg_system_bell_v1_interface,
version, id);
wl_resource_set_implementation (resource,
&system_bell_implementation,
compositor, NULL);
}
void
meta_wayland_init_system_bell (MetaWaylandCompositor *compositor)
{
struct wl_display *wl_display =
meta_wayland_compositor_get_wayland_display (compositor);
if (!wl_global_create (wl_display,
&xdg_system_bell_v1_interface,
META_WP_SYSTEM_BELL_V1_VERSION,
compositor,
system_bell_bind))
g_error ("Failed to create xdg_system_bell_v1 global");
}

View File

@ -0,0 +1,23 @@
/*
* Copyright (C) 2024 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "wayland/meta-wayland-types.h"
void meta_wayland_init_system_bell (MetaWaylandCompositor *compositor);

View File

@ -61,3 +61,4 @@
#define META_XDG_DIALOG_VERSION 1
#define META_WP_DRM_LEASE_DEVICE_V1_VERSION 1
#define META_XDG_SESSION_MANAGER_V1_VERSION 1
#define META_WP_SYSTEM_BELL_V1_VERSION 1

View File

@ -55,6 +55,7 @@
#include "wayland/meta-wayland-region.h"
#include "wayland/meta-wayland-seat.h"
#include "wayland/meta-wayland-subsurface.h"
#include "wayland/meta-wayland-system-bell.h"
#include "wayland/meta-wayland-tablet-manager.h"
#include "wayland/meta-wayland-transaction.h"
#include "wayland/meta-wayland-xdg-dialog.h"
@ -895,6 +896,7 @@ meta_wayland_compositor_new (MetaContext *context)
meta_wayland_init_xdg_wm_dialog (compositor);
meta_wayland_init_color_management (compositor);
meta_wayland_xdg_session_management_init (compositor);
meta_wayland_init_system_bell (compositor);
#ifdef HAVE_NATIVE_BACKEND
meta_wayland_drm_lease_manager_init (compositor);