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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3370>
This commit is contained in:
Carlos Garnacho 2023-11-07 13:21:39 +01:00 committed by Marge Bot
parent b611569b26
commit 2dec4dd088
2 changed files with 15 additions and 11 deletions

View File

@ -340,6 +340,8 @@ meta_display_handle_event (MetaDisplay *display,
if (event_type != CLUTTER_DEVICE_ADDED && if (event_type != CLUTTER_DEVICE_ADDED &&
event_type != CLUTTER_DEVICE_REMOVED) event_type != CLUTTER_DEVICE_REMOVED)
handle_idletime_for_event (display, event); handle_idletime_for_event (display, event);
else
meta_pad_action_mapper_handle_event (display->pad_action_mapper, event);
if (event_type == CLUTTER_MOTION) if (event_type == CLUTTER_MOTION)
{ {

View File

@ -134,9 +134,8 @@ pad_mapping_info_free (PadMappingInfo *info)
} }
static void static void
device_added (ClutterSeat *seat, device_added (MetaPadActionMapper *mapper,
ClutterInputDevice *device, ClutterInputDevice *device)
MetaPadActionMapper *mapper)
{ {
PadMappingInfo *info; PadMappingInfo *info;
@ -149,9 +148,8 @@ device_added (ClutterSeat *seat,
} }
static void static void
device_removed (ClutterSeat *seat, device_removed (MetaPadActionMapper *mapper,
ClutterInputDevice *device, ClutterInputDevice *device)
MetaPadActionMapper *mapper)
{ {
g_hash_table_remove (mapper->pads, device); g_hash_table_remove (mapper->pads, device);
} }
@ -163,10 +161,6 @@ meta_pad_action_mapper_init (MetaPadActionMapper *mapper)
(GDestroyNotify) pad_mapping_info_free); (GDestroyNotify) pad_mapping_info_free);
mapper->seat = clutter_backend_get_default_seat (clutter_get_default_backend ()); 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 * MetaPadActionMapper *
@ -727,9 +721,17 @@ meta_pad_action_mapper_handle_event (MetaPadActionMapper *mapper,
return meta_pad_action_mapper_handle_action (mapper, pad, event, return meta_pad_action_mapper_handle_action (mapper, pad, event,
META_PAD_FEATURE_STRIP, META_PAD_FEATURE_STRIP,
number, mode); 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: default:
return FALSE; break;
} }
return CLUTTER_EVENT_PROPAGATE;
} }
static char * static char *