From 2dec4dd088680bb3dcf198d6ae38d0e559358966 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 7 Nov 2023 13:21:39 +0100 Subject: [PATCH] core: Manage MetaPadActionMapper devices through events Use the CLUTTER_DEVICE_ADDED/REMOVED set of events instead of the ClutterSeat signals to track device availability. Part-of: --- src/core/events.c | 2 ++ src/core/meta-pad-action-mapper.c | 24 +++++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/core/events.c b/src/core/events.c index 3ae38110a..eb6177c3b 100644 --- a/src/core/events.c +++ b/src/core/events.c @@ -340,6 +340,8 @@ meta_display_handle_event (MetaDisplay *display, if (event_type != CLUTTER_DEVICE_ADDED && event_type != CLUTTER_DEVICE_REMOVED) handle_idletime_for_event (display, event); + else + meta_pad_action_mapper_handle_event (display->pad_action_mapper, event); if (event_type == CLUTTER_MOTION) { diff --git a/src/core/meta-pad-action-mapper.c b/src/core/meta-pad-action-mapper.c index cc4f06298..60d6453ec 100644 --- a/src/core/meta-pad-action-mapper.c +++ b/src/core/meta-pad-action-mapper.c @@ -134,9 +134,8 @@ pad_mapping_info_free (PadMappingInfo *info) } static void -device_added (ClutterSeat *seat, - ClutterInputDevice *device, - MetaPadActionMapper *mapper) +device_added (MetaPadActionMapper *mapper, + ClutterInputDevice *device) { PadMappingInfo *info; @@ -149,9 +148,8 @@ device_added (ClutterSeat *seat, } static void -device_removed (ClutterSeat *seat, - ClutterInputDevice *device, - MetaPadActionMapper *mapper) +device_removed (MetaPadActionMapper *mapper, + ClutterInputDevice *device) { g_hash_table_remove (mapper->pads, device); } @@ -163,10 +161,6 @@ meta_pad_action_mapper_init (MetaPadActionMapper *mapper) (GDestroyNotify) pad_mapping_info_free); mapper->seat = clutter_backend_get_default_seat (clutter_get_default_backend ()); - g_signal_connect (mapper->seat, "device-added", - G_CALLBACK (device_added), mapper); - g_signal_connect (mapper->seat, "device-removed", - G_CALLBACK (device_removed), mapper); } MetaPadActionMapper * @@ -727,9 +721,17 @@ meta_pad_action_mapper_handle_event (MetaPadActionMapper *mapper, return meta_pad_action_mapper_handle_action (mapper, pad, event, META_PAD_FEATURE_STRIP, number, mode); + case CLUTTER_DEVICE_ADDED: + device_added (mapper, clutter_event_get_source_device (event)); + break; + case CLUTTER_DEVICE_REMOVED: + device_removed (mapper, clutter_event_get_source_device (event)); + break; default: - return FALSE; + break; } + + return CLUTTER_EVENT_PROPAGATE; } static char *