backends/native: Don't fake device IDs

Stop making them up, they go nowhere.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1569>
This commit is contained in:
Carlos Garnacho 2020-11-17 15:09:59 +01:00 committed by Marge Bot
parent 7738ce2a64
commit 20e6464087
2 changed files with 1 additions and 56 deletions

View File

@ -59,18 +59,11 @@ static void stop_mousekeys_move (MetaInputDeviceNative *device);
static void static void
meta_input_device_native_finalize (GObject *object) meta_input_device_native_finalize (GObject *object)
{ {
ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (object);
MetaInputDeviceNative *device_evdev = META_INPUT_DEVICE_NATIVE (object); MetaInputDeviceNative *device_evdev = META_INPUT_DEVICE_NATIVE (object);
ClutterBackend *backend;
ClutterSeat *seat;
if (device_evdev->libinput_device) if (device_evdev->libinput_device)
libinput_device_unref (device_evdev->libinput_device); libinput_device_unref (device_evdev->libinput_device);
backend = clutter_get_default_backend ();
seat = clutter_backend_get_default_seat (backend);
meta_seat_native_release_device_id (META_SEAT_NATIVE (seat), device);
clear_slow_keys (device_evdev); clear_slow_keys (device_evdev);
stop_bounce_keys (device_evdev); stop_bounce_keys (device_evdev);
stop_toggle_slowkeys (device_evdev); stop_toggle_slowkeys (device_evdev);
@ -1281,14 +1274,13 @@ meta_input_device_native_new (MetaSeatNative *seat,
MetaInputDeviceNative *device; MetaInputDeviceNative *device;
ClutterInputDeviceType type; ClutterInputDeviceType type;
char *vendor, *product; char *vendor, *product;
int device_id, n_rings = 0, n_strips = 0, n_groups = 1; int n_rings = 0, n_strips = 0, n_groups = 1;
char *node_path; char *node_path;
double width, height; double width, height;
type = meta_input_device_native_determine_type (libinput_device); type = meta_input_device_native_determine_type (libinput_device);
vendor = g_strdup_printf ("%.4x", libinput_device_get_id_vendor (libinput_device)); vendor = g_strdup_printf ("%.4x", libinput_device_get_id_vendor (libinput_device));
product = g_strdup_printf ("%.4x", libinput_device_get_id_product (libinput_device)); product = g_strdup_printf ("%.4x", libinput_device_get_id_product (libinput_device));
device_id = meta_seat_native_acquire_device_id (seat);
node_path = g_strdup_printf ("/dev/input/%s", libinput_device_get_sysname (libinput_device)); node_path = g_strdup_printf ("/dev/input/%s", libinput_device_get_sysname (libinput_device));
if (libinput_device_has_capability (libinput_device, if (libinput_device_has_capability (libinput_device,
@ -1300,7 +1292,6 @@ meta_input_device_native_new (MetaSeatNative *seat,
} }
device = g_object_new (META_TYPE_INPUT_DEVICE_NATIVE, device = g_object_new (META_TYPE_INPUT_DEVICE_NATIVE,
"id", device_id,
"name", libinput_device_get_name (libinput_device), "name", libinput_device_get_name (libinput_device),
"device-type", type, "device-type", type,
"device-mode", CLUTTER_INPUT_MODE_PHYSICAL, "device-mode", CLUTTER_INPUT_MODE_PHYSICAL,
@ -1343,7 +1334,6 @@ meta_input_device_native_new_virtual (MetaSeatNative *seat,
{ {
MetaInputDeviceNative *device; MetaInputDeviceNative *device;
const char *name; const char *name;
int device_id;
switch (type) switch (type)
{ {
@ -1361,9 +1351,7 @@ meta_input_device_native_new_virtual (MetaSeatNative *seat,
break; break;
}; };
device_id = meta_seat_native_acquire_device_id (seat);
device = g_object_new (META_TYPE_INPUT_DEVICE_NATIVE, device = g_object_new (META_TYPE_INPUT_DEVICE_NATIVE,
"id", device_id,
"name", name, "name", name,
"device-type", type, "device-type", type,
"device-mode", mode, "device-mode", mode,

View File

@ -3050,49 +3050,6 @@ meta_seat_native_update_xkb_state (MetaSeatNative *seat)
meta_seat_native_sync_leds (seat); meta_seat_native_sync_leds (seat);
} }
gint
meta_seat_native_acquire_device_id (MetaSeatNative *seat)
{
GList *first;
gint next_id;
if (seat->free_device_ids == NULL)
{
gint i;
/* We ran out of free ID's, so append 10 new ones. */
for (i = 0; i < 10; i++)
seat->free_device_ids =
g_list_append (seat->free_device_ids,
GINT_TO_POINTER (seat->device_id_next++));
}
first = g_list_first (seat->free_device_ids);
next_id = GPOINTER_TO_INT (first->data);
seat->free_device_ids = g_list_delete_link (seat->free_device_ids, first);
return next_id;
}
static int
compare_ids (gconstpointer a,
gconstpointer b)
{
return GPOINTER_TO_INT (a) - GPOINTER_TO_INT (b);
}
void
meta_seat_native_release_device_id (MetaSeatNative *seat,
ClutterInputDevice *device)
{
gint device_id;
device_id = clutter_input_device_get_device_id (device);
seat->free_device_ids = g_list_insert_sorted (seat->free_device_ids,
GINT_TO_POINTER (device_id),
compare_ids);
}
/** /**
* meta_seat_native_release_devices: * meta_seat_native_release_devices:
* *