From 1fc021c3c662f6df9e999eaa9a439ae42b2688d2 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 1 Oct 2019 17:15:41 +0200 Subject: [PATCH] clutter: Move bell_notify() from ClutterBackend to ClutterSeat Bells can be considered to be a per-seat feature, so move it there. https://gitlab.gnome.org/GNOME/mutter/merge_requests/852 --- clutter/clutter/clutter-backend-private.h | 4 +--- clutter/clutter/clutter-backend.c | 10 -------- clutter/clutter/clutter-backend.h | 3 --- clutter/clutter/clutter-seat.c | 6 +++++ clutter/clutter/clutter-seat.h | 4 ++++ .../native/meta-clutter-backend-native.c | 9 -------- .../native/meta-input-device-native.c | 23 ++++++++----------- src/backends/native/meta-seat-native.c | 10 ++++++++ src/backends/x11/meta-clutter-backend-x11.c | 9 -------- src/backends/x11/meta-seat-x11.c | 10 ++++++++ 10 files changed, 41 insertions(+), 47 deletions(-) diff --git a/clutter/clutter/clutter-backend-private.h b/clutter/clutter/clutter-backend-private.h index 05d62ee01..d75c6a210 100644 --- a/clutter/clutter/clutter-backend-private.h +++ b/clutter/clutter/clutter-backend-private.h @@ -96,9 +96,7 @@ struct _ClutterBackendClass gpointer native, ClutterEvent *event); - void (* bell_notify) (ClutterBackend *backend); - - ClutterKeymap * (* get_keymap) (ClutterBackend *backend); + ClutterKeymap * (* get_keymap) (ClutterBackend *backend); ClutterSeat * (* get_default_seat) (ClutterBackend *backend); diff --git a/clutter/clutter/clutter-backend.c b/clutter/clutter/clutter-backend.c index be4ca76cf..8f44822ec 100644 --- a/clutter/clutter/clutter-backend.c +++ b/clutter/clutter/clutter-backend.c @@ -1009,16 +1009,6 @@ clutter_set_allowed_drivers (const char *drivers) allowed_drivers = g_strdup (drivers); } -void -clutter_backend_bell_notify (ClutterBackend *backend) -{ - ClutterBackendClass *klass; - - klass = CLUTTER_BACKEND_GET_CLASS (backend); - if (klass->bell_notify) - klass->bell_notify (backend); -} - /** * clutter_backend_get_input_method: * @backend: the #CLutterBackend diff --git a/clutter/clutter/clutter-backend.h b/clutter/clutter/clutter-backend.h index ad577e7b2..2d24ffd41 100644 --- a/clutter/clutter/clutter-backend.h +++ b/clutter/clutter/clutter-backend.h @@ -73,9 +73,6 @@ const cairo_font_options_t * clutter_backend_get_font_options (Clutter CLUTTER_EXPORT CoglContext * clutter_backend_get_cogl_context (ClutterBackend *backend); -CLUTTER_EXPORT -void clutter_backend_bell_notify (ClutterBackend *backend); - CLUTTER_EXPORT ClutterInputMethod * clutter_backend_get_input_method (ClutterBackend *backend); diff --git a/clutter/clutter/clutter-seat.c b/clutter/clutter/clutter-seat.c index a8af0a4e8..c4f1f0744 100644 --- a/clutter/clutter/clutter-seat.c +++ b/clutter/clutter/clutter-seat.c @@ -208,3 +208,9 @@ clutter_seat_list_devices (ClutterSeat *seat) return CLUTTER_SEAT_GET_CLASS (seat)->list_devices (seat); } + +void +clutter_seat_bell_notify (ClutterSeat *seat) +{ + CLUTTER_SEAT_GET_CLASS (seat)->bell_notify (seat); +} diff --git a/clutter/clutter/clutter-seat.h b/clutter/clutter/clutter-seat.h index 40c9286a7..62130dd87 100644 --- a/clutter/clutter/clutter-seat.h +++ b/clutter/clutter/clutter-seat.h @@ -45,6 +45,8 @@ struct _ClutterSeatClass ClutterInputDevice * (* get_keyboard) (ClutterSeat *seat); GList * (* list_devices) (ClutterSeat *seat); + + void (* bell_notify) (ClutterSeat *seat); }; CLUTTER_EXPORT @@ -53,5 +55,7 @@ CLUTTER_EXPORT ClutterInputDevice * clutter_seat_get_keyboard (ClutterSeat *seat); CLUTTER_EXPORT GList * clutter_seat_list_devices (ClutterSeat *seat); +CLUTTER_EXPORT +void clutter_seat_bell_notify (ClutterSeat *seat); #endif /* CLUTTER_SEAT_H */ diff --git a/src/backends/native/meta-clutter-backend-native.c b/src/backends/native/meta-clutter-backend-native.c index 2cab84734..cae9c6728 100644 --- a/src/backends/native/meta-clutter-backend-native.c +++ b/src/backends/native/meta-clutter-backend-native.c @@ -103,14 +103,6 @@ meta_clutter_backend_native_create_stage (ClutterBackend *backend, return CLUTTER_STAGE_WINDOW (clutter_backend_native->stage_native); } -static void -meta_clutter_backend_native_bell_notify (ClutterBackend *backend) -{ - MetaDisplay *display = meta_get_display (); - - meta_bell_notify (display, NULL); -} - static ClutterDeviceManager * meta_clutter_backend_native_get_device_manager (ClutterBackend *backend) { @@ -162,7 +154,6 @@ meta_clutter_backend_native_class_init (MetaClutterBackendNativeClass *klass) clutter_backend_class->get_renderer = meta_clutter_backend_native_get_renderer; clutter_backend_class->create_stage = meta_clutter_backend_native_create_stage; - clutter_backend_class->bell_notify = meta_clutter_backend_native_bell_notify; clutter_backend_class->get_device_manager = meta_clutter_backend_native_get_device_manager; clutter_backend_class->get_keymap = meta_clutter_backend_native_get_keymap; clutter_backend_class->init_events = meta_clutter_backend_native_init_events; diff --git a/src/backends/native/meta-input-device-native.c b/src/backends/native/meta-input-device-native.c index 296aee6ca..49d3106fe 100644 --- a/src/backends/native/meta-input-device-native.c +++ b/src/backends/native/meta-input-device-native.c @@ -223,12 +223,9 @@ meta_input_device_native_is_grouped (ClutterInputDevice *device, } static void -meta_input_device_native_bell_notify (void) +meta_input_device_native_bell_notify (MetaInputDeviceNative *device) { - ClutterBackend *backend; - - backend = clutter_get_default_backend (); - clutter_backend_bell_notify (backend); + clutter_seat_bell_notify (CLUTTER_SEAT (device->seat)); } static void @@ -277,7 +274,7 @@ trigger_slow_keys (gpointer data) meta_input_device_native_free_pending_slow_key (slow_keys_event); if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_BEEP_ACCEPT) - meta_input_device_native_bell_notify (); + meta_input_device_native_bell_notify (device); return G_SOURCE_REMOVE; } @@ -315,7 +312,7 @@ start_slow_keys (ClutterEvent *event, device->slow_keys_list = g_list_append (device->slow_keys_list, slow_keys_event); if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_BEEP_PRESS) - meta_input_device_native_bell_notify (); + meta_input_device_native_bell_notify (device); } static void @@ -335,7 +332,7 @@ stop_slow_keys (ClutterEvent *event, meta_input_device_native_free_pending_slow_key (slow_keys_event); if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_BEEP_REJECT) - meta_input_device_native_bell_notify (); + meta_input_device_native_bell_notify (device); return; } @@ -389,7 +386,7 @@ static void notify_bounce_keys_reject (MetaInputDeviceNative *device) { if (device->a11y_flags & CLUTTER_A11Y_BOUNCE_KEYS_BEEP_REJECT) - meta_input_device_native_bell_notify (); + meta_input_device_native_bell_notify (device); } static gboolean @@ -609,7 +606,7 @@ handle_stickykeys_release (ClutterEvent *event, if (key_event_is_modifier (event)) { if (device->a11y_flags & CLUTTER_A11Y_STICKY_KEYS_BEEP) - meta_input_device_native_bell_notify (); + meta_input_device_native_bell_notify (device); return; } @@ -628,7 +625,7 @@ trigger_toggle_slowkeys (gpointer data) device->toggle_slowkeys_timer = 0; if (device->a11y_flags & CLUTTER_A11Y_FEATURE_STATE_CHANGE_BEEP) - meta_input_device_native_bell_notify (); + meta_input_device_native_bell_notify (device); if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_ENABLED) set_slowkeys_off (device); @@ -690,7 +687,7 @@ handle_enablekeys_release (ClutterEvent *event, device->shift_count = 0; if (device->a11y_flags & CLUTTER_A11Y_FEATURE_STATE_CHANGE_BEEP) - meta_input_device_native_bell_notify (); + meta_input_device_native_bell_notify (device); if (device->a11y_flags & CLUTTER_A11Y_STICKY_KEYS_ENABLED) set_stickykeys_off (device); @@ -1227,7 +1224,7 @@ void meta_input_device_native_a11y_maybe_notify_toggle_keys (MetaInputDeviceNative *device) { if (device->a11y_flags & CLUTTER_A11Y_TOGGLE_KEYS_ENABLED) - meta_input_device_native_bell_notify (); + meta_input_device_native_bell_notify (device); } static void diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c index e6325f164..7f12bc6b5 100644 --- a/src/backends/native/meta-seat-native.c +++ b/src/backends/native/meta-seat-native.c @@ -38,6 +38,7 @@ #include "backends/native/meta-input-device-tool-native.h" #include "backends/native/meta-keymap-native.h" #include "clutter/clutter-mutter.h" +#include "core/bell.h" /* * Clutter makes the assumption that two core devices have ID's 2 and 3 (core @@ -2503,6 +2504,14 @@ meta_seat_native_list_devices (ClutterSeat *seat) return devices; } +static void +meta_seat_native_bell_notify (ClutterSeat *seat) +{ + MetaDisplay *display = meta_get_display (); + + meta_bell_notify (display, NULL); +} + static void meta_seat_native_class_init (MetaSeatNativeClass *klass) { @@ -2518,6 +2527,7 @@ meta_seat_native_class_init (MetaSeatNativeClass *klass) seat_class->get_pointer = meta_seat_native_get_pointer; seat_class->get_keyboard = meta_seat_native_get_keyboard; seat_class->list_devices = meta_seat_native_list_devices; + seat_class->bell_notify = meta_seat_native_bell_notify; props[PROP_SEAT_ID] = g_param_spec_string ("seat-id", diff --git a/src/backends/x11/meta-clutter-backend-x11.c b/src/backends/x11/meta-clutter-backend-x11.c index 33a9138a2..4be8c2b28 100644 --- a/src/backends/x11/meta-clutter-backend-x11.c +++ b/src/backends/x11/meta-clutter-backend-x11.c @@ -80,14 +80,6 @@ meta_clutter_backend_x11_create_stage (ClutterBackend *backend, return stage; } -static void -meta_clutter_backend_x11_bell_notify (ClutterBackend *backend) -{ - MetaDisplay *display = meta_get_display (); - - meta_bell_notify (display, NULL); -} - static ClutterDeviceManager * meta_clutter_backend_x11_get_device_manager (ClutterBackend *backend) { @@ -187,7 +179,6 @@ meta_clutter_backend_x11_class_init (MetaClutterBackendX11Class *klass) clutter_backend_class->get_renderer = meta_clutter_backend_x11_get_renderer; clutter_backend_class->create_stage = meta_clutter_backend_x11_create_stage; - clutter_backend_class->bell_notify = meta_clutter_backend_x11_bell_notify; clutter_backend_class->get_device_manager = meta_clutter_backend_x11_get_device_manager; clutter_backend_class->get_keymap = meta_clutter_backend_x11_get_keymap; clutter_backend_class->translate_event = meta_clutter_backend_x11_translate_event; diff --git a/src/backends/x11/meta-seat-x11.c b/src/backends/x11/meta-seat-x11.c index 72fcacd93..b2c2d7815 100644 --- a/src/backends/x11/meta-seat-x11.c +++ b/src/backends/x11/meta-seat-x11.c @@ -27,6 +27,7 @@ #include "backends/x11/meta-stage-x11.h" #include "clutter/clutter-mutter.h" #include "clutter/x11/clutter-x11.h" +#include "core/bell.h" #include "meta-seat-x11.h" enum @@ -1418,6 +1419,14 @@ meta_seat_x11_list_devices (ClutterSeat *seat) return retval; } +static void +meta_seat_x11_bell_notify (ClutterSeat *seat) +{ + MetaDisplay *display = meta_get_display (); + + meta_bell_notify (display, NULL); +} + static void meta_seat_x11_class_init (MetaSeatX11Class *klass) { @@ -1432,6 +1441,7 @@ meta_seat_x11_class_init (MetaSeatX11Class *klass) seat_class->get_pointer = meta_seat_x11_get_pointer; seat_class->get_keyboard = meta_seat_x11_get_keyboard; seat_class->list_devices = meta_seat_x11_list_devices; + seat_class->bell_notify = meta_seat_x11_bell_notify; props[PROP_OPCODE] = g_param_spec_int ("opcode",